MessageOS
Guides

Events

How a business sends an event, and how to sign an inbound event.

An event tells MessageOS that something happened in your own system, such as a new lead or a finished order. MessageOS can then message the person about it, with a reminder or a follow-up, by the rules set up for your agent. Those rules are called an event playbook. While the assistant is paused or the agent is API only, event playbook messages are not sent.

Sending an event

POST /v1/events needs the scope events:write. It answers 404 not_found until MessageOS turns events on for you.

The body is an envelope:

{
  "id": "client-event-1",
  "occurredAt": "2026-10-28T23:00:00.000Z",
  "contact": { "phoneNumber": "+15555550123" },
  "type": "lead.created",
  "data": { "leadId": "L-1", "source": "web" }
}
  • contact must include contactId, phoneNumber, or externalId.
  • type starts with a lowercase letter and may contain lowercase letters, numbers, dots, underscores, and hyphens, 2 to 64 characters. conversation.idle is reserved and is rejected.
  • When the client declared a schema for that type, data must match it. Otherwise data is free-form, up to 8192 bytes of JSON by default.
  • The optional id is the client's own id. Sending it again returns the same event with "status": "duplicate".

A new event returns 202:

{ "id": "evt_...", "status": "received" }

An unknown phone creates a contact with no consent record. A proactive message to that contact is still blocked until consent is recorded or the person texts in. An external id alone does not create a contact, because a phone number is required.

Example types a client may use, or replace with their own: crm.order.completed, lead.created, appointment.reminder_due, qr.scanned, rcs_ad.clicked. None of these grant consent by themselves.

Sending an event again

The Idempotency-Key header is also accepted. A key reused with a different body returns 422 idempotency_key_reuse, and a key reused while the first request is still running returns 409 conflict with Retry-After: 1.

A request that fails, such as one answered 503 service_unavailable, may still have been received. Send the event again after the seconds in Retry-After, with the same id, or with the same Idempotency-Key and body, and it is processed once. Without either, a resend can make a second event.

Signed events from another system

Another system can post the same envelope to POST /webhooks/clients/{sourceId} with no client key. It signs each request with the secret of an event source instead. The route answers 404 until MessageOS turns inbound event webhooks on for you.

POST /v1/event-sources with webhooks:manage creates a source:

{ "name": "Orders", "allowedTypes": ["lead.created"] }

The response includes id and secret once. The secret belongs to that source. A type that is not in allowedTypes is rejected.

Each event the source posts carries two headers:

  • x-messageos-timestamp: unix seconds
  • x-messageos-signature: sha256= plus the lowercase hex HMAC-SHA256 of <timestamp>.<raw body>

The signature is made the same way as the one on a webhook. Sign the raw body you send.

  • A bad signature, a timestamp more than 300 seconds from the server clock, or an unknown source returns not found.
  • An accepted event returns 202 with the same body as POST /v1/events.
  • When MessageOS cannot complete the request just now, it returns 503 service_unavailable with a Retry-After header. Send the event again after that many seconds, signed with a new timestamp, and give it an id so a repeat stays one event.

On this page