POST
/
notifications?c=sms
curl --request POST \
  --url 'https://api.onesignal.com/notifications?c=sms' \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "app_id": "YOUR_APP_ID",
  "contents": {
    "en": "<string>"
  },
  "include_aliases": {
    "external_id": [
      "<string>"
    ],
    "onesignal_id": [
      "<string>"
    ]
  },
  "target_channel": "sms",
  "include_subscription_ids": [
    "<string>"
  ],
  "include_phone_numbers": [
    "<string>"
  ],
  "included_segments": [
    "<string>"
  ],
  "excluded_segments": [
    "<string>"
  ],
  "filters": [
    {
      "field": "first_session",
      "key": "<string>",
      "relation": ">",
      "value": "1"
    }
  ],
  "sms_from": "<string>",
  "sms_media_urls": [
    "<string>"
  ],
  "name": "<string>",
  "template_id": "<string>",
  "custom_data": {},
  "send_after": "<string>",
  "delayed_option": "<string>",
  "delivery_time_of_day": "<string>",
  "idempotency_key": "<string>"
}'
{
  "id": "<string>",
  "external_id": "<string>",
  "errors": {
    "invalid_phone_numbers": [
      "<string>"
    ],
    "invalid_aliases": {
      "external_id": [
        "[\"user_id_1\", \"user_id_1\", \"user_id_2\"]"
      ],
      "onesignal_id": [
        "[\"1589641e-bed1-4325-bce4-d2234e578884\", \"1589641e-bed1-4325-bce4-d2234e578884\", \"1589641e-bed1-4325-bce4-d2234e578884\"]"
      ]
    },
    "invalid_player_ids": [
      "<string>"
    ]
  }
}

Overview

The Create message API allows you to send push notifications, emails, and SMS to your users. This guide is specific for SMS and MMS. See Push notification or Email to send to those channels.

Ensure your SMS setup is complete.


Add trackable links to your SMS contents using liquid syntax in the format {{'your_url' | track_link}}.

Example:

JSON
{
  "contents": {
    "en": "Hi, here's my link: {{'https://example.com' | track_link}} "
  }
}

In this example, the liquid syntax block will be replaced with a trackable short link and display in the message as: 1sgnl.co/XXXX.

See SMS trackable links for more details.


Headers

Authorization
string
default:Key YOUR_APP_API_KEY
required

Your App API key with prefix Key. See Keys & IDs.

Body

application/json

Response

200
application/json

200

The response is of type object.