Deewan API Reference

REST API reference for Relay - By Deewan: send SMS and WhatsApp messages, manage contacts, segments and campaigns, and read delivery logs. 77 endpoints, authenticated with a single API key. This page is public — no account needed to read it.

Two hosts, one API key

Generate a REST API key in the portal, then send it as Authorization: Bearer <key> or X-API-Key. One key works for both hosts. Which host serves a request is decided entirely by its path:

GW
Messaging — send SMS and WhatsApp, read and write contact tags and CDP attributes. Every path under /api/v1/.
https://ops.relay.deewan.sa
CP
Management API — contacts, segments, campaigns, message logs, apps and billing reads. Every path under /api/mgmt/v1/. A key must have Management API access enabled, which is a per-key setting in the portal.
https://portal.relay.deewan.sa

The messaging host sends no CORS headers, so those endpoints are server-to-server only — they cannot be called from a browser.

Platform

A connectivity check for the sending platform, for uptime monitoring.

- Needs no authentication. Every other endpoint needs a credential (see Authentication).

GET /api/health Messaging host

Platform health check

Reports whether the platform is up and connected to its database (db) and its message queue (nats).

  • No authentication required.
  • Always answers 200 while the service runs; check db and nats for connected / disconnected.

cURL

curl -X GET "https://ops.relay.deewan.sa/api/health" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/health", {
  method: "GET",
  headers: {
    "Content-Type": "application/json"
},
});
const data = await res.json();
console.log(data);

Responses

200

Service statuses

{
  "status": "ok",
  "db": "connected",
  "nats": "connected"
}

Contacts

Your contact list (CRM): create, search, import, export, update and delete contacts.

- The /api/v1/contacts/:phone endpoints read and update a contact's tags and custom attributes with an API key, by phone number.

GET /api/mgmt/v1/contacts Management host API key

List contacts

A page of contacts, newest first, narrowed by status, opt-in status, segment, tag and a search query.

  • search takes plain text (matched against name, phone, email, tags and custom attributes) or comma-separated conditions such as tier = gold, country = SA, vip; all terms must match.
  • A query is limited to 512 characters and 12 terms. An unparseable condition returns 400 invalid_query.
  • A search that takes too long returns 503 query_too_slow — add an exact tag or status to narrow it.
  • Engagement figures in behaviorProfile cover the last 30 days and are recalculated nightly.

Parameters

NameInTypeDescription
page query integer Page number (default 1) 1
limit query integer Items per page, max 200 (default 50) 50
status query string subscribed or unsubscribed subscribed
optInStatus query string confirmed, pending or not-requested confirmed
tag query string Only contacts with this tag vip
segment query string Only contacts in this segment (ObjectId) 64f1...
search query string Free text, or conditions such as tier = gold, vip (see above). q is accepted as an alias. jane

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/contacts" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/contacts", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Contacts page

{
  "contacts": [
    {
      "_id": "...",
      "phone": "+1...",
      "name": "Jane",
      "status": "subscribed",
      "tags": [
        "vip"
      ]
    }
  ],
  "total": 1240,
  "page": 1,
  "limit": 50
}
GET /api/mgmt/v1/contacts/stats Management host API key

Contact statistics

Total and subscribed contact counts, and each segment with its stored contact count.

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/contacts/stats" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/contacts/stats", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Stats

{
  "total": 1240,
  "subscribed": 1100,
  "subscribedPercent": 88.7,
  "segments": [
    {
      "name": "VIPs",
      "contactCount": 230
    }
  ]
}
GET /api/mgmt/v1/contacts/:id Management host API key

Get a contact

Returns one contact by ObjectId.

  • behaviorProfile holds messages sent and delivered and the engagementScore for the last 30 days, recalculated nightly.

Parameters

NameInTypeDescription
id * path string Contact ObjectId 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/contacts/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/contacts/{id}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Contact

{
  "_id": "...",
  "phone": "+12025551234",
  "name": "Jane Doe",
  "status": "subscribed",
  "tags": [
    "vip"
  ],
  "behaviorProfile": {
    "messagesSent": 12,
    "messagesDelivered": 11,
    "engagementScore": 72
  }
}
404

Not found

{
  "error": "Contact not found"
}
POST /api/mgmt/v1/contacts Management host API key

Create a contact

Creates one contact. Requires the admin or editor role.

  • A contact needs a valid phone or email. The phone is converted to international format; a number without a country code uses defaultCountry, else your account's default country.
  • A phone already used by another contact returns 409; so does the email of an email-only contact that already exists.
  • On the Free plan, a contact beyond your included contacts is refused with 403 free_contact_cap.

Request body

FieldTypeRequiredDescription
phone string one of

Mobile number, ideally in international format (+9665…). Rejected with 400 if it is not a valid number.

email string one of

Email address. Send it alone for an email-only contact.

name string optional

Display name.

status string optional

subscribed (default) or unsubscribed. Creating as unsubscribed records the opt-out date.

optInStatus string optional

confirmed, pending or not-requested (default).

tags string[] optional

Tags to add to the contact.

country string optional

Country, stored as given. city and region work the same way.

metadata.cdpAttributes object optional

Custom attributes as key/value pairs, e.g. { "tier": "gold" }.

defaultCountry string optional

Dialling code for a number without a country code: 966, 971, 973, 974, 965, 968, 962 or 20.

Phone and email

{
  "phone": "+12025551234",
  "name": "Jane Doe",
  "email": "jane@example.com",
  "status": "subscribed",
  "tags": [
    "newsletter"
  ]
}

Email-only contact

{
  "email": "sara@example.com",
  "name": "Sara"
}

Local number with a default country

{
  "phone": "0501234567",
  "defaultCountry": "966",
  "name": "Omar"
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/contacts" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"phone":"+12025551234","name":"Jane Doe","email":"jane@example.com","status":"subscribed","tags":["newsletter"]}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/contacts", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "phone": "+12025551234",
    "name": "Jane Doe",
    "email": "jane@example.com",
    "status": "subscribed",
    "tags": [
        "newsletter"
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

201

Created

{
  "_id": "...",
  "phone": "+12025551234",
  "name": "Jane Doe",
  "status": "subscribed"
}
409

Phone or email already exists

{
  "error": "Contact with this phone already exists"
}
POST /api/mgmt/v1/contacts/import Management host API key

Bulk import contacts

Adds many contacts in one request. Contacts that already exist are skipped, not updated. Requires the admin or editor role.

  • Up to 100,000 contacts per request (413 above that).
  • Each row needs a valid phone or email; rows with neither are counted in invalid. Rows that repeat a phone or email in the same request are counted in duplicatesInFile.
  • A row with phone and email whose email belongs to an existing email-only contact adds the phone to that contact.
  • The response also reports emailOnly (email-only rows) and conflicts (rows lost to a simultaneous write).
  • addToSegment puts every contact in the request, new and existing, into a fixed segment. It is checked before any contact is written.
  • If adding to the segment fails afterwards, the import still stands and segmentError explains.
  • On the Free plan, an import that would exceed your included contacts is refused with 403 free_contact_cap.

Request body

FieldTypeRequiredDescription
contacts object[] required

The contacts to add (at least one).

contacts[].phone string one of

Mobile number. One without a country code uses defaultCountry.

contacts[].email string one of

Email address. Send it alone for an email-only contact.

contacts[].name string optional

Display name.

contacts[].status string optional

subscribed (default) or unsubscribed.

contacts[].tags string[] optional

Tags for the new contact.

defaultCountry string optional

Dialling code for numbers without a country code, e.g. 966. Default: your account's default country.

addToSegment object optional

Fixed segment to put the contacts in. Send segmentId or name, not both.

addToSegment.segmentId string one of

An existing fixed segment. A live segment is refused with 400.

addToSegment.name string one of

Name for a new fixed segment. 409 if a segment with that name exists.

Import into a new segment

{
  "contacts": [
    {
      "phone": "+12025551234",
      "name": "Jane",
      "status": "subscribed"
    },
    {
      "phone": "+12025559999",
      "name": "Bob",
      "tags": [
        "vip"
      ]
    }
  ],
  "addToSegment": {
    "name": "Expo leads"
  }
}

Import into an existing segment

{
  "contacts": [
    {
      "phone": "0501234567",
      "name": "Omar"
    },
    {
      "email": "sara@example.com",
      "name": "Sara"
    }
  ],
  "defaultCountry": "966",
  "addToSegment": {
    "segmentId": "64f1c0ffee0000000000aaaa"
  }
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/contacts/import" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"contacts":[{"phone":"+12025551234","name":"Jane","status":"subscribed"},{"phone":"+12025559999","name":"Bob","tags":["vip"]}],"addToSegment":{"name":"Expo leads"}}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/contacts/import", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "contacts": [
        {
            "phone": "+12025551234",
            "name": "Jane",
            "status": "subscribed"
        },
        {
            "phone": "+12025559999",
            "name": "Bob",
            "tags": [
                "vip"
            ]
        }
    ],
    "addToSegment": {
        "name": "Expo leads"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

200

Import result

{
  "imported": 1,
  "skipped": 1,
  "segment": {
    "_id": "...",
    "name": "Expo leads",
    "created": true,
    "added": 2,
    "contactCount": 2
  }
}
400

Invalid payload, or a live segment chosen

{
  "error": "contacts array is required"
}
404

Chosen segment not found

{
  "error": "The chosen segment no longer exists."
}
409

New segment name already used

{
  "error": "A segment named \"Expo leads\" already exists. Choose it from the list, or use a different name."
}
PUT /api/mgmt/v1/contacts/:id Management host API key

Update a contact

Updates the fields you send; fields you leave out keep their value. Requires the admin or editor role.

  • A changed phone is validated and converted to international format, like Create a contact.
  • A contact must keep a phone or an email (400 otherwise). A phone or email already used by another contact returns 409.
  • Setting status to unsubscribed records the opt-out date.

Parameters

NameInTypeDescription
id * path string Contact ObjectId 64f1...

Request body

FieldTypeRequiredDescription
name string optional

Display name.

phone string optional

New mobile number. Send "" to remove it (the contact must keep an email).

email string optional

New email address. Send "" to remove it (the contact must keep a phone).

status string optional

subscribed or unsubscribed.

optInStatus string optional

confirmed, pending or not-requested.

tags string[] optional

Replaces the whole tag list.

defaultCountry string optional

Dialling code used if the new phone has no country code, e.g. 966.

{
  "name": "Jane Smith",
  "tags": [
    "vip",
    "newsletter"
  ],
  "status": "subscribed"
}

cURL

curl -X PUT "https://portal.relay.deewan.sa/api/mgmt/v1/contacts/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Jane Smith","tags":["vip","newsletter"],"status":"subscribed"}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/contacts/{id}", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "name": "Jane Smith",
    "tags": [
        "vip",
        "newsletter"
    ],
    "status": "subscribed"
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated contact

{
  "_id": "...",
  "phone": "+12025551234",
  "name": "Jane Smith"
}
404

Not found

{
  "error": "Contact not found"
}
GET /api/v1/contacts/:phone Messaging host API key

Get contact profile (Gateway)

Returns a contact's name, status, tags and custom attributes by phone number.

  • The phone must match the stored number exactly (international format, e.g. +12025551234); 404 if no contact has it.

Parameters

NameInTypeDescription
phone * path string Phone in international format, URL-encoded (+ → %2B) %2B12025551234

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/contacts/{phone}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/contacts/{phone}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Contact profile

{
  "phone": "+12025551234",
  "name": "Jane Doe",
  "status": "subscribed",
  "tags": [
    "vip"
  ],
  "attributes": {
    "loyalty_tier": "gold"
  },
  "updatedAt": "2025-03-01T12:00:00Z"
}
404

Not found

{
  "error": "Contact not found"
}
POST /api/v1/contacts/:phone/tags Messaging host API key

Add tags to a contact (Gateway)

Adds tags and keeps the existing ones. Returns the full tag list.

  • If no contact has this phone, a subscribed contact is created with it.
  • The phone is used exactly as sent — send it in international format.

Parameters

NameInTypeDescription
phone * path string Phone in international format, URL-encoded (+ → %2B) %2B12025551234

Request body

FieldTypeRequiredDescription
tags string[] required

At least one tag. Spaces around each tag are trimmed; tags already on the contact are not repeated.

{
  "tags": [
    "vip",
    "promo-june"
  ]
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/contacts/{phone}/tags" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"tags":["vip","promo-june"]}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/contacts/{phone}/tags", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "tags": [
        "vip",
        "promo-june"
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated tag list

{
  "phone": "+12025551234",
  "tags": [
    "newsletter",
    "vip",
    "promo-june"
  ]
}
400

Invalid payload

{
  "error": "tags must be a non-empty array of strings"
}
PUT /api/v1/contacts/:phone/tags Messaging host API key

Replace all tags (Gateway)

Replaces the contact's whole tag list.

  • Send "tags": [] to clear all tags.
  • If no contact has this phone, a subscribed contact is created with it.

Parameters

NameInTypeDescription
phone * path string Phone in international format, URL-encoded (+ → %2B) %2B12025551234

Request body

FieldTypeRequiredDescription
tags string[] required

The new tag list (may be empty). Spaces around each tag are trimmed.

{
  "tags": [
    "newsletter"
  ]
}

cURL

curl -X PUT "https://ops.relay.deewan.sa/api/v1/contacts/{phone}/tags" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"tags":["newsletter"]}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/contacts/{phone}/tags", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "tags": [
        "newsletter"
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

200

New tag list

{
  "phone": "+12025551234",
  "tags": [
    "newsletter"
  ]
}
DELETE /api/v1/contacts/:phone/tags Messaging host API key

Remove tags from a contact (Gateway)

Removes the listed tags and returns the remaining ones.

  • Tags the contact does not have are ignored. Matching is exact (no trimming).

Parameters

NameInTypeDescription
phone * path string Phone in international format, URL-encoded (+ → %2B) %2B12025551234

Request body

FieldTypeRequiredDescription
tags string[] required

At least one tag to remove.

{
  "tags": [
    "promo-june"
  ]
}

cURL

curl -X DELETE "https://ops.relay.deewan.sa/api/v1/contacts/{phone}/tags" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"tags":["promo-june"]}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/contacts/{phone}/tags", {
  method: "DELETE",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "tags": [
        "promo-june"
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

200

Remaining tags

{
  "phone": "+12025551234",
  "tags": [
    "newsletter",
    "vip"
  ]
}
404

Contact not found

{
  "error": "Contact not found"
}
PATCH /api/v1/contacts/:phone/attributes Messaging host API key

Set CDP attributes (Gateway)

Sets or updates custom attributes. Attributes you leave out keep their value. Returns all of the contact's attributes.

  • 1 to 50 attributes per request. Values are stored as strings.
  • . and $ in a key are replaced with _.
  • If no contact has this phone, a subscribed contact is created with it.

Parameters

NameInTypeDescription
phone * path string Phone in international format, URL-encoded (+ → %2B) %2B12025551234

Request body

FieldTypeRequiredDescription
attributes object required

Key/value pairs to set, e.g. { "loyalty_tier": "gold" }.

{
  "attributes": {
    "loyalty_tier": "gold",
    "last_purchase": "2025-03-01",
    "preferred_language": "en"
  }
}

cURL

curl -X PATCH "https://ops.relay.deewan.sa/api/v1/contacts/{phone}/attributes" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"attributes":{"loyalty_tier":"gold","last_purchase":"2025-03-01","preferred_language":"en"}}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/contacts/{phone}/attributes", {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "attributes": {
        "loyalty_tier": "gold",
        "last_purchase": "2025-03-01",
        "preferred_language": "en"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated attributes

{
  "phone": "+12025551234",
  "attributes": {
    "loyalty_tier": "gold",
    "last_purchase": "2025-03-01",
    "preferred_language": "en"
  }
}
400

Invalid payload

{
  "error": "attributes must be a key-value object"
}
DELETE /api/v1/contacts/:phone/attributes/:key Messaging host API key

Remove a CDP attribute (Gateway)

Removes one custom attribute and returns the remaining ones.

  • Removing a key the contact does not have still returns 200.

Parameters

NameInTypeDescription
phone * path string Phone in international format, URL-encoded (+ → %2B) %2B12025551234
key * path string Attribute key to remove loyalty_tier

cURL

curl -X DELETE "https://ops.relay.deewan.sa/api/v1/contacts/{phone}/attributes/{key}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/contacts/{phone}/attributes/{key}", {
  method: "DELETE",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Remaining attributes

{
  "phone": "+12025551234",
  "attributes": {
    "last_purchase": "2025-03-01"
  }
}
404

Contact not found

{
  "error": "Contact not found"
}

Segments

Group contacts for campaign and automation targeting.

- A live segment (type: "dynamic") stores a rule; its members are whoever matches the rule when it is read.
- A fixed segment (type: "static") holds a list of contacts that only changes when you add or remove them.

GET /api/mgmt/v1/segments Management host API key

List segments

Returns all segments, newest first.

  • A live segment's contactCount is recounted on each call; if a count is slow, the last known count is returned.
  • definition describes a live segment's rule in words. system: true marks segments Relay maintains from order data (they cannot be deleted).

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/segments" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/segments", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Segments

[
  {
    "_id": "...",
    "name": "VIPs",
    "type": "static",
    "contactCount": 230
  }
]
POST /api/mgmt/v1/segments Management host API key

Create a segment

Creates a live segment from a rule, or a fixed segment from the contacts matching a rule now and/or a list of contact ids. Requires the admin or editor role.

  • A rule is query and/or the status, optInStatus, tag and segment filters.
  • With a rule and membership other than "fixed", the rule is saved and re-evaluated on every read.
  • With membership: "fixed", up to 50,000 contacts matching the rule now are saved; truncated: true reports a cut-off. contactIds are added too.
  • With neither a rule nor contactIds, an empty fixed segment is created.
  • A live rule's segment filter must point at a fixed segment (400 otherwise).
  • Names are unique per account, ignoring case (409 if taken).
  • Snapshotting a slow rule returns 503 query_too_slow.

Request body

FieldTypeRequiredDescription
name string required

Segment name.

description string optional

Free-text description.

membership string optional

live (default) or fixed.

query string optional

Contact search query, e.g. city = Riyadh, vip — same syntax as search in List contacts.

status string optional

Rule filter: subscribed or unsubscribed.

optInStatus string optional

Rule filter: confirmed, pending or not-requested.

tag string optional

Rule filter: contacts with this tag.

segment string optional

Rule filter: contacts in this segment (ObjectId).

contactIds string[] optional

Contact ObjectIds to add, 1–5,000. Only with membership: "fixed".

Fixed segment from a query

{
  "name": "Riyadh VIPs — Ramadan list",
  "membership": "fixed",
  "query": "city = Riyadh, vip"
}

Live segment

{
  "name": "Subscribed gold tier",
  "query": "tier = gold",
  "status": "subscribed"
}

Fixed segment of chosen contacts

{
  "name": "Event guests",
  "membership": "fixed",
  "contactIds": [
    "64f1c0ffee0000000000aaaa",
    "64f1c0ffee0000000000bbbb"
  ]
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/segments" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Riyadh VIPs — Ramadan list","membership":"fixed","query":"city = Riyadh, vip"}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/segments", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "name": "Riyadh VIPs — Ramadan list",
    "membership": "fixed",
    "query": "city = Riyadh, vip"
}),
});
const data = await res.json();
console.log(data);

Responses

201

Created

{
  "_id": "...",
  "name": "Riyadh VIPs — Ramadan list",
  "type": "static",
  "contactCount": 412,
  "truncated": false
}
400

Invalid rule, or a live rule on top of another live segment

{
  "error": "A live segment can't be built on another live segment. Save it as a fixed segment instead."
}
PUT /api/mgmt/v1/segments/:id Management host API key

Update a segment

Renames a segment, changes its description, or replaces its rule. Requires the admin or editor role.

  • Sending a rule (query and/or status, optInStatus, tag, segment) makes the segment live with that rule, even if it was fixed.
  • Names are unique per account, ignoring case (409 if taken).

Parameters

NameInTypeDescription
id * path string Segment ObjectId 64f1...

Request body

FieldTypeRequiredDescription
name string optional

New name (not empty).

description string optional

New description.

query string optional

New rule query, as in Create a segment.

status string optional

Rule filter: subscribed or unsubscribed.

optInStatus string optional

Rule filter: confirmed, pending or not-requested.

tag string optional

Rule filter: contacts with this tag.

segment string optional

Rule filter: contacts in this segment (ObjectId).

Rename

{
  "name": "Premium buyers",
  "description": "Updated description"
}

Replace the rule

{
  "query": "totalOrders >= 3",
  "status": "subscribed"
}

cURL

curl -X PUT "https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Premium buyers","description":"Updated description"}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "name": "Premium buyers",
    "description": "Updated description"
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated

{
  "_id": "...",
  "name": "Premium buyers"
}
404

Not found

{
  "error": "Segment not found"
}
POST /api/mgmt/v1/segments/:id/contacts Management host API key

Add contacts to segment

Adds contacts to a fixed segment. Requires the admin or editor role.

  • Live segments refuse manual changes (400).
  • added counts contacts that were not already members; ids of contacts outside your account are ignored.

Parameters

NameInTypeDescription
id * path string Segment ObjectId 64f1...

Request body

FieldTypeRequiredDescription
contactIds string[] required

Contact ObjectIds, 1–5,000 per request.

{
  "contactIds": [
    "64f1...",
    "64f2..."
  ]
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}/contacts" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"contactIds":["64f1...","64f2..."]}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}/contacts", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "contactIds": [
        "64f1...",
        "64f2..."
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

200

Added

{
  "added": 2,
  "contactCount": 232
}
GET /api/mgmt/v1/segments/:id/contacts Management host API key

List contacts in segment

A page of the segment's contacts, newest first. For a live segment, the contacts matching its rule now.

  • A segment that takes too long to resolve returns 503 query_too_slow.

Parameters

NameInTypeDescription
id * path string Segment ObjectId 64f1...
page query integer Page number (default 1) 1
limit query integer Items per page, max 200 (default 50) 50

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}/contacts" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}/contacts", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Contacts page

{
  "contacts": [],
  "total": 230,
  "page": 1,
  "limit": 50
}
POST /api/mgmt/v1/segments/:id/populate Management host API key

Auto-populate from filter

Adds the subscribed contacts matching a filter (as used by AI segment suggestions) to a fixed segment. Requires the admin or editor role.

  • Only subscribed contacts are added, whatever the filter.
  • Up to 50,000 contacts per call; truncated: true reports a cut-off.
  • Live segments refuse it (400).

Parameters

NameInTypeDescription
id * path string Segment ObjectId 64f1...

Request body

FieldTypeRequiredDescription
filter object required

Which contacts to add.

filter.type string required

engagementScore, tag, cdpAttribute or subscribed (all subscribed contacts).

filter.min number optional

engagementScore: score at least this (0–100). Takes precedence over max.

filter.max number optional

engagementScore: score at most this.

filter.value string conditional

The tag. Required for tag.

filter.key string conditional

Custom attribute name (letters, numbers, underscores); contacts with a non-empty value match. Required for cdpAttribute.

Engagement score

{
  "filter": {
    "type": "engagementScore",
    "min": 70
  }
}

Tag

{
  "filter": {
    "type": "tag",
    "value": "vip"
  }
}

Has a custom attribute

{
  "filter": {
    "type": "cdpAttribute",
    "key": "loyalty_tier"
  }
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}/populate" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"filter":{"type":"engagementScore","min":70}}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/segments/{id}/populate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "filter": {
        "type": "engagementScore",
        "min": 70
    }
}),
});
const data = await res.json();
console.log(data);

Responses

200

Contacts added

{
  "added": 145
}

Campaigns

Create, schedule and send broadcast campaigns to contact segments or to your own uploaded list of recipients.

- A campaign is created as a draft, gets its audience (segments, or a recipient file in three upload calls), then is launched.
- Creating, editing, uploading, launching and pausing require the admin or editor role.

GET /api/mgmt/v1/campaigns Management host API key

List campaigns

Your campaigns, newest first, one page at a time, with an optional status filter.

Parameters

NameInTypeDescription
status query string draft | queued | sending | completed | failed | paused sending
page query integer Page number (default 1) 1
limit query integer Items per page (default 20, max 100) 20

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Campaigns page

{
  "campaigns": [
    {
      "_id": "...",
      "name": "Summer Sale",
      "status": "completed",
      "estimatedReach": 500
    }
  ],
  "total": 12,
  "page": 1
}
POST /api/mgmt/v1/campaigns Management host API key

Create a campaign

Creates a campaign in draft status. Target contacts with targetSegments, or leave it out and attach your own recipient file with the three upload calls below. Then call Launch a campaign.

  • For SMS, send either free text in content or an approved SMS template in smsTemplateId — the campaign then sends the template's approved text.
  • Template tokens are filled from the recipient's value of the same name (a contact field or attribute, or a column of your recipient file), or from smsVariableMap.
  • A/B variants may each name their own smsTemplateId. The template must still be approved at launch, and must allow the campaign's sender if it restricts senders.
  • The sender must be one your account may use; otherwise the call returns 400.
  • A/B tests, tracked links and the WhatsApp and email settings take further fields, set by the campaign builder in the portal.

Request body

FieldTypeRequiredDescription
name string required

Campaign name, up to 120 characters, no HTML (< >).

channel string optional

sms (default), whatsapp or email.

senderId string conditional

SMS sender ID. Required for SMS campaigns.

content string one of

SMS text. In free text, {name} is the contact's name; with a recipient file, each of its variables is a {token}. Replaced by the template text when smsTemplateId is set.

smsTemplateId string one of

An SMS template of your account, used instead of content. Must be approved by launch time.

smsTemplateLocale string optional

Language version of the template, e.g. ar. Must exist on the template.

smsVariableMap object optional

Template token → value: another field's name ("code": "tier"), or a fixed value in quotes ("date": "\"30 Nov\"").

targetSegments string[] optional

Segment ids to send to. Leave out to upload a recipient file instead.

schedule object optional

When to send. Default: as soon as it is launched.

schedule.type string optional

immediate (default) or scheduled.

schedule.date string conditional

ISO 8601 date-time in the future. Required when type is scheduled.

schedule.timezone string optional

Time zone of the schedule (default UTC).

Free text

{
  "name": "Summer Sale",
  "senderId": "BRAND",
  "content": "Hi {name}, get 20% off today! Reply STOP to unsubscribe.",
  "targetSegments": [
    "seg-id"
  ],
  "schedule": {
    "type": "immediate"
  }
}

From an approved SMS template

{
  "name": "Points expiry",
  "senderId": "BRAND",
  "smsTemplateId": "6727b1c0ffee000000000001",
  "smsTemplateLocale": "ar",
  "smsVariableMap": {
    "date": "\"30 Nov\"",
    "code": "tier"
  },
  "targetSegments": [
    "seg-id"
  ]
}

Scheduled

{
  "name": "Eid greeting",
  "senderId": "BRAND",
  "content": "Eid Mubarak, {name}!",
  "targetSegments": [
    "seg-id"
  ],
  "schedule": {
    "type": "scheduled",
    "date": "2026-12-01T09:00:00Z",
    "timezone": "Asia/Riyadh"
  }
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Summer Sale","senderId":"BRAND","content":"Hi {name}, get 20% off today! Reply STOP to unsubscribe.","targetSegments":["seg-id"],"schedule":{"type":"immediate"}}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "name": "Summer Sale",
    "senderId": "BRAND",
    "content": "Hi {name}, get 20% off today! Reply STOP to unsubscribe.",
    "targetSegments": [
        "seg-id"
    ],
    "schedule": {
        "type": "immediate"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

201

Draft created

{
  "_id": "...",
  "name": "Summer Sale",
  "status": "draft"
}
400

The SMS template is not this account's, lacks the chosen language, or does not allow the sender

{
  "error": "The SMS template \"Points expiry\" can only be sent from BRAND."
}
GET /api/mgmt/v1/campaigns/:id Management host API key

Get a campaign

Returns one campaign with its live delivery figures.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Campaign

{
  "_id": "...",
  "name": "Summer Sale",
  "status": "completed",
  "liveMetrics": {
    "sent": 450,
    "delivered": 430,
    "failed": 20
  }
}
404

Not found

{
  "error": "Campaign not found"
}
PUT /api/mgmt/v1/campaigns/:id Management host API key

Update a campaign

Changes a campaign that has not started sending. Send only the fields to change; they are the same as Create a campaign.

  • Editable while draft, or queued (scheduled) before its send time; otherwise 409.
  • A scheduled campaign cannot be switched back to immediate — change its schedule.date instead.
  • Saving targetSegments on a campaign with an uploaded recipient file replaces the file.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

Request body

FieldTypeRequiredDescription
name string optional

Campaign name, up to 120 characters.

content string optional

SMS text.

senderId string optional

SMS sender ID.

smsTemplateId string optional

Send an approved SMS template instead of content.

targetSegments string[] optional

Segment ids to send to.

schedule object optional

{ type, date, timezone } — as in Create a campaign.

{
  "name": "Summer Sale (Final)",
  "content": "Updated message here."
}

cURL

curl -X PUT "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"Summer Sale (Final)","content":"Updated message here."}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "name": "Summer Sale (Final)",
    "content": "Updated message here."
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated

{
  "_id": "...",
  "name": "Summer Sale (Final)"
}
404

Not found

{
  "error": "Campaign not found"
}
POST /api/mgmt/v1/campaigns/:id/recipients/uploads Management host API key

Start a recipient file upload

Step 1 of 3 for sending a campaign to your own list of recipients. Declare how many batches you will send and keep the returned uploadId for steps 2 and 3.

  • The campaign must be a draft, or scheduled and not yet started.
  • Starting a new upload discards any earlier upload that was never committed. The current audience stays in place until you commit.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

Request body

FieldTypeRequiredDescription
batches integer required

How many batches you will send in step 2: 1–5000.

{
  "batches": 3
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/recipients/uploads" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"batches":3}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/recipients/uploads", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "batches": 3
}),
});
const data = await res.json();
console.log(data);

Responses

201

Upload started

{
  "uploadId": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}
409

Campaign already sending or finished

{
  "error": "This campaign is already sending or finished, so its audience can no longer change."
}
POST /api/mgmt/v1/campaigns/:id/recipients/batch Management host API key

Upload a batch of recipients

Step 2 of 3. Send each batch once, with its batchIndex.

  • Up to 1,000 recipients per batch and 250,000 per campaign.
  • SMS and WhatsApp recipients need a valid mobile number; others are counted in rejected. Email recipients need a valid email.
  • A number or address repeated in the upload is kept once (counted in duplicates).
  • Resending a batch that already arrived is acknowledged without storing it twice, so a batch whose response was lost is safe to resend.
  • Each call counts as 5 requests towards the per-minute rate limit.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

Request body

FieldTypeRequiredDescription
uploadId string required

The id returned by Start a recipient file upload.

batchIndex integer required

0 to batches − 1.

defaultCountry string optional

Dial code for numbers sent without one, e.g. 966. Default: the platform's default country.

recipients object[] required

1–1,000 recipients.

recipients[].mobile string conditional

Mobile number, international or local (with defaultCountry). Required for SMS and WhatsApp campaigns.

recipients[].email string conditional

Email address. Required for email campaigns.

recipients[].variables object optional

Values for this recipient's message: a key such as name fills {name} in the campaign text.

{
  "uploadId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "batchIndex": 0,
  "defaultCountry": "966",
  "recipients": [
    {
      "mobile": "+966501234567",
      "variables": {
        "name": "Sara",
        "code": "EID20"
      }
    },
    {
      "mobile": "0551234567",
      "variables": {
        "name": "Omar",
        "code": "EID20"
      }
    }
  ]
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/recipients/batch" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"uploadId":"7c9e6679-7425-40de-944b-e07fc1f90ae7","batchIndex":0,"defaultCountry":"966","recipients":[{"mobile":"+966501234567","variables":{"name":"Sara","code":"EID20"}},{"mobile":"0551234567","variables":{"name":"Omar","code":"EID20"}}]}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/recipients/batch", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "uploadId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "batchIndex": 0,
    "defaultCountry": "966",
    "recipients": [
        {
            "mobile": "+966501234567",
            "variables": {
                "name": "Sara",
                "code": "EID20"
            }
        },
        {
            "mobile": "0551234567",
            "variables": {
                "name": "Omar",
                "code": "EID20"
            }
        }
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

200

Batch stored

{
  "accepted": 2,
  "rejected": 0,
  "duplicates": 0
}
409

Upload replaced or not started

{
  "error": "This upload is no longer active — another upload replaced it. Upload the file again."
}
413

Too many recipients

{
  "error": "A batch may carry at most 1000 recipients"
}
POST /api/mgmt/v1/campaigns/:id/recipients/uploads/:uploadId/commit Management host API key

Commit a recipient file upload

Step 3 of 3. Once every declared batch has arrived, makes the upload the campaign's audience in one step, replacing any earlier file or segment targeting. Then call Launch a campaign.

  • If batches are missing, nothing is applied and the campaign keeps its previous audience.
  • Safe to retry: a repeated commit of the same upload returns the same total.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...
uploadId * path string The id returned by the start call 7c9e6679-7425-40de-944b-e07fc1f90ae7

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/recipients/uploads/{uploadId}/commit" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/recipients/uploads/{uploadId}/commit", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Audience applied

{
  "total": 2
}
409

Batches missing

{
  "error": "Only 2 of 3 parts of the upload arrived, so it was not applied. Upload the file again."
}
422

No valid recipients

{
  "error": "None of the uploaded rows had a valid mobile number. Check the Mobile Number column and Default Country."
}
POST /api/mgmt/v1/campaigns/:id/launch Management host API key

Launch a campaign

Sends a draft campaign to its audience, or resumes a paused one from where it stopped. A scheduled campaign becomes queued and is sent at its time.

  • The campaign needs segments or a committed recipient file — not both.
  • Your balance must cover the send, or the call returns 402.
  • The sender and any template are checked again at launch.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/launch" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/launch", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Launched

{
  "message": "Campaign launched",
  "recipientCount": 450,
  "status": "sending"
}
402

Insufficient credits

{
  "error": "Insufficient credits"
}
403

Trial quota exhausted

{
  "error": "Trial quota exhausted. Please upgrade to a paid plan."
}
400

No contacts match

{
  "error": "No contacts match the target criteria"
}
POST /api/mgmt/v1/campaigns/:id/pause Management host API key

Pause a sending campaign

Pauses a campaign in sending status. Resume it with Launch a campaign.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/pause" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/pause", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Paused

{
  "_id": "...",
  "status": "paused"
}
404

Not found or not sending

{
  "error": "Campaign not found or not sending"
}
GET /api/mgmt/v1/campaigns/:id/metrics Management host API key

Campaign delivery metrics

Live sent / delivered / failed counts of an SMS campaign, counted from its message records.

Parameters

NameInTypeDescription
id * path string Campaign id 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/metrics" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/campaigns/{id}/metrics", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Metrics

{
  "_id": "...",
  "name": "Summer Sale",
  "liveMetrics": {
    "sent": 450,
    "delivered": 430,
    "failed": 20
  }
}

SMS

Send SMS one at a time, in batches of up to 1,000, or as a CSV file of up to 250,000 rows. Query, filter and export the delivery log.

- Sending endpoints use an API key; the delivery-log endpoints use a portal session.
- The two run on different hosts — check the base URL on each endpoint.

GET /api/mgmt/v1/senders Management host API key

Get available sender IDs

Returns the approved sender IDs you can send from.

  • Inside a project, only the sender IDs granted to that project are listed.

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/senders" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/senders", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Sender IDs

[
  "BRAND",
  "ALERTS",
  "PROMO"
]
POST /api/v1/sms/messages Messaging host API key

Send an SMS

Sends one SMS. All checks (sender, balance, limits, routing) run before the answer, so 202 means the message is queued.

  • A rejected message answers 422 with the reason.
  • promotional messages inside the recipient's quiet hours are held and sent when the window opens.

Request body

FieldTypeRequiredDescription
from string required

An approved sender ID on your account.

to string required

Destination number in international format (+9665…).

text string required

The message text.

campaignId string optional

Links the message log to one of your campaigns.

messageIntent string optional

promotional or transactional. Default: the classification of your sender ID, else transactional. Only promotional messages wait for quiet hours to end.

{
  "from": "BRAND",
  "to": "+12025551234",
  "text": "Hello from Relay!",
  "campaignId": "64f1..."
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/sms/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"BRAND","to":"+12025551234","text":"Hello from Relay!","campaignId":"64f1..."}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "BRAND",
    "to": "+12025551234",
    "text": "Hello from Relay!",
    "campaignId": "64f1..."
}),
});
const data = await res.json();
console.log(data);

Responses

202

Message accepted

{
  "messageId": "uuid",
  "status": "queued",
  "clientId": "CPAAS-XXXX"
}
401

Missing or invalid API key

{
  "error": "Missing API key"
}
403

SMS is not enabled on your account

{
  "error": "SMS is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
422

Rejected (blocklist / quota)

{
  "status": "rejected",
  "reason": "Destination on DND list"
}
400

Missing required fields

{
  "error": "from, to, and text are required"
}
POST /api/v1/sms/messages/bulk Messaging host API key

Bulk send SMS

Sends one message text to up to 1,000 recipients in one call, personalised per recipient with {placeholder} values.

  • The whole request counts as one unit against your messages-per-second cap.
  • Your project's limits come from the API key — no project id in the body.
  • If your balance or limits cover only part of the batch, the first recipients are queued and the rest come back in rejections.
  • Rejection reason: insufficient_balance, client_daily_limit_reached or app_monthly_limit_reached when nothing fits, otherwise quota_exhausted.
  • Do-not-disturb and content checks run later, when each message is sent; see the delivery log.

Request body

FieldTypeRequiredDescription
from string required

An approved sender ID on your account.

text string required

The message text. {name} placeholders are replaced from each recipient's variables (case-insensitive).

recipients array required

1 to 1,000 recipients.

recipients[].to string required

Destination number in international format.

recipients[].variables object optional

Placeholder values for this recipient, e.g. { "name": "Alice" }. Without it, the recipient gets text unchanged.

campaignId string optional

Links the messages to one of your campaigns.

messageIntent string optional

promotional or transactional, as for Send an SMS.

{
  "from": "BRAND",
  "text": "Hi {name}, your order {orderId} is ready for pickup!",
  "recipients": [
    {
      "to": "+12025551001",
      "variables": {
        "name": "Alice",
        "orderId": "A-123"
      }
    },
    {
      "to": "+12025551002",
      "variables": {
        "name": "Bob",
        "orderId": "B-456"
      }
    },
    {
      "to": "+12025551003"
    }
  ],
  "campaignId": "64f1..."
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/sms/messages/bulk" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"BRAND","text":"Hi {name}, your order {orderId} is ready for pickup!","recipients":[{"to":"+12025551001","variables":{"name":"Alice","orderId":"A-123"}},{"to":"+12025551002","variables":{"name":"Bob","orderId":"B-456"}},{"to":"+12025551003"}],"campaignId":"64f1..."}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/messages/bulk", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "BRAND",
    "text": "Hi {name}, your order {orderId} is ready for pickup!",
    "recipients": [
        {
            "to": "+12025551001",
            "variables": {
                "name": "Alice",
                "orderId": "A-123"
            }
        },
        {
            "to": "+12025551002",
            "variables": {
                "name": "Bob",
                "orderId": "B-456"
            }
        },
        {
            "to": "+12025551003"
        }
    ],
    "campaignId": "64f1..."
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued (full or partial)

{
  "queued": 2,
  "rejected": 1,
  "messageIds": [
    {
      "to": "+12025551001",
      "messageId": "uuid"
    },
    {
      "to": "+12025551002",
      "messageId": "uuid"
    }
  ],
  "rejections": [
    {
      "to": "+12025551003",
      "reason": "quota_exhausted"
    }
  ]
}
400

Validation error

{
  "error": "recipients must be a non-empty array of up to 1000 items"
}
401

Missing or invalid API key

{
  "error": "Missing API key (Authorization: Bearer <key> or X-API-Key header)"
}
403

SMS is not enabled on your account

{
  "error": "SMS is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
403

Sender not approved / app paused / IP blocked

{
  "error": "Sender ID \"BRAND\" is not in the approved senders list for this account"
}
429

TPS cap reached

{
  "error": "TPS cap of 50 msg/s reached"
}
POST /api/v1/sms/jobs Messaging host API key

Send an SMS file (send job)

Sends one SMS to every number in a CSV file, up to 250,000 rows and 100 MB, with one call. Upload the file, or give a link to it on your own servers.

  • Idempotency-Key header is required (1–128 printable characters). A repeat call with the same key returns the same job.
  • Nothing is sent unless the whole job is covered: the file is read and priced first, and a short balance stops the job at insufficient_balance.
  • Phone column: the header named msisdn, to, mobile or phone. International format, or local numbers with defaultCountry.
  • Placeholders: any other column can be used in text — {name} is filled from the name column. A placeholder with no matching column refuses the file.
  • ref column: your own id for the row (up to 128 characters), returned on the job's message list and on delivery receipts.
  • A plain list of numbers with no header row (one per line) works when text has no placeholders.
  • Skipped and listed in the error report: invalid mobile numbers, repeated numbers and, by default, rows with an empty placeholder value.
  • At most 3 jobs being read or sent, and 10 scheduled jobs, per account.

Request body

FieldTypeRequiredDescription
from string required

An approved sender ID on your account.

text string required

The message, up to 4,000 characters, with {column} placeholders (case-insensitive).

fileUrl string conditional

JSON form only: an https:// link to the CSV. Give the final link — redirects are not followed. A pre-signed storage link works.

defaultCountry string optional

Dial code for local numbers, e.g. 966 (1–4 digits, + optional). Default: the platform's default country.

name string optional

Job name, up to 120 characters. Default: the file name.

messageIntent string optional

promotional or transactional. Only promotional messages wait for the recipient's quiet hours to end. Default: from your sender ID's classification.

sendAt string optional

ISO 8601 date-time to send at: in the future, at most 30 days ahead. The job waits as scheduled.

autoStart boolean optional

false holds the job as ready until you call Start or resume a send job. Default true.

onEmptyVariable string optional

skip_row (default) skips a row with an empty placeholder value; leave_blank sends it with the placeholder replaced by nothing.

Send the file in one of two ways:

  • application/json: the settings and fileUrl, as shown. The settings may also be nested under a settings key.
  • multipart/form-data: a settings part (the settings as JSON) before a file part with the CSV, e.g. -F 'settings=<JSON>' -F file=@members.csv.

Link to the file (JSON)

{
  "from": "BRAND",
  "text": "Hi {name}, your {points} points expire on 30 Nov.",
  "defaultCountry": "966",
  "fileUrl": "https://files.example.com/exports/members.csv?signature=…",
  "name": "Points expiry",
  "messageIntent": "promotional",
  "sendAt": "2026-11-05T17:00:00Z",
  "autoStart": true,
  "onEmptyVariable": "skip_row"
}

Upload: the settings part (multipart)

{
  "from": "BRAND",
  "text": "Hi {name}, your {points} points expire soon.",
  "defaultCountry": "966"
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/sms/jobs" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"BRAND","text":"Hi {name}, your {points} points expire on 30 Nov.","defaultCountry":"966","fileUrl":"https://files.example.com/exports/members.csv?signature=…","name":"Points expiry","messageIntent":"promotional","sendAt":"2026-11-05T17:00:00Z","autoStart":true,"onEmptyVariable":"skip_row"}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/jobs", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "BRAND",
    "text": "Hi {name}, your {points} points expire on 30 Nov.",
    "defaultCountry": "966",
    "fileUrl": "https://files.example.com/exports/members.csv?signature=…",
    "name": "Points expiry",
    "messageIntent": "promotional",
    "sendAt": "2026-11-05T17:00:00Z",
    "autoStart": true,
    "onEmptyVariable": "skip_row"
}),
});
const data = await res.json();
console.log(data);

Responses

202

Job created — an upload answers once the file is read; a fileUrl job answers at once with status validating

{
  "jobId": "6727b1…",
  "name": "Points expiry",
  "status": "queued",
  "source": {
    "kind": "upload",
    "fileName": "members.csv",
    "bytes": 60524171
  },
  "from": "BRAND",
  "rows": 250000,
  "accepted": 249250,
  "rejected": {
    "invalidNumber": 250,
    "duplicate": 250,
    "missingVariable": 250
  },
  "estimatedCost": {
    "parts": 249250,
    "amount": "4985",
    "currency": "SAR"
  },
  "progress": {
    "published": 0
  },
  "sendAt": null
}
200

Same Idempotency-Key as an earlier call — that job is returned

{
  "jobId": "6727b1…",
  "status": "sending"
}
400

Invalid settings, missing file, missing Idempotency-Key or an unacceptable fileUrl

{
  "error": "An Idempotency-Key header (1–128 printable characters) is required, so a retried upload never creates a second job.",
  "code": "idempotency_key_required"
}
401

No API key, or the Authorization header is not Bearer <key> — answered before the file is read

{
  "error": "The Authorization header must be \"Bearer <key>\" (the word Bearer, a space, then the key) — or send the key in X-API-Key."
}
403

SMS is not enabled on your account

{
  "error": "SMS is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
403

Sender not approved / IP not allowed

{
  "error": "Sender ID \"BRAND\" is not in the approved senders list for this account"
}
413

File over 100 MB — refused at once when the request declares its size, otherwise as soon as 100 MB is passed

{
  "error": "The file is larger than 100 MB. Split it into several jobs, or send it as fileUrl.",
  "code": "file_too_large"
}
422

The uploaded file cannot be used (no phone column, empty, no valid numbers, not CSV) — answered as soon as the problem is found. The job is recorded as failed under jobId, so the Idempotency-Key is spent: fix the file and send it with a new key

{
  "error": "No phone column found — name it one of: msisdn, to, mobile, phone.",
  "code": "invalid_file",
  "jobId": "6727b1…"
}
429

Too many jobs at once (3 being read or sent, 10 scheduled)

{
  "error": "You already have 3 jobs being read or sent. Wait for one to finish."
}
GET /api/v1/sms/jobs/:id Messaging host API key

Get a send job

Status, row counts, cost and delivery progress of a send job.

  • Normal path: validating (file being read) → ready (held, autoStart: false) or scheduled (sendAt) → queued → sending → completed.
  • failed: the file could not be used — see statusReason.
  • insufficient_balance: top up, then call Start or resume a send job.
  • stopped: a daily or project limit was reached — start again once it allows. A job stopped part-way resumes after the last message sent.
  • cancelled: stopped by Cancel a send job.
  • GET /api/v1/sms/jobs lists your jobs, newest first. Query: limit (1–100, default 25), status, and before = the next value of the previous page.

Parameters

NameInTypeDescription
id * path string The jobId returned on create 6727b1…

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Job

{
  "jobId": "6727b1…",
  "status": "sending",
  "rows": 250000,
  "accepted": 249250,
  "rejected": {
    "invalidNumber": 250,
    "duplicate": 250,
    "missingVariable": 250
  },
  "estimatedCost": {
    "parts": 249250,
    "amount": "4985",
    "currency": "SAR"
  },
  "progress": {
    "published": 120000,
    "delivered": 117200,
    "failed": 310,
    "pending": 2490
  }
}
404

Not found

{
  "error": "Job not found"
}
GET /api/v1/sms/jobs/:id/errors Messaging host API key

Rejected rows of a send job (CSV)

A CSV of the rows that were not sent, with columns row,value,reason.

  • reason is invalid_number, duplicate or missing_variable (value is then the name of the empty placeholder).
  • Lists the first 10,000 rejected rows; the X-Rejected-Total header gives the full count, and a final # line says how many are not listed.

Parameters

NameInTypeDescription
id * path string Job id 6727b1…

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/errors" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/errors", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

text/csv

{
  "csv": "row,value,reason\n2,0112345678,invalid_number\n3,0510000000,duplicate\n4,name,missing_variable"
}
GET /api/v1/sms/jobs/:id/messages Messaging host API key

Messages of a send job

One entry per message the job sent, with your row ref, the messageId and its current status, for matching results to your own records.

  • Paged: pass next as after to get the following page; next is null on the last page.
  • Delivery receipts sent to your webhook also carry jobId and ref for these messages.

Parameters

NameInTypeDescription
id * path string Job id 6727b1…
status query string delivered, failed (also rejected, blocked, expired, undelivered) or pending failed
limit query integer Messages per page, 1–1,000 (default 100) 1000
after query string The next value of the previous page 6727c3…

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/messages", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Messages

{
  "messages": [
    {
      "messageId": "3bfc98f9-…",
      "to": "+966510000001",
      "ref": "CRM-88121",
      "status": "Delivered",
      "parts": 1,
      "at": "2026-11-05T17:00:04Z"
    }
  ],
  "next": "6727c3…"
}
POST /api/v1/sms/jobs/:id/start Messaging host API key

Start or resume a send job

Starts a job created with autoStart: false, or resumes one that is insufficient_balance or stopped once you have topped up or the limit allows.

  • The sender ID and the cost are checked again first; the job may stay insufficient_balance or stopped.
  • A job with a future sendAt goes back to scheduled.

Parameters

NameInTypeDescription
id * path string Job id 6727b1…

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/start" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/start", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Job after the check

{
  "jobId": "6727b1…",
  "status": "queued"
}
409

Job cannot be started from its status

{
  "error": "A job that is completed cannot be started."
}
POST /api/v1/sms/jobs/:id/cancel Messaging host API key

Cancel a send job

Stops a job: nothing more is sent.

  • Messages already handed over for sending are not recalled.
  • A job whose file is still being read (validating) cannot be cancelled yet.

Parameters

NameInTypeDescription
id * path string Job id 6727b1…

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/cancel" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/sms/jobs/{id}/cancel", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Cancelled

{
  "jobId": "6727b1…",
  "status": "cancelled"
}
409

Already finished, or the file is still being read

{
  "error": "The file is still being read. Cancel once it is ready."
}
GET /api/mgmt/v1/messages/stats Management host API key

Message statistics

Message counts by status, total parts and average delivery latency for a time window.

  • Default window: today. from is limited to the last 90 days.
  • avgLatencyMs is null when no message in the window has a latency.

Parameters

NameInTypeDescription
from query string ISO 8601 start date (default: start of today) 2025-03-01
to query string ISO 8601 end date (default: now) 2025-03-31
status query string Queued | Sent | Delivered | Failed | Unknown | … Failed
search query string Search sender, destination, messageId, text BRAND
campaignId query string Only the messages of one campaign 64f1...
appId query string Filter to a specific Workspace 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/messages/stats" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/messages/stats", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Stats

{
  "total": 12400,
  "byStatus": {
    "Delivered": 11800,
    "Failed": 420,
    "Sent": 150,
    "Queued": 30
  },
  "avgLatencyMs": 312
}
GET /api/mgmt/v1/messages Management host API key

List message logs

Paged log of your outbound SMS, newest first.

  • Default window: today. from is limited to the last 90 days.
  • total stops at 10,000; totalCapped: true then says there are more.

Parameters

NameInTypeDescription
page query integer Page number 1
limit query integer Items per page, 1–200 (default 50) 50
status query string Queued (in Relay) | Sent (accepted by the carrier, awaiting receipt) | Delivered | Failed | Unknown | Rejected | Blocked Failed
from query string ISO 8601 start date (default: start of today) 2025-03-01
to query string ISO 8601 end date (default: now) 2025-03-31
search query string Search sender, destination, messageId, text BRAND
campaignId query string Only the messages of one campaign 64f1...
appId query string Filter to a Workspace ObjectId 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/messages", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Logs

{
  "logs": [
    {
      "messageId": "uuid",
      "sender": "BRAND",
      "destination": "+1...",
      "status": "Delivered",
      "latencyMs": 320
    }
  ],
  "total": 12400,
  "page": 1,
  "pages": 248
}
GET /api/mgmt/v1/messages/export Management host API key

Export messages as CSV

Downloads the messages matching the filters as a CSV file (Content-Disposition: attachment), newest first.

  • Up to 10,000 rows.
  • Default window: the last 90 days, which is also the furthest back from can go.

Parameters

NameInTypeDescription
status query string Filter by status Failed
from query string ISO 8601 start date (default: 90 days ago) 2025-03-01
to query string ISO 8601 end date (default: now) 2025-03-31
search query string Search sender, destination, messageId, text BRAND
campaignId query string Only the messages of one campaign 64f1...
appId query string Filter by Workspace 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/messages/export" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/messages/export", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

CSV download

{
  "note": "Returns text/csv — use in a download link or curl -o export.csv"
}

WhatsApp

Send WhatsApp messages from your registered numbers: approved templates, text replies and media (image, document, audio, video, sticker). All three use the same endpoint, chosen by type.

- Templates can be sent at any time. Text and media need an open 24-hour service window: the contact messaged you in the last 24 hours.
- Contacts on your WhatsApp suppression list are refused (422, code suppressed).

POST /api/v1/whatsapp/messages Messaging host API key

Send a template

Sends an approved message template. Templates are the only messages allowed when the contact has no open 24-hour service window.

  • Send an Idempotency-Key header so a retry never sends twice: the same key returns the earlier messageId with deduplicated: true.
  • A template that Relay knows is not approved in that language is refused with 422 before sending.
  • Use Get message status with the returned messageId to follow delivery.

Request body

FieldTypeRequiredDescription
from string required

Your registered WhatsApp number, in international format (with or without +, or 00), or its phone number ID. phoneNumberId is accepted as another name for this field.

to string required

Destination number in international format.

type string required

template.

template object required

The template to send.

template.name string required

Name of an approved template on the sending number's WhatsApp Business account.

template.language string required

Language code the template is approved in, e.g. en, ar.

template.variables object optional

Values for {{1}}, {{2}}, … keyed by number. Body placeholders are filled first, then URL-button placeholders in button order.

template.components array optional

Advanced: the components array in WhatsApp Cloud API format, sent as is. Used instead of variables when both are given.

replyToWamid string optional

The wamid of an earlier message to reply to.

clientRef string optional

Your own reference, stored on the message and returned by Get message status. Ignored when an Idempotency-Key header is sent.

{
  "from": "+31644102243",
  "to": "+12025551234",
  "type": "template",
  "template": {
    "name": "order_shipping",
    "language": "en",
    "variables": {
      "1": "Omar Rodrigues",
      "2": "omar@example.com"
    }
  }
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/whatsapp/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"+31644102243","to":"+12025551234","type":"template","template":{"name":"order_shipping","language":"en","variables":{"1":"Omar Rodrigues","2":"omar@example.com"}}}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/whatsapp/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "+31644102243",
    "to": "+12025551234",
    "type": "template",
    "template": {
        "name": "order_shipping",
        "language": "en",
        "variables": {
            "1": "Omar Rodrigues",
            "2": "omar@example.com"
        }
    }
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued for delivery

{
  "messageId": "wa_lxky9z_a1b2c3d4",
  "status": "queued"
}
200

Duplicate idempotency key

{
  "messageId": "wa_lxky9z_a1b2c3d4",
  "status": "sent",
  "deduplicated": true
}
400

Missing or invalid fields

{
  "error": "`from`, `to`, and `type` are required"
}
401

Missing or invalid API key

{
  "error": "Missing API key (Authorization: Bearer <key> or X-API-Key header)"
}
403

WhatsApp is not enabled on your account

{
  "error": "WhatsApp is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
404

Sender not found for this account

{
  "error": "Sender +31644102243 not found for this account"
}
409

Sender not Registered on Cloud API

{
  "error": "Sender is not Registered (state: Pending)"
}
422

Template / suppression failure

{
  "error": "Template 'order_shipping' (en) is not APPROVED (status: PENDING)"
}
429

TPS cap reached (per channel)

{
  "error": "TPS cap of 50 msg/s reached",
  "code": "throughput_exceeded"
}
POST /api/v1/whatsapp/messages Messaging host API key

Send a text reply

Sends free-form text to a contact who messaged you in the last 24 hours (open service window).

  • Outside the window the send is refused with 409 (service_window_closed) — send a template instead.
  • Idempotency-Key works as for Send a template.

Request body

FieldTypeRequiredDescription
from string required

Your registered WhatsApp number or its phone number ID, as for Send a template.

to string required

Destination number in international format.

type string required

text.

text object required

The message.

text.body string required

Message text. WhatsApp allows up to 4,096 characters.

text.preview_url boolean optional

true shows a preview of the first link in the text.

replyToWamid string optional

The wamid of an earlier message (e.g. the contact's inbound message) to reply to.

clientRef string optional

Your own reference, returned by Get message status.

{
  "from": "+31644102243",
  "to": "+12025551234",
  "type": "text",
  "text": {
    "body": "Thanks for reaching out — your order will ship today.",
    "preview_url": false
  },
  "replyToWamid": "wamid.HBgL…"
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/whatsapp/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"+31644102243","to":"+12025551234","type":"text","text":{"body":"Thanks for reaching out — your order will ship today.","preview_url":false},"replyToWamid":"wamid.HBgL…"}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/whatsapp/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "+31644102243",
    "to": "+12025551234",
    "type": "text",
    "text": {
        "body": "Thanks for reaching out — your order will ship today.",
        "preview_url": false
    },
    "replyToWamid": "wamid.HBgL…"
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued

{
  "messageId": "wa_…",
  "status": "queued"
}
409

Service window closed

{
  "error": "No open 24h service window for this contact — use a template send instead",
  "code": "service_window_closed"
}
POST /api/v1/whatsapp/messages Messaging host API key

Send media

Sends an image, document, audio, video or sticker to a contact who messaged you in the last 24 hours (open service window).

  • Set type and put the media under the key of the same name ("type": "document" → document: { … }).
  • Give either link or id; id wins if both are sent.
  • Captions are not shown for audio and sticker.
  • Outside the window the send is refused with 409 (service_window_closed).

Request body

FieldTypeRequiredDescription
from string required

Your registered WhatsApp number or its phone number ID, as for Send a template.

to string required

Destination number in international format.

type string required

image, document, audio, video or sticker.

image object conditional

The image, with type: "image".

image.link string one of

Public HTTPS URL WhatsApp downloads the file from.

image.id string one of

A WhatsApp media ID from an earlier upload.

image.caption string optional

Text shown under the image (also for video and document).

document object conditional

With type: "document": the same fields as image, plus filename.

document.filename string optional

File name shown to the contact.

video object conditional

With type: "video": link or id, and an optional caption.

audio object conditional

With type: "audio": link or id.

sticker object conditional

With type: "sticker": link or id.

replyToWamid string optional

The wamid of an earlier message to reply to.

clientRef string optional

Your own reference, returned by Get message status.

Image

{
  "from": "+31644102243",
  "to": "+12025551234",
  "type": "image",
  "image": {
    "link": "https://cdn.example.com/orders/abc.jpg",
    "caption": "Your order is on its way!"
  }
}

Document

{
  "from": "+31644102243",
  "to": "+12025551234",
  "type": "document",
  "document": {
    "link": "https://cdn.example.com/invoices/INV-1042.pdf",
    "filename": "INV-1042.pdf",
    "caption": "Your invoice"
  }
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/whatsapp/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"+31644102243","to":"+12025551234","type":"image","image":{"link":"https://cdn.example.com/orders/abc.jpg","caption":"Your order is on its way!"}}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/whatsapp/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "+31644102243",
    "to": "+12025551234",
    "type": "image",
    "image": {
        "link": "https://cdn.example.com/orders/abc.jpg",
        "caption": "Your order is on its way!"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued

{
  "messageId": "wa_…",
  "status": "queued"
}
400

Media reference missing

{
  "error": "image requires either `image.link` (public HTTPS URL) or `image.id` (Meta media id)"
}
GET /api/v1/whatsapp/messages/:messageId Messaging host API key

Get message status

Returns the current status and WhatsApp wamid of a message you sent.

  • Also returns readAt, failedAt, errorCode, statusHistory and clientRef when they are set.
  • Works even when WhatsApp sending is switched off for your account.

Parameters

NameInTypeDescription
messageId * path string The messageId returned by POST /api/v1/whatsapp/messages wa_lxky9z_a1b2c3d4

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/whatsapp/messages/{messageId}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/whatsapp/messages/{messageId}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Current status

{
  "messageId": "wa_lxky9z_a1b2c3d4",
  "wamid": "wamid.HBgL…",
  "status": "delivered",
  "type": "template",
  "contactPhone": "+12025551234",
  "phoneNumberId": "1136187512911204",
  "sentAt": "2026-05-21T10:00:00Z",
  "deliveredAt": "2026-05-21T10:00:02Z"
}
404

Not found

{
  "error": "Message not found"
}

Email

Send email from your verified sender identities — a Relay address, or your own DKIM-verified domain.

- Delivery, bounce, complaint, open and click events update the message record and fire your webhooks.
- Addresses on your suppression list (unsubscribed, bounced, complained) are refused.

POST /api/v1/email/messages Messaging host API key

Send using a template

Queues an email built from one of your approved email templates. Tokens in the subject and body are filled from variables and the recipient's contact.

  • If the address belongs to one of your contacts, its name, first_name, phone, country and attributes fill tokens automatically; variables override them.
  • The unsubscribe footer and List-Unsubscribe headers are added automatically.
  • Send an Idempotency-Key header (or clientRef): a repeat returns the first messageId without sending again.

Request body

FieldTypeRequiredDescription
to string required

Recipient email address.

from string | object optional

A full address ("Brand <hello@yourdomain.com>") or { identityId, address?, name? }. Leave out to use your default sender. The address must be one the sender identity allows.

from.identityId string optional

A sender identity _id from List sender identities.

from.address string optional

From address. Default: the identity's default From.

from.name string optional

Display name. Default: the identity's display name.

replyTo string optional

Reply-to address. Default: the identity's reply-to.

toName string optional

Recipient display name (up to 200 characters).

clientRef string optional

Your own reference. Also makes retries safe, like the Idempotency-Key header.

templateId string one of

An approved email template. Send this, or subject with html / text.

locale string optional

Language version of the template, e.g. ar. Unknown versions fall back to the template's default.

variables object optional

Token values for the subject and body. Keys are letters, digits and _; values are text, numbers or true/false.

{
  "from": {
    "identityId": "665f1c2a9b4e2f0012a34bcd"
  },
  "to": "omar@example.com",
  "templateId": "665f1c2a9b4e2f0012a34bce",
  "locale": "en",
  "variables": {
    "first_name": "Omar",
    "order_id": "SA-10233"
  }
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/email/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":{"identityId":"665f1c2a9b4e2f0012a34bcd"},"to":"omar@example.com","templateId":"665f1c2a9b4e2f0012a34bce","locale":"en","variables":{"first_name":"Omar","order_id":"SA-10233"}}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/email/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": {
        "identityId": "665f1c2a9b4e2f0012a34bcd"
    },
    "to": "omar@example.com",
    "templateId": "665f1c2a9b4e2f0012a34bce",
    "locale": "en",
    "variables": {
        "first_name": "Omar",
        "order_id": "SA-10233"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued for delivery

{
  "messageId": "em_lxky9z_a1b2c3d4",
  "status": "queued"
}
200

Duplicate idempotency key

{
  "messageId": "em_lxky9z_a1b2c3d4",
  "status": "sent",
  "deduplicated": true
}
400

Missing or invalid fields

{
  "error": "`to` must be a valid email address"
}
401

Missing or invalid API key

{
  "error": "Missing API key (Authorization: Bearer <key> or X-API-Key header)"
}
403

Email is not enabled on your account

{
  "error": "Email is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
403

From address not allowed for that sender

{
  "error": "From address news@other.com is not allowed for this sender",
  "code": "from_not_allowed"
}
404

No matching sender identity

{
  "error": "No sender identity matches `from`. Set one up under Channels → Email → Sender setup.",
  "code": "sender_not_found"
}
409

Sender domain not verified

{
  "error": "Sender domain mail.example.com is not verified",
  "code": "sender_not_verified"
}
422

Suppressed recipient or unapproved template

{
  "error": "Recipient is on the email suppression list",
  "code": "suppressed",
  "reason": "bounce"
}
429

TPS cap reached (per channel)

{
  "error": "TPS cap of 50 msg/s reached",
  "code": "throughput_exceeded"
}
503

Email not configured on this deployment

{
  "error": "Email sending is not configured on this deployment",
  "code": "email_not_configured"
}
POST /api/v1/email/messages Messaging host API key

Send raw HTML

Queues an email from HTML you supply, instead of a template.

  • Requires a verified own domain — not allowed from a shared Relay address.
  • The HTML is sanitised: scripts, iframes and forms are removed.
  • An unsubscribe footer is added when the HTML has no {unsubscribe_url}.
  • html and text together must stay under 9 MB.
  • Sent as transactional unless marketing is true.

Request body

FieldTypeRequiredDescription
to string required

Recipient email address.

from string | object optional

A full address ("Brand <hello@yourdomain.com>") or { identityId, address?, name? }. Leave out to use your default sender. The address must be one the sender identity allows.

from.identityId string optional

A sender identity _id from List sender identities.

from.address string optional

From address. Default: the identity's default From.

from.name string optional

Display name. Default: the identity's display name.

replyTo string optional

Reply-to address. Default: the identity's reply-to.

toName string optional

Recipient display name (up to 200 characters).

clientRef string optional

Your own reference. Also makes retries safe, like the Idempotency-Key header.

subject string one of

Subject line (up to 300 characters). Send with html and/or text, instead of templateId.

html string conditional

HTML body. At least one of html / text is required with subject.

text string conditional

Plain-text body.

marketing boolean optional

true treats a raw send as promotional: quiet hours, frequency caps and the CRM unsubscribe then apply. Default: transactional.

{
  "from": "Brand <hello@mail.yourcompany.com>",
  "to": "omar@example.com",
  "subject": "Your order SA-10233 has shipped",
  "html": "<p>Hi Omar, your order is on its way.</p><p><a href=\"{unsubscribe_url}\">Unsubscribe</a></p>",
  "text": "Hi Omar, your order is on its way."
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/email/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"Brand <hello@mail.yourcompany.com>","to":"omar@example.com","subject":"Your order SA-10233 has shipped","html":"<p>Hi Omar, your order is on its way.</p><p><a href=\"{unsubscribe_url}\">Unsubscribe</a></p>","text":"Hi Omar, your order is on its way."}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/email/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "Brand <hello@mail.yourcompany.com>",
    "to": "omar@example.com",
    "subject": "Your order SA-10233 has shipped",
    "html": "<p>Hi Omar, your order is on its way.</p><p><a href=\"{unsubscribe_url}\">Unsubscribe</a></p>",
    "text": "Hi Omar, your order is on its way."
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued for delivery

{
  "messageId": "em_lxky9z_a1b2c3d4",
  "status": "queued"
}
403

Raw HTML needs your own domain

{
  "error": "Raw HTML sends require a verified own domain; use a template with a Relay address",
  "code": "raw_requires_domain"
}
413

Body too large

{
  "error": "Email body exceeds 9 MB"
}
POST /api/v1/email/messages Messaging host API key

Send with attachments

Add attachments to either kind of send (template or raw HTML) to deliver files with the email — invoices, tickets, statements.

  • Requires a verified own domain.
  • Up to 10 files, 10 MB in total before encoding.
  • Allowed types, by extension: pdf, png, jpg/jpeg, gif, webp, docx, xlsx, pptx, odt, ods, csv, txt, ics, json, xml. Archives, macro-enabled or legacy Office files and programs are refused.
  • Each file's content must match its extension, so a renamed program is refused.
  • Files are kept only until the email is sent. Get message status lists their name, type and size.

Request body

FieldTypeRequiredDescription
to string required

Recipient email address.

from string | object optional

A full address ("Brand <hello@yourdomain.com>") or { identityId, address?, name? }. Leave out to use your default sender. The address must be one the sender identity allows.

from.identityId string optional

A sender identity _id from List sender identities.

from.address string optional

From address. Default: the identity's default From.

from.name string optional

Display name. Default: the identity's display name.

replyTo string optional

Reply-to address. Default: the identity's reply-to.

toName string optional

Recipient display name (up to 200 characters).

clientRef string optional

Your own reference. Also makes retries safe, like the Idempotency-Key header.

templateId string one of

An approved email template. Send this, or subject with html / text.

locale string optional

Language version of the template, e.g. ar. Unknown versions fall back to the template's default.

variables object optional

Token values for the subject and body. Keys are letters, digits and _; values are text, numbers or true/false.

attachments object[] optional

Files to attach (up to 10).

attachments[].filename string required

File name with an allowed extension, e.g. INV-1001.pdf (longer than 150 characters is shortened).

attachments[].content string required

The file, base64-encoded.

{
  "from": "Billing <billing@mail.yourcompany.com>",
  "to": "omar@example.com",
  "templateId": "665f1c2a9b4e2f0012a34bce",
  "variables": {
    "first_name": "Omar",
    "invoice_no": "INV-1001"
  },
  "attachments": [
    {
      "filename": "INV-1001.pdf",
      "content": "JVBERi0xLjcKMSAwIG9iago8PD4+CmVuZG9iago="
    }
  ]
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/email/messages" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"from":"Billing <billing@mail.yourcompany.com>","to":"omar@example.com","templateId":"665f1c2a9b4e2f0012a34bce","variables":{"first_name":"Omar","invoice_no":"INV-1001"},"attachments":[{"filename":"INV-1001.pdf","content":"JVBERi0xLjcKMSAwIG9iago8PD4+CmVuZG9iago="}]}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/email/messages", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "from": "Billing <billing@mail.yourcompany.com>",
    "to": "omar@example.com",
    "templateId": "665f1c2a9b4e2f0012a34bce",
    "variables": {
        "first_name": "Omar",
        "invoice_no": "INV-1001"
    },
    "attachments": [
        {
            "filename": "INV-1001.pdf",
            "content": "JVBERi0xLjcKMSAwIG9iago8PD4+CmVuZG9iago="
        }
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued for delivery

{
  "messageId": "em_lxky9z_a1b2c3d4",
  "status": "queued"
}
400

File type not allowed, content does not match, or too large

{
  "error": "attachments[0]: the content of \"invoice.pdf\" does not match its .pdf extension",
  "code": "invalid_attachment"
}
403

Attachments need your own domain

{
  "error": "Attachments require a verified own domain",
  "code": "attachments_require_domain"
}
GET /api/v1/email/messages/:messageId Messaging host API key

Get message status

The delivery state of an email you sent, with the bounce reason, open and click counts, and any attached files.

Parameters

NameInTypeDescription
messageId * path string The messageId returned by POST /api/v1/email/messages em_lxky9z_a1b2c3d4

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/email/messages/{messageId}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/email/messages/{messageId}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Current status

{
  "messageId": "em_lxky9z_a1b2c3d4",
  "sesMessageId": "0100018f…",
  "status": "delivered",
  "to": "omar@example.com",
  "from": "hello@mail.yourcompany.com",
  "subject": "Your order SA-10233 has shipped",
  "sentAt": "2026-05-21T10:00:00Z",
  "deliveredAt": "2026-05-21T10:00:03Z",
  "firstOpenedAt": "2026-05-21T10:14:22Z",
  "opens": 2,
  "clicks": 1
}
404

Not found

{
  "error": "Message not found"
}
GET /api/v1/email/identities Messaging host API key

List sender identities

Your sender identities and their default From addresses. Use an _id from here as from.identityId when sending.

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/email/identities" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/email/identities", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Identities

{
  "items": [
    {
      "_id": "665f1c2a9b4e2f0012a34bcd",
      "kind": "domain",
      "displayName": "Your Brand",
      "domain": "mail.yourcompany.com",
      "defaultFrom": "hello@mail.yourcompany.com",
      "verification": {
        "status": "verified"
      },
      "isDefault": true
    }
  ]
}

Voice calls

Phone a contact from your own systems. On the answered call Relay can speak a message, play one of your recordings, run a call flow (a menu such as "press 1 to confirm"), or let a Voice AI agent hold the conversation.

- Calls are billed per minute in your plan's increments; unanswered calls are free.
- Outgoing calls must be enabled for your account by Relay.

POST /api/v1/voice/calls Messaging host API key

Place a voice call

Queues an outgoing call. On the answered call Relay speaks a message, plays one of your recordings, runs a call flow, or hands the call to a Voice AI agent — send exactly one of message, recordId / recording, flowId or agentId.

  • Send an Idempotency-Key header (or clientRef) so a retried request never places a second call.
  • Use Get call status with the returned callId to follow the call.
  • Message text is never stored after the call.

Request body

FieldTypeRequiredDescription
to string required

Number to call, in international format (+9665…).

message object | string one of

Text Relay speaks. A plain string is the same as { "text": "…" }.

message.text string conditional

What to say, up to 1000 characters. Required with message. Add a pause with <break time='3s'/> (up to 30 seconds).

message.language string optional

Language of the text, e.g. en-US, ar-SA.

message.voice string optional

Voice to speak with: Kore, Puck, Charon, Aoede, Fenrir, Leda, Orus or Zephyr. Any other name uses the default voice.

message.repeat integer optional

Say it 1–3 times (default 1).

message.pressToRepeat boolean optional

Offer "press 1 to hear it again" after the last repeat.

recordId string one of

One of your recordings (from Upload a recording or Voice → Recordings), played once.

recording object one of

A recording with options — use instead of recordId.

recording.recordId string conditional

The recording to play. Required with recording.

recording.repeat integer optional

Play it 1–3 times (default 1).

recording.pressToRepeat boolean optional

Offer "press 1 to hear it again" afterwards.

recording.language string optional

Language of the "press 1" prompt, e.g. ar-SA.

flowId string one of

A published call flow with *Outbound calls* turned on.

agentId string one of

An active Voice AI agent.

from string optional

One of your numbers that can place calls. Default: the flow's or agent's number; for a message or a recording, your first calling number.

variables object optional

Flat key/value pairs. Spoken in flow prompts as {name}, or given to the agent as context.

transactional boolean optional

true for calls the person asked for, such as a verification code: placed outside quiet hours and not blocked by the marketing opt-out list.

clientRef string optional

Your own reference (up to 100 characters); also makes retries safe, like Idempotency-Key.

ringTimeoutSec integer optional

How long the phone rings before the call counts as unanswered: 10–60 seconds (default 30).

statusCallbackUrl string optional

An https address that receives the call's final status once, as a GET.

  • Parameters: callid, status (COMPLETED, NO_ANSWER, BUSY, REJECTED or FAILED), status_timestamp, call_initiated_at, call_ringing_at, call_answered_at, call_finished_at (ISO 8601, UTC).
  • Times the call never reached are left out.
  • Retried within minutes if your server does not answer 2xx.
  • statusCallbackEndpoint is accepted as the same field.
dtmfCallbackUrl string optional

With message or a recording: listen for a key press while it plays, e.g. "press 1 to confirm".

  • The first key is sent to this https address as a GET with callid and dtmf (the key) added to it.
  • Then the call ends: a message speaks the rest of its text first, a recording stops.
  • A message listens through each <break>, or for 5 seconds at the end.
  • A recording listens while it plays and for 5 seconds after.

Speak a message

{
  "to": "+966500000000",
  "message": {
    "text": "Your verification code is 4, 8, 1, 5, 9, 2.",
    "language": "en-US",
    "repeat": 2
  },
  "transactional": true
}

Ask for a key press ("press 1 to confirm")

{
  "to": "+966500000000",
  "message": {
    "text": "To confirm your order, press 1. <break time='6s'/> Thank you.",
    "language": "en-US"
  },
  "dtmfCallbackUrl": "https://api.example.com/voice/dtmf",
  "ringTimeoutSec": 40,
  "transactional": true
}

Play a recording

{
  "to": "+966500000000",
  "recordId": "3f8a2c1e-9b7d-4e6f-a5c4-2d1b0e9f8a7c.wav"
}

Play a recording 2 times, then offer "press 1"

{
  "to": "+966500000000",
  "recording": {
    "recordId": "3f8a2c1e-9b7d-4e6f-a5c4-2d1b0e9f8a7c.wav",
    "repeat": 2,
    "pressToRepeat": true,
    "language": "ar-SA"
  }
}

Run a call flow

{
  "to": "+966500000000",
  "flowId": "66f1c0ffee0000000000f10e",
  "variables": {
    "appointment": "Tuesday 4 pm"
  }
}

Connect a Voice AI agent

{
  "to": "+966500000000",
  "agentId": "66f1c0ffee0000000000abcd",
  "variables": {
    "firstName": "Sara"
  }
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/voice/calls" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"to":"+966500000000","message":{"text":"Your verification code is 4, 8, 1, 5, 9, 2.","language":"en-US","repeat":2},"transactional":true}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/voice/calls", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "to": "+966500000000",
    "message": {
        "text": "Your verification code is 4, 8, 1, 5, 9, 2.",
        "language": "en-US",
        "repeat": 2
    },
    "transactional": true
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued

{
  "callId": "66f1c0ffee0000000000beef",
  "status": "queued",
  "from": "+966110000000"
}
200

Repeat of an earlier request (same Idempotency-Key)

{
  "callId": "66f1c0ffee0000000000beef",
  "status": "queued",
  "from": "+966110000000",
  "deduplicated": true
}
400

Invalid request

{
  "error": "Provide exactly one of `message`, `recordId`, `flowId` or `agentId`",
  "code": "invalid_request"
}
404

The recordId is not one of your recordings

{
  "error": "Recording not found — upload it first (POST /api/v1/voice/file) and use the recordId it returns",
  "code": "recording_not_found"
}
401

Missing or invalid API key

{
  "error": "Missing API key"
}
403

Voice is not enabled on your account

{
  "error": "Voice is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
402

Balance too low for a call

{
  "error": "Your balance does not cover a call — top up your wallet",
  "code": "insufficient_funds"
}
403

Outgoing calls not enabled, destination not allowed, or from not yours

{
  "error": "Outbound calling is not enabled for your account — contact support to enable it",
  "code": "outbound_not_enabled"
}
409

Flow not published / not outbound, agent inactive, quiet hours, opted-out contact, or no calling number

{
  "error": "This call flow is not enabled for outbound calls — turn on \"Outbound calls\" in the flow",
  "code": "flow_not_outbound"
}
429

Too many calls per second, or the workspace's monthly call limit

{
  "error": "Too many calls started in the last second — try again shortly",
  "code": "rate_limited"
}
GET /api/v1/voice/calls/:id Messaging host API key

Get call status

The state of a call you placed, with the end reason, talk time, billed seconds and charge.

  • Status moves queued → ringing → answered → completed, or ends as no_answer, busy, rejected or failed.
  • Agent calls include the transcript; call-flow calls include the menu choices.
  • ringingAt is when the call started ringing. A call placed with statusCallbackUrl includes statusCallback: state (pending, sent or failed), the HTTP status your address answered with, and sentAt.
  • A message or recording with dtmfCallbackUrl includes dtmf: the key pressed (digits), the HTTP status your address answered with (callbackStatus, 0 = no answer) and when (at).

Parameters

NameInTypeDescription
id * path string The callId returned by POST /api/v1/voice/calls 66f1c0ffee0000000000beef

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/voice/calls/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/voice/calls/{id}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Call

{
  "_id": "66f1c0ffee0000000000beef",
  "direction": "outbound",
  "outboundKind": "message",
  "from": "+966110000000",
  "to": "+966500000000",
  "status": "completed",
  "endReason": "flow_end",
  "durationSec": 14,
  "billableSec": 60,
  "chargeMinor": 30,
  "currency": "SAR"
}
404

Not found

{
  "error": "Call not found"
}
POST /api/v1/voice/legacy-calls Messaging host API key

Place a call (previous platform format)

For systems moving from the previous platform: send the same call body you sent there, unchanged. Only the address and the API key change. Relay places it as a spoken-message call, with the same checks and answer as Place a voice call.

  • from may be a sender name: the call shows your first calling number. A number of yours is used as the caller ID.
  • A key pressed while the text plays is sent to dtmfCallbackEndpoint as a GET with callid and dtmf added to the address.
  • <break time='6s'/> in sayText is a pause; the call listens for a key through it.
  • callerVoice is matched to the closest Relay voice. neuralLang is accepted and ignored.
  • Follow the call with Get call status.

Request body

FieldTypeRequiredDescription
to string required

Number to call, in international format (+9665…).

sayText string required

What to say, up to 1000 characters, with optional <break time='6s'/> pauses.

lang string optional

Language of the text, e.g. ar-AE.

callerVoice string optional

Voice name from the previous platform (e.g. Hala); matched to a Relay voice.

repeatition integer optional

Say it 1–3 times (default 1; higher values count as 3).

ringingDuration integer optional

Seconds the phone rings before the call counts as unanswered (10–60, default 30).

enabledtmf boolean optional

Listen for a key press. Requires dtmfCallbackEndpoint.

dtmfCallbackEndpoint string conditional

https address that receives the key pressed. Required when enabledtmf is true.

from string optional

Sender name or one of your calling numbers.

statusCallbackEndpoint string optional

https address that receives the call's final status once, as a GET — the same request as statusCallbackUrl on Place a voice call.

neuralLang boolean optional

Accepted for compatibility; ignored.

{
  "callerVoice": "Hala",
  "dtmfCallbackEndpoint": "https://api.example.com/voice/dtmf",
  "enabledtmf": true,
  "from": "MyBrand",
  "lang": "ar-AE",
  "neuralLang": true,
  "repeatition": 1,
  "ringingDuration": 30,
  "sayText": "لتأكيد الطلب اضغط رقم 1 <break time='6s'/> شكرا لك",
  "to": "+966500000000"
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/voice/legacy-calls" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"callerVoice":"Hala","dtmfCallbackEndpoint":"https://api.example.com/voice/dtmf","enabledtmf":true,"from":"MyBrand","lang":"ar-AE","neuralLang":true,"repeatition":1,"ringingDuration":30,"sayText":"لتأكيد الطلب اضغط رقم 1 <break time='6s'/> شكرا لك","to":"+966500000000"}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/voice/legacy-calls", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "callerVoice": "Hala",
    "dtmfCallbackEndpoint": "https://api.example.com/voice/dtmf",
    "enabledtmf": true,
    "from": "MyBrand",
    "lang": "ar-AE",
    "neuralLang": true,
    "repeatition": 1,
    "ringingDuration": 30,
    "sayText": "لتأكيد الطلب اضغط رقم 1 <break time='6s'/> شكرا لك",
    "to": "+966500000000"
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued

{
  "callId": "66f1c0ffee0000000000beef",
  "status": "queued",
  "from": "+966110000000"
}
400

Invalid request

{
  "error": "`dtmfCallbackEndpoint` is required when `enabledtmf` is true",
  "code": "invalid_request"
}
401

Missing or invalid API key

{
  "error": "Missing API key"
}
402

Balance too low for a call

{
  "error": "Your balance does not cover a call — top up your wallet",
  "code": "insufficient_funds"
}
403

Outgoing calls not enabled, or destination not allowed

{
  "error": "Outbound calling is not enabled for your account — contact support to enable it",
  "code": "outbound_not_enabled"
}
409

No calling number on your account

{
  "error": "No phone number on your account can place outgoing calls",
  "code": "number_unavailable"
}
429

Too many calls per second, or the workspace's monthly call limit

{
  "error": "Too many calls started in the last second — try again shortly",
  "code": "rate_limited"
}
POST /api/v1/voice/legacy-calls/executionengine Messaging host API key

Place a call with an execution plan (previous platform format)

For systems moving from the previous platform's Advanced Call: send the same body and XML plan you sent there, unchanged. Only the address and the API key change. The same checks apply as Place a voice call.

  • Verbs: <say> (text to speech, with reps, voice, lang), <play recordId=…> (one of your recordings), <gather> (speaks its text and collects keys) and <close/>, run in order. Others (async-gather, record, dial, redirect, play soundurl) return 400.
  • Key presses: always on <gather>; on <say> / <play> with enableDTMF='true'. Waits waitduration s for the first key (default 4), innertimeout between keys (3), totaltimeout in all (180).
  • One key with exitOnFirstDTMF='true', else up to maxchar, ending on stopchar.
  • Repeat: on <gather> with enablerep='true', pressing repchar replays the prompt, up to repcount times.
  • dtmfCallbackURL (url on <gather>; may be empty): receives a GET with dtmf and callid when the verb stops listening. dtmf is empty when nothing was pressed.
  • Next plan: if your reply (within 15 s, up to 32 KB) is a plan, it replaces the rest of the call. Any other reply: the plan goes on.
  • recordId: a Relay recordId, or the alias you gave the recording when uploading it (use your previous file names as aliases).
  • Body keys are read in any case (To, ExecutionPlan). The answer is 200 { callId }. Follow the call with Get call status.

Request body

FieldTypeRequiredDescription
to string required

Number to call, in international format, with or without +.

executionPlan string required

The XML plan: <begin>…</begin> with the verbs above, up to 32 KB and 50 verbs.

statusCallbackEndpoint string optional

https address that receives the call's final status once, as a GET — the same request as statusCallbackUrl on Place a voice call.

ringingDuration integer optional

Seconds the phone rings before the call counts as unanswered (10–60, default 30).

callerVoice string optional

Default voice for <say>: a previous-platform name (e.g. Hala) is matched to a Relay voice.

isCampaign boolean optional

true for marketing calls: quiet hours and the opt-out list apply. Default: a transactional call.

from string optional

One of your calling numbers. A sender name is ignored and your first calling number is used.

{
  "to": "966500000000",
  "executionPlan": "<begin><play recordId='IVR_Welcome_AR-1792410256556.wav' enableDTMF='true' exitOnFirstDTMF='true' waitduration='10' totaltimeout='20' dtmfCallbackURL='https://api.example.com/voice/dtmf'></play></begin>",
  "statusCallbackEndpoint": "https://api.example.com/voice/status"
}

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/voice/legacy-calls/executionengine" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"to":"966500000000","executionPlan":"<begin><play recordId='IVR_Welcome_AR-1792410256556.wav' enableDTMF='true' exitOnFirstDTMF='true' waitduration='10' totaltimeout='20' dtmfCallbackURL='https://api.example.com/voice/dtmf'></play></begin>","statusCallbackEndpoint":"https://api.example.com/voice/status"}'

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/voice/legacy-calls/executionengine", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "to": "966500000000",
    "executionPlan": "<begin><play recordId='IVR_Welcome_AR-1792410256556.wav' enableDTMF='true' exitOnFirstDTMF='true' waitduration='10' totaltimeout='20' dtmfCallbackURL='https://api.example.com/voice/dtmf'></play></begin>",
    "statusCallbackEndpoint": "https://api.example.com/voice/status"
}),
});
const data = await res.json();
console.log(data);

Responses

200

Queued

{
  "callId": "66f1c0ffee0000000000beef"
}
400

Invalid request or plan

{
  "error": "invalid recordId in play verb",
  "code": "invalid_request",
  "message": "invalid recordId in play verb"
}
401

Missing or invalid API key

{
  "error": "Missing API key",
  "message": "Missing API key"
}
402

Balance too low for a call

{
  "error": "Your balance does not cover a call — top up your wallet",
  "code": "insufficient_funds",
  "message": "Your balance does not cover a call — top up your wallet"
}
403

Outgoing calls not enabled, or destination not allowed

{
  "error": "Outbound calling is not enabled for your account — contact support to enable it",
  "code": "outbound_not_enabled",
  "message": "Outbound calling is not enabled for your account — contact support to enable it"
}
404

A recordId in the plan is not one of your recordings

{
  "error": "Recording \"IVR_Welcome_AR-1792410256556.wav\" not found — upload it first (POST /api/v1/voice/file?alias=<its name>)",
  "code": "recording_not_found",
  "message": "…"
}
429

Too many calls per second, or the workspace's monthly call limit

{
  "error": "Too many calls started in the last second — try again shortly",
  "code": "rate_limited",
  "message": "Too many calls started in the last second — try again shortly"
}
POST /api/v1/voice/file Messaging host API key

Upload a recording

Adds an audio file to your recordings library and returns its recordId. Pass it as recordId to Place a voice call, or use it as a prompt in your call flows.

  • Format: WAV, uncompressed PCM, 8000 Hz, mono, 16-bit. Convert other audio first: ffmpeg -i input.mp3 -ar 8000 -ac 1 -c:a pcm_s16le output.wav.
  • Size: up to 16,777,216 bytes (about 17 minutes); the upload must finish within 60 seconds.
  • Uploading the same audio again returns the same recordId with duplicate: true.
  • The recording also appears in the portal under Voice → Recordings (play, rename, delete).

Parameters

NameInTypeDescription
name query string Name shown in the portal (up to 80 characters). Default: the file name. Welcome message
alias query string Your own ID for the recording, e.g. the file name your previous platform used. It then works wherever a recordId does, exactly as written (case matters).

- Up to 256 characters; no .., /, \ or control characters.
- Unique in your account: an alias already on another recording returns 409 alias_taken. IVR_Welcome_AR-1792410256556.wav

cURL

curl -X POST "https://ops.relay.deewan.sa/api/v1/voice/file" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/voice/file", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Stored

{
  "reqId": "0b6c1f2e-4a1d-4c55-9a51-1f0e8d2c7b10",
  "recordId": "3f8a2c1e-9b7d-4e6f-a5c4-2d1b0e9f8a7c.wav",
  "bytes": 264044,
  "sampleRate": 8000,
  "channels": 1,
  "bitDepth": 16,
  "durationMs": 16500
}
400

Not an accepted WAV (format, sample rate, channels, bit depth), malformed, empty, or no file part

{
  "reqId": "…",
  "error": "Unsupported sample rate 44100 Hz: use 8000 Hz",
  "code": "unsupported_format"
}
401

Missing or invalid API key

{
  "reqId": "…",
  "error": "Invalid or inactive API key"
}
403

Voice is not enabled on your account, or the workspace is paused

{
  "reqId": "…",
  "error": "Voice is not enabled on your account. Contact your account manager to enable it.",
  "code": "channel_disabled"
}
408

The upload took longer than 60 seconds

{
  "reqId": "…",
  "error": "The upload did not finish within 60 seconds",
  "code": "upload_timeout"
}
409

Your recording library is full (1000 recordings), or alias already names another recording

{
  "reqId": "…",
  "error": "Your recording library is full (1000) — delete recordings you no longer use",
  "code": "library_full"
}
413

File too large

{
  "reqId": "…",
  "error": "The file is too large: the limit is 16777216 bytes",
  "code": "file_too_large"
}
415

Sent as JSON or a form instead of the file

{
  "reqId": "…",
  "error": "Send the WAV file as the request body (Content-Type: audio/wav) or as multipart/form-data",
  "code": "unsupported_media_type"
}
502

The file could not be stored — safe to retry

{
  "reqId": "…",
  "error": "Failed to store the file — try again",
  "code": "storage_failed"
}
GET /api/v1/voice/file/:fileId Messaging host API key

Download a recording

Returns one of your recordings as a WAV file (Content-Type: audio/wav). A recording that belongs to another account, or was deleted, returns 404.

Parameters

NameInTypeDescription
fileId * path string The recordId returned by POST /api/v1/voice/file (also shown in Voice → Recordings), or an alias you gave it 3f8a2c1e-9b7d-4e6f-a5c4-2d1b0e9f8a7c.wav

cURL

curl -X GET "https://ops.relay.deewan.sa/api/v1/voice/file/{fileId}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://ops.relay.deewan.sa/api/v1/voice/file/{fileId}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

The WAV file

{
  "note": "Returns audio/wav — save it with curl -o recording.wav"
}
404

Not found

{
  "error": "file not found"
}
POST /api/mgmt/v1/voice/calls Management host API key

Place a voice call (portal)

The portal's own copy of Place a voice call, with the same body and responses. Requires the admin or editor role.

  • From your own systems, use POST /api/v1/voice/calls with an API key instead.

Request body

FieldTypeRequiredDescription
to string required

Number to call, in international format.

message object | string one of

Text to speak — same as Place a voice call.

recordId string one of

One of your recordings (or recording with options).

flowId string one of

A published call flow with *Outbound calls* on.

agentId string one of

An active Voice AI agent.

from string optional

One of your calling numbers.

variables object optional

Flat key/value pairs for the flow or the agent.

transactional boolean optional

A call the person asked for (ignores quiet hours and the marketing opt-out list).

{
  "agentId": "66f1c0ffee0000000000abcd",
  "to": "+966500000000",
  "variables": {
    "firstName": "Sara",
    "appointment": "Tuesday 4 pm"
  }
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/voice/calls" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"agentId":"66f1c0ffee0000000000abcd","to":"+966500000000","variables":{"firstName":"Sara","appointment":"Tuesday 4 pm"}}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/voice/calls", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "agentId": "66f1c0ffee0000000000abcd",
    "to": "+966500000000",
    "variables": {
        "firstName": "Sara",
        "appointment": "Tuesday 4 pm"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

202

Queued

{
  "callId": "66f1c0ffee0000000000beef",
  "status": "queued"
}
402

Balance too low for a call

{
  "error": "Your balance does not cover a call — top up your wallet",
  "code": "insufficient_funds"
}
403

Destination not enabled

{
  "error": "Calls to this destination are not enabled for your account",
  "code": "destination_not_allowed"
}
409

Quiet hours, opted-out contact, or inactive agent

{
  "error": "Calls are paused for this recipient’s quiet hours",
  "code": "quiet_hours",
  "retryAt": "2026-09-25T06:00:00.000Z"
}
429

Too many calls started per second

{
  "error": "Too many calls started in the last second — try again shortly",
  "code": "rate_limited"
}
GET /api/mgmt/v1/voice/calls Management host API key

List voice calls

Paginated call log, newest first, for inbound and outbound calls handled by your Voice AI agents.

Parameters

NameInTypeDescription
page query integer Page number 1
limit query integer Items per page (max 200) 50
direction query string inbound | outbound outbound
status query string queued | ringing | answered | completed | failed | no_answer | busy | rejected completed
agentId query string Only calls handled by this agent 66f1...
from query string ISO 8601 start date 2026-09-01
to query string ISO 8601 end date 2026-09-30
search query string Digits of the caller or called number 9665

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/voice/calls" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/voice/calls", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Calls

{
  "calls": [
    {
      "_id": "66f1...",
      "direction": "outbound",
      "from": "+966110000000",
      "to": "+966500000000",
      "status": "completed",
      "durationSec": 75,
      "billableSec": 120,
      "chargeMinor": 120,
      "currency": "SAR"
    }
  ],
  "total": 42,
  "page": 1,
  "pages": 1
}
GET /api/mgmt/v1/voice/calls/:id Management host API key

Get a voice call

One call with its full transcript, the tools the agent used, the end reason, the billed duration and charge, and the handover case id when the agent passed the caller to your team.

Parameters

NameInTypeDescription
id * path string Call id 66f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/voice/calls/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/voice/calls/{id}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Call

{
  "_id": "66f1...",
  "status": "completed",
  "endReason": "agent_hangup",
  "durationSec": 75,
  "billableSec": 120,
  "transcript": [
    {
      "role": "agent",
      "text": "Hello Sara, this is Relay Clinic calling about your appointment."
    },
    {
      "role": "caller",
      "text": "Yes, go ahead."
    }
  ],
  "caseId": null
}
404

Not found

{
  "error": "Call not found"
}

Automations

Start an automation from your own systems: one with the API trigger is started with an API key; one with the Inbound webhook trigger by a signed POST to its own URL.

- Both identify the person by phone number; a number not yet in your contacts is added.
- The data you send becomes fields your steps use as {field} — in messages, If/else and Switch conditions.
- In the builder, the trigger panel shows the ready-to-copy call and lets you list required fields: a call missing any of them is refused before anything is created.

POST /api/webhooks/inbound/:slug Management host

Inbound webhook (signed)

The URL of an automation with the Inbound webhook trigger. Create the endpoint in the builder (trigger panel → New endpoint): you choose the slug and where the phone number sits in your JSON, and see the endpoint's secret once (rotate it there).

  • Signing (required): HMAC-SHA256 (or SHA-512, if set on the endpoint) of the exact raw body with the endpoint secret, hex-encoded, in X-Signature-256 (or the endpoint's header). A sha256= prefix is accepted.
  • Sign the bytes you send, not a re-serialised copy. Bash: printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.*= //'. Node.js: crypto.createHmac('sha256', secret).update(body).digest('hex').
  • Who: the phone is read from the endpoint's contact path — $.phone by default; dotted paths and list positions such as $.customer.phone or $.items[0].mobile work. A new number is added to your contacts.
  • Your data: the whole body is available to steps — each top-level key as {key}, a nested value as {parent_child} (up to three levels), a list as {key_count}. A body key never replaces a contact field.
  • Required fields: a body where one is missing, null or blank (a.b for nested keys) gets 400 missing_fields after the signature check, before any contact is created.
  • Waiting runs: if the person has a run of this automation paused on *Wait for event → webhook callback*, the call resumes it (the body is saved on the run) instead of starting a new one. Required fields are not checked then.
  • No idempotency key: each accepted call starts a new run.

Parameters

NameInTypeDescription
slug * path string The endpoint slug chosen in the builder shop-order-paid

Request body

FieldTypeRequiredDescription
phone string conditional

The person's phone number, at the endpoint's contact path ($.phone by default — it may sit elsewhere, e.g. customer.phone).

order_id any optional

An example of your own data: any other key is available to steps as {order_id}.

amount any optional

Another example key: {amount}.

customer object optional

A nested object: its fields become {customer_tier} and so on.

Any JSON object up to 1 MB, sent with Content-Type: application/json and the signature header — the cURL sample below leaves the signature out.

{
  "phone": "+966500000000",
  "order_id": "ORD-1001",
  "amount": 249.5,
  "customer": {
    "tier": "gold"
  }
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/webhooks/inbound/{slug}" \
  -H "Content-Type: application/json" \
  -d '{"phone":"+966500000000","order_id":"ORD-1001","amount":249.5,"customer":{"tier":"gold"}}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/webhooks/inbound/{slug}", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
},
  body: JSON.stringify({
    "phone": "+966500000000",
    "order_id": "ORD-1001",
    "amount": 249.5,
    "customer": {
        "tier": "gold"
    }
}),
});
const data = await res.json();
console.log(data);

Responses

202

Run started

{
  "enrollmentId": "66f1c0ffee0000000000e001"
}
202

A waiting run was resumed

{
  "resumed": true,
  "enrollmentId": "66f1c0ffee0000000000e001"
}
400

Required fields missing

{
  "error": "missing_fields",
  "message": "Missing required fields: order_id, amount",
  "missing": [
    "order_id",
    "amount"
  ]
}
400

Body is not JSON, no phone at the contact path, or an invalid phone number

{
  "error": "Could not resolve contact identifier from path \"$.phone\""
}
401

Signature header missing, or the signature does not match

{
  "error": "Invalid signature"
}
403

Contact limit of your plan reached (new phone), or the workspace is read-only

{
  "error": "Workspace is read-only (subscription past due) — automations are paused"
}
404

Unknown slug, or the endpoint is disabled

{
  "error": "Webhook endpoint not found"
}
409

Automation not active, emergency stop engaged, or a waiting run could not be resumed

{
  "error": "Automation is paused — cannot enroll"
}
429

Concurrent-run limit or per-contact frequency cap reached

{
  "error": "Frequency cap exceeded for this contact"
}

Workspaces

Workspaces split your account's sending. Each has its own monthly limit per channel, an optional spend budget, its members, the assets (senders, numbers, stores) it may use, and the credentials assigned to it.

- Paths keep the original /apps spelling so existing integrations keep working.
- Limit units: SMS in message parts, WhatsApp and email in outbound messages, voice in outgoing calls placed through the voice API.
- The Main Workspace is always uncapped and uses every account asset.

GET /api/mgmt/v1/apps Management host API key

List workspaces

Returns the organisation's workspaces, Main Workspace first.

  • Account admins see every workspace; other users see only the workspaces they belong to.
  • An API key assigned to a workspace sees only that workspace.

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/apps" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Workspaces

[
  {
    "_id": "...",
    "name": "My Workspace",
    "status": "active",
    "monthlyLimits": {
      "sms": 500000,
      "whatsapp": 50000,
      "email": 250000,
      "voice": 5000
    }
  }
]
POST /api/mgmt/v1/apps Management host API key

Create a workspace

Creates a workspace. Requires the account admin role.

  • A new workspace uses only the assets granted to it (see Add an asset to a workspace).
  • A limit or budget of 0 (or omitted) means no limit.

Request body

FieldTypeRequiredDescription
name string required

Workspace name.

description string optional

Free-text description.

monthlyLimits object optional

Monthly cap per channel. Omit a channel or set 0 for no limit; other values are rounded down.

monthlyLimits.sms integer optional

SMS message parts per calendar month.

monthlyLimits.whatsapp integer optional

Outbound WhatsApp messages per calendar month.

monthlyLimits.email integer optional

Outbound emails per calendar month.

monthlyLimits.voice integer optional

Outgoing calls placed through the voice API per calendar month.

monthlyBudgetMinor integer optional

Monthly spend budget in minor units of your wallet currency (e.g. halalas). Sends stop once the month's spend reaches it. 0 = no budget.

alertAt integer[] optional

Budget percentages that trigger a notification. Default [80, 90, 100].

senders string[] optional

SMS sender IDs the workspace may use. Each must be one of the account's sender IDs.

{
  "name": "My Marketing Workspace",
  "monthlyLimits": {
    "sms": 500000,
    "whatsapp": 50000,
    "email": 250000,
    "voice": 5000
  },
  "senders": [
    "BRAND"
  ]
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/apps" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"My Marketing Workspace","monthlyLimits":{"sms":500000,"whatsapp":50000,"email":250000,"voice":5000},"senders":["BRAND"]}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "name": "My Marketing Workspace",
    "monthlyLimits": {
        "sms": 500000,
        "whatsapp": 50000,
        "email": 250000,
        "voice": 5000
    },
    "senders": [
        "BRAND"
    ]
}),
});
const data = await res.json();
console.log(data);

Responses

201

Created

{
  "_id": "...",
  "name": "My Marketing Workspace",
  "status": "active"
}
GET /api/mgmt/v1/apps/:id Management host API key

Get a workspace

Returns one workspace. A workspace you cannot see returns 404.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Project

{
  "_id": "...",
  "name": "My Workspace",
  "status": "active",
  "monthlyLimits": {
    "sms": 500000,
    "whatsapp": 50000,
    "email": 250000,
    "voice": 5000
  }
}
PUT /api/mgmt/v1/apps/:id Management host API key

Update a workspace

Updates the fields you send; omitted fields keep their value. Requires the account admin role.

  • monthlyLimits is replaced as a whole: a channel you leave out becomes 0 (no limit).
  • On the Main Workspace, name, monthlyLimits and monthlyBudgetMinor are ignored — it stays uncapped.
  • status and isDefault cannot be changed here.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

Request body

FieldTypeRequiredDescription
name string optional

New name.

description string optional

Free-text description.

monthlyLimits object optional

Full set of monthly caps; send every channel. 0 = no limit.

monthlyLimits.sms integer optional

SMS message parts per calendar month.

monthlyLimits.whatsapp integer optional

Outbound WhatsApp messages per calendar month.

monthlyLimits.email integer optional

Outbound emails per calendar month.

monthlyLimits.voice integer optional

Outgoing calls placed through the voice API per calendar month.

monthlyBudgetMinor integer optional

Monthly spend budget in minor units of your wallet currency. 0 = no budget.

alertAt integer[] optional

Budget percentages that trigger a notification.

senders string[] optional

SMS sender IDs the workspace may use; each must be one of the account's sender IDs.

{
  "monthlyLimits": {
    "sms": 750000,
    "whatsapp": 50000,
    "email": 0,
    "voice": 0
  }
}

cURL

curl -X PUT "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"monthlyLimits":{"sms":750000,"whatsapp":50000,"email":0,"voice":0}}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "monthlyLimits": {
        "sms": 750000,
        "whatsapp": 50000,
        "email": 0,
        "voice": 0
    }
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated

{
  "_id": "...",
  "monthlyLimits": {
    "sms": 750000,
    "whatsapp": 50000,
    "email": 0,
    "voice": 0
  }
}
PATCH /api/mgmt/v1/apps/:id/status Management host API key

Toggle workspace status

Activates or pauses the workspace. Requires the account admin role.

  • While paused, every send that routes through the workspace is rejected — SMS, WhatsApp and email alike.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

Request body

FieldTypeRequiredDescription
status string required

active or paused.

{
  "status": "paused"
}

cURL

curl -X PATCH "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/status" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"status":"paused"}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/status", {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "status": "paused"
}),
});
const data = await res.json();
console.log(data);

Responses

200

Updated

{
  "_id": "...",
  "status": "paused"
}
GET /api/mgmt/v1/apps/:id/stats Management host API key

Workspace SMS delivery stats

Daily SMS delivery counts for the workspace (sent / delivered / failed / blocked / parts), oldest first.

  • For usage against the monthly limits on every channel, use GET /api/apps/:id/usage.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...
from query string First day, YYYY-MM-DD 2025-03-01
to query string Last day, YYYY-MM-DD 2025-03-31

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/stats" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/stats", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Stats

[
  {
    "date": "2025-03-01",
    "sent": 420,
    "delivered": 400
  }
]
GET /api/mgmt/v1/apps/:id/usage Management host API key

Workspace monthly usage vs limits

This calendar month's usage per channel, read from the same counters the limits are enforced against, plus the month's spend against the budget.

  • Units: SMS in message parts, WhatsApp and email in messages, voice in calls.
  • A limit of 0 means that channel is uncapped.
  • metered: false means usage tracking is unavailable on this deployment, so limits are not being enforced.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/usage" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/usage", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Usage

{
  "month": "2026-09",
  "metered": true,
  "channels": [
    {
      "channel": "sms",
      "unit": "parts",
      "limit": 500000,
      "used": 128430
    },
    {
      "channel": "whatsapp",
      "unit": "messages",
      "limit": 50000,
      "used": 9120
    },
    {
      "channel": "email",
      "unit": "messages",
      "limit": 0,
      "used": 41207
    }
  ]
}
GET /api/mgmt/v1/apps/:id/members Management host API key

List workspace members

People who can switch to this workspace, with their role in it, plus candidates: team members who could be added. Requires the account admin role.

  • Account admins are listed as admins of every workspace (via: "account_admin").
  • On the Main Workspace, team members who belong to no workspace appear with via: "implicit_default".
  • On the Management API, only an account-wide key may call this; a key assigned to a workspace is refused (403).

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/members" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/members", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Members

{
  "members": [
    {
      "userId": "64f2...",
      "name": "Sara",
      "email": "sara@example.com",
      "role": "editor",
      "via": "member"
    }
  ],
  "candidates": []
}
PUT /api/mgmt/v1/apps/:id/members/:userId Management host API key

Add a member / change their role

Adds a team member to the workspace, or changes their role in it. Requires the account admin role.

  • A member who so far worked only in the Main Workspace keeps access to it.
  • Account admins cannot be added (400) — they already admin every workspace.
  • Only an account-wide API key may call this (403 for a key assigned to a workspace).

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...
userId * path string Team member id 64f2...

Request body

FieldTypeRequiredDescription
role string required

Role in this workspace: admin, editor, viewer or agent.

{
  "role": "editor"
}

cURL

curl -X PUT "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/members/{userId}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"role":"editor"}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/members/{userId}", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "role": "editor"
}),
});
const data = await res.json();
console.log(data);

Responses

200

Saved

{
  "ok": true
}
DELETE /api/mgmt/v1/apps/:id/members/:userId Management host API key

Remove a member

Removes the person from this workspace. Requires the account admin role.

  • Refused (409) when it is their only workspace — add them elsewhere first, or suspend them.
  • Only an account-wide API key may call this (403 for a key assigned to a workspace).

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...
userId * path string Team member id 64f2...

cURL

curl -X DELETE "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/members/{userId}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/members/{userId}", {
  method: "DELETE",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Removed

{
  "ok": true
}
GET /api/mgmt/v1/apps/:id/assets Management host API key

List workspace assets

Every asset on the account, by kind, marked granted for this workspace, with how many workspaces use it (projects). Requires the account admin role.

  • Kinds: sms_sender, whatsapp_number, voice_number, email_identity, store.
  • The Main Workspace uses every asset.
  • usesAllAssets: true marks a workspace created before assets existed that has not been restricted yet.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/assets" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/assets", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Assets

{
  "isDefault": false,
  "usesAllAssets": false,
  "assets": {
    "sms_sender": [
      {
        "ref": "ACME",
        "label": "ACME",
        "sub": "",
        "granted": true,
        "projects": 2
      }
    ]
  }
}
POST /api/mgmt/v1/apps/:id/assets Management host API key

Add an asset to a workspace

Lets the workspace send from one of the account's assets. Requires the account admin role.

  • The asset stays on the account and can serve several workspaces.
  • Not allowed on the Main Workspace (400) — it already uses every asset.
  • An asset that is not on the account returns 404.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...

Request body

FieldTypeRequiredDescription
kind string required

sms_sender, whatsapp_number, voice_number, email_identity or store.

ref string required

The asset's ref from List workspace assets: the sender ID, WhatsApp phone-number id, voice number id, email sender id or store id.

{
  "kind": "sms_sender",
  "ref": "ACME"
}

cURL

curl -X POST "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/assets" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"kind":"sms_sender","ref":"ACME"}'

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/assets", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
  body: JSON.stringify({
    "kind": "sms_sender",
    "ref": "ACME"
}),
});
const data = await res.json();
console.log(data);

Responses

201

Granted

{
  "ok": true
}
DELETE /api/mgmt/v1/apps/:id/assets/:kind/:ref Management host API key

Remove an asset from a workspace

The workspace stops sending from the asset; the asset itself stays on the account. Requires the account admin role.

Parameters

NameInTypeDescription
id * path string Workspace ObjectId 64f1...
kind * path string Asset kind sms_sender
ref * path string Asset ref (URL-encoded) ACME

cURL

curl -X DELETE "https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/assets/{kind}/{ref}" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/apps/{id}/assets/{kind}/{ref}", {
  method: "DELETE",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Revoked

{
  "ok": true
}

Billing

Read your subscription, plan, prepaid wallet balance, available plans and invoice history.

GET /api/mgmt/v1/billing/subscription Management host API key

Get subscription

Returns your subscription: plan, status, billing cycle and next billing date.

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/billing/subscription" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/billing/subscription", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Subscription

{
  "plan": "pro",
  "status": "active",
  "credits": {
    "total": 5000,
    "used": 1200,
    "resetDate": "2025-04-01"
  },
  "monthlyPrice": 49
}
GET /api/mgmt/v1/billing/package Management host API key

Plan, wallet & usage details

Returns your plan and its included quotas, the prepaid wallet balance, and this month's usage.

  • monthlyUsed counts SMS messages sent this calendar month (UTC); partsUsed counts their parts.

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/billing/package" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/billing/package", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Plan & wallet info

{
  "currency": "SAR",
  "monthlyUsed": 8400,
  "partsUsed": 9100,
  "plan": {
    "name": "Growth",
    "isFree": false,
    "includedContacts": 30000,
    "includedSeats": 8,
    "includedAiConversations": 1500,
    "includedWaNumbers": 3
  },
  "wallet": {
    "balance": 420.5,
    "formatted": "ر.س420.50"
  },
  "smsPriceMinor": 14,
  "monthStart": "2026-06-01T00:00:00Z"
}
GET /api/mgmt/v1/billing/plans Management host API key

Available plans

Returns the public plans you can subscribe to yourself, in display order.

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/billing/plans" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/billing/plans", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Plans

[
  {
    "id": "...",
    "key": "starter",
    "name": "Starter",
    "isFree": false,
    "price": 19,
    "priceFormatted": "$19.00",
    "currency": "USD",
    "includedContacts": 5000,
    "includedSeats": 3,
    "includedAiConversations": 500,
    "includedWaNumbers": 1,
    "smsFreeCap": 0,
    "featureFlags": {}
  }
]
GET /api/mgmt/v1/billing/invoices Management host API key

List invoices

Invoice history, newest first.

Parameters

NameInTypeDescription
limit query integer Max results (default 20, max 100) 20

cURL

curl -X GET "https://portal.relay.deewan.sa/api/mgmt/v1/billing/invoices" \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json"

JavaScript

const res = await fetch("https://portal.relay.deewan.sa/api/mgmt/v1/billing/invoices", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <api_key>"
},
});
const data = await res.json();
console.log(data);

Responses

200

Invoices

[
  {
    "invoiceNumber": "INV-123",
    "amount": 49,
    "currency": "USD",
    "status": "paid",
    "paidAt": "2025-03-01T00:00:00Z"
  }
]