Create Event
Define a custom event for your organization. An event definition is a named schema: once defined, you can send events against it and use them to trigger automations.
Endpoint
POST /events
Returns: 201 Created
Headers
| Header | Value | Required |
|---|---|---|
Authorization | Bearer <your-api-key> | Yes |
Content-Type | application/json | Yes |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique event name for your organization. 1–80 characters. Immutable after creation. |
description | string | No | Human-readable description. Max 2000 characters. |
schema | object | No | Field schema that ingested payloads are validated against. Defaults to no fields. See below. |
conversion | object | No | Mark this event as a conversion and map its revenue value/currency. See below. |
Schema object
schema.fields is an array of field definitions. Payloads sent to this event are validated against them.
| Field | Type | Description |
|---|---|---|
name | string | Field identifier. Letters, digits, and underscores; must start with a letter or underscore. Max 64 characters. |
type | string | One of string, number, boolean, date. |
required | boolean | Whether the field must be present in every payload. |
{
"name": "order.completed",
"description": "Fired when a customer completes checkout.",
"schema": {
"fields": [
{ "name": "order_id", "type": "string", "required": true },
{ "name": "total", "type": "number", "required": true },
{ "name": "is_gift", "type": "boolean", "required": false }
]
}
}
Conversion object
Mark an event as a conversion so it counts toward goals and revenue reporting. The revenue value and currency are read from fields on the event's own schema.
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | Yes | Whether this event counts as a conversion. false clears any existing config. |
value_field | string | null | When enabled | Numeric schema field holding the revenue value. Send null for a count-only conversion (no revenue). Required when enabled is true. |
currencies | string[] | For monetary | Accepted ISO-4217 currency codes (e.g. ["SAR","USD"]). Required when value_field is a (non-null) field name. One = fixed currency; many = read per event from currency_field. |
currency_field | string | When >1 currency | Schema field holding each event's ISO-4217 currency. Required when more than one currency is accepted. |
{
"name": "order.completed",
"schema": {
"fields": [
{ "name": "order_id", "type": "string", "required": true },
{ "name": "total", "type": "number", "required": true },
{ "name": "currency", "type": "string", "required": true }
]
},
"conversion": {
"enabled": true,
"value_field": "total",
"currencies": ["SAR", "USD"],
"currency_field": "currency"
}
}
The API never guesses the revenue field. When enabling a conversion, send value_field: a numeric field name, or null for a count-only conversion. Omitting value_field while enabled is true returns 422.
The event definition is saved before the conversion config is applied. If the conversion object is invalid (e.g. missing value_field), the request returns an error but the event is already created with no conversion config. Don't retry the same POST (it returns 409, duplicate name); fix the conversion config with PATCH /events/:id.
A send for an undefined event name returns 404.
Response
{
"id": "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a",
"name": "order.completed",
"description": "Fired when a customer completes checkout.",
"schema": {
"fields": [
{ "name": "order_id", "type": "string", "required": true },
{ "name": "total", "type": "number", "required": true },
{ "name": "is_gift", "type": "boolean", "required": false }
]
},
"conversion": {
"enabled": false,
"value_field": null,
"currency_field": null,
"currencies": null
},
"created_at": "2026-06-01T12:00:00.000Z",
"updated_at": "2026-06-01T12:00:00.000Z"
}
| Field | Type | Description |
|---|---|---|
id | string | Unique event ID (UUIDv7) |
name | string | Event name (unique per organization, immutable) |
description | string | null | Description, or null |
schema | object | The field schema ({ "fields": [...] }) |
conversion | object | Conversion config: enabled, value_field, currency_field, currencies (all null when not a conversion) |
created_at | string | ISO 8601 timestamp |
updated_at | string | ISO 8601 timestamp |
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X POST "https://api.arsel.sa/v1/events" \
-H "Authorization: Bearer $ARSEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "order.completed",
"description": "Fired when a customer completes checkout.",
"schema": {
"fields": [
{
"name": "order_id",
"type": "string",
"required": true
},
{
"name": "total",
"type": "number",
"required": true
}
]
}
}'
const response = await fetch("https://api.arsel.sa/v1/events", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ARSEL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "order.completed",
description: "Fired when a customer completes checkout.",
schema: {
fields: [
{
name: "order_id",
type: "string",
required: true,
},
{
name: "total",
type: "number",
required: true,
},
],
},
}),
});
const data = await response.json();
if (!response.ok) {
throw new Error(`${data.name}: ${data.message}`);
}
console.log(data);
import os
import requests
response = requests.post(
"https://api.arsel.sa/v1/events",
headers={"Authorization": f"Bearer {os.environ['ARSEL_API_KEY']}"},
json={
"name": "order.completed",
"description": "Fired when a customer completes checkout.",
"schema": {
"fields": [
{
"name": "order_id",
"type": "string",
"required": True,
},
{
"name": "total",
"type": "number",
"required": True,
},
],
},
},
)
response.raise_for_status()
print(response.json())
using System.Net.Http.Headers;
using System.Text;
var client = new HttpClient(); // share one instance across requests
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ARSEL_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.arsel.sa/v1/events")
{
Content = new StringContent(
"""
{
"name": "order.completed",
"description": "Fired when a customer completes checkout.",
"schema": {
"fields": [
{
"name": "order_id",
"type": "string",
"required": true
},
{
"name": "total",
"type": "number",
"required": true
}
]
}
}
""",
Encoding.UTF8,
"application/json"),
};
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"{(int)response.StatusCode}: {body}");
Console.WriteLine(body);
<?php
$ch = curl_init("https://api.arsel.sa/v1/events");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("ARSEL_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "order.completed",
"description" => "Fired when a customer completes checkout.",
"schema" => [
"fields" => [
[
"name" => "order_id",
"type" => "string",
"required" => true,
],
[
"name" => "total",
"type" => "number",
"required" => true,
],
],
],
]),
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) {
throw new Exception("{$data['name']}: {$data['message']}");
}
print_r($data);
Error Responses
- 409 Conflict
- 400 Bad Conversion
- 422 Validation Error
- 401 Unauthorized
{
"status_code": 409,
"name": "conflict",
"message": "An event named \"order.completed\" already exists"
}
{
"status_code": 400,
"name": "conversion_value_field_invalid",
"message": "\"total\" is not a numeric field on this event."
}
{
"status_code": 422,
"name": "validation_error",
"message": "name must be longer than or equal to 1 characters"
}
{
"status_code": 401,
"name": "unauthorized",
"message": "Invalid API Key"
}