Emit a customer event
POST /v1/events
| Property | Value |
|---|---|
| Operation | create_event |
| Group | Events |
| Scope | events:write |
| Route class | control |
| Idempotency | Idempotency-Key required: a retry with the same key replays the first answer |
| Audit | Audited event.emitted (mutation) |
| Released in | 1.62.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Records a customer-emitted event of the family custom, source customer, and answers 202 with its id and targets (1.62.0); the relay delivers it as every record event is, and in PHI mode its data travels in no payload. With process the processes module records a Process event named by the custom type and writes its commands; with call_id the calls module appends custom.received to the Call. Data above 32 KiB (a target) is data_too_large and a Call of the other environment, or ended more than 24 hours ago, call_not_targetable (CustomEventIssueCode); an instance by id that ended is process_not_active, and an unknown one or Process not_found. At most 20 a second per key (a target).
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the events:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/events" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "type": "custom.payment.received" }'const response = await fetch(`${process.env.VOCAL_API}/v1/events`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"type": "custom.payment.received"
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/events",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"type": "custom.payment.received",
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idempotency-key | header | string | yes | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: CustomEventCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
call_id | CallId | no | A Call of the key's environment, live or ended within 24 hours (a target), which records custom.received. |
data | map of any | no | A JSON object of at most 32 KiB (a target) as canonical JSON, stored as a content pair. Content. |
process | CustomEventProcessTargetInput | no | |
type | CustomEventType | yes |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
202 | application/json | CustomEvent | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | process_not_active, idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 202 answer
The shape is CustomEvent.
| Field | Type | Required | Description |
|---|---|---|---|
call_id | CallId or null | yes | |
created_at | Timestamp | yes | |
id | EventId | yes | The id the event carries on every surface, assigned once in the request transaction: de-duplicate on it. |
livemode | boolean | yes | True for the live environment. |
object | "custom_event" | yes | |
process_event_id | ProcessEventId or null | yes | The Process event recorded for the Process target; null without one. |
process_id | ProcessInstanceId or null | yes | The instance the request named by id; null for a correlation key or none. |
type | CustomEventType | yes | |
workflow_id | WorkflowId or null | yes |