Skip to main content

Create Event

Define a new 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

HeaderValueRequired
AuthorizationBearer <your-api-key>Yes
Content-Typeapplication/jsonYes

Body Parameters

ParameterTypeRequiredDescription
namestringYesUnique event name for your organization. 1–80 characters. Immutable after creation.
descriptionstringNoHuman-readable description. Max 2000 characters.
schemaobjectNoField schema that ingested payloads are validated against. Defaults to no fields. See below.
conversionobjectNoMark 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.

FieldTypeDescription
namestringField identifier. Letters, digits, and underscores; must start with a letter or underscore. Max 64 characters.
typestringOne of string, number, boolean, date.
requiredbooleanWhether 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.

FieldTypeRequiredDescription
enabledbooleanYesWhether this event counts as a conversion. false clears any existing config.
value_fieldstring | nullWhen enabledNumeric schema field holding the revenue value. Send null for a count-only conversion (no revenue). Required when enabled is true.
currenciesstring[]For monetaryAccepted 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_fieldstringWhen >1 currencySchema 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"
}
}
Explicit value field

Unlike the dashboard, the API never guesses the revenue field. When enabling a conversion you must send value_field — either a numeric field name, or null for a count-only conversion. Omitting value_field while enabled is true returns 422.

If the conversion config is rejected, the event is still created

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 has already been created with no conversion config. Do not retry the same POST — it will return 409 (duplicate name). Instead, fix the conversion config with PATCH /events/:id.

Define before you send

You must create an event definition before sending events to it. A send for an undefined 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"
}
FieldTypeDescription
idstringUnique event ID (UUIDv7)
namestringEvent name (unique per organization, immutable)
descriptionstring | nullDescription, or null
schemaobjectThe field schema ({ "fields": [...] })
conversionobjectConversion config: enabled, value_field, currency_field, currencies (all null when not a conversion)
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

Examples

curl -X POST "https://api.arsel.sa/v1/events" \
-H "Authorization: Bearer be_your_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 }
]
}
}'

Error Responses

{
"status_code": 409,
"name": "conflict",
"message": "An event named \"order.completed\" already exists"
}