Skip to content
CodeOnAir
Docs menu

Send push notifications from your server

The push REST API: send or schedule a notification to users, tags or platforms with POST /v1/push/messages, then read its status and results.

Order updates, chat messages and reminders come from your backend. Send them with one request to POST /v1/push/messages — the same notifications the dashboard sends, marked API in the list.

Authentication#

Use your app's secret API key from Settings → App credentials (sk_live_…) — see API keys. Keep it on your servers, never in the app.

Header
Authorization: Bearer sk_live_…

Send a notification#

Request
curl -X POST https://app.codeonair.com/v1/push/messages \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Your order has shipped 📦",
    "body": "Arriving Thursday. Track it in the app.",
    "url": "/orders/1042",
    "data": { "order_id": "1042" },
    "audience": { "user_ids": ["user_1024"] }
  }'
Response · 201 Created
{
  "id": "push_…",
  "source": "api",
  "name": null,
  "title": "Your order has shipped 📦",
  "body": "Arriving Thursday. Track it in the app.",
  "image_url": null,
  "url": "/orders/1042",
  "data": { "order_id": "1042" },
  "options": {},
  "audience": { "user_ids": ["user_1024"] },
  "status": "scheduled",
  "scheduled_at": "2026-10-25T09:30:00.000Z",
  "stats": { "targeted": 0, "sent": 0, "failed": 0, "opened": 0, "open_rate": 0 },
  "errors": {},
  "error": null,
  "created_at": "2026-10-25T09:30:00.000Z",
  "started_at": null,
  "completed_at": null
}

Sending happens in the background, so the response comes straight back. A notification sent “now” is created as scheduled for the current time, moves to sending within seconds and ends as sent (or failed if nothing could be delivered). Read it again with GET /v1/push/messages/:id to see stats and errors.

Request fields#

FieldMeaning
titleRequired. Up to 150 characters.
bodyUp to 1,000 characters.
image_urlAn https:// image URL (under 1 MB).
urlOpened on tap: https://…, your scheme (myapp://…) or a path starting with /. Empty opens the app.
dataUp to 20 string values for your app; keys can't start with coa_, google. or gcm.. Under 3 KB.
optionssound (true/false), badge (0–9999), android_channel, ttl_seconds (0–2,419,200), collapse_key.
audienceWho gets it — see below. Empty or missing: everyone who allowed notifications.
send"now" (default), "schedule" (with scheduled_at) or "draft".
scheduled_atWith send: "schedule" — an ISO 8601 date and time, in the future and at most 90 days ahead.
nameOptional internal name shown in the dashboard.

Audience

FieldSelects
platforms["ios"], ["android"] or both.
user_idsDevices of these users (the user ID your app sets). Up to 10,000.
tagsDevices with these tags (up to 50); tags_match is "any" (default) or "all".
device_idsSpecific devices (dev_…), up to 100 — e.g. from the Devices page.

Filters combine: a device must match all the ones you give.

Schedule a reminder for VIPs on Android
{
  "title": "Your cart is waiting",
  "body": "Checkout in one tap — your items are saved.",
  "audience": { "platforms": ["android"], "tags": ["vip"] },
  "send": "schedule",
  "scheduled_at": "2026-11-01T10:00:00+05:30"
}

Endpoints#

MethodPathWhat it does
POST/v1/push/messagesSend, schedule or save a draft
GET/v1/push/messages?status=&source=&before=The latest 50, newest first; before= an ISO date for older ones
GET/v1/push/messages/:idOne notification with its stats and errors
PATCH/v1/push/messages/:idChange a draft or scheduled one (send only the fields to change)
POST/v1/push/messages/:id/cancelCancel a draft, scheduled or sending notification
DELETE/v1/push/messages/:idDelete a draft or cancelled one (204)
POST/v1/push/audience{ audience } → how many devices it reaches now

Errors#

Errors use the same shape as the rest of the API: { "error": { "code": "…", "message": "…" } }.

StatusCodeWhen
400invalid_title, invalid_url, invalid_data, invalid_audience, invalid_schedule…A field is invalid — the message says which and why.
401unauthorizedMissing or wrong API key — or only an App ID was sent.
403forbiddenA publishable key was used; these endpoints need the secret key.
404not_foundNo notification with that id in this app.
409not_editable, not_cancellable, not_deletableIt has already been sent (or isn't a draft / cancelled).
429rate_limitedMore than 600 requests a minute with one key.
Note
Running out of your plan's monthly sends doesn't fail the request: the notification stops sending and its error says “Your plan's monthly push limit was reached.”
Stuck? Write to support@codeonair.com with your App ID and what you tried — we reply within a working day.