This guide helps you get started with sending messages using the OneSignal API. You’ll learn how to pick your target audience, set up content for push, email, or SMS, and schedule when it sends.

Before you begin, make sure you:


Select your target audience

You can target users using:

  1. Aliases – Specific users via unique IDs, emails, or phone numbers.
  2. Segments – Groups based on predefined behaviors or attributes.
  3. Filters – Custom rules using tags, location, activity, and more.

Only one targeting method is allowed per message. For example, you cannot mix aliases and filters.

Additionally, you can target specific platforms (Android, iOS, Web) when sending push notifications.

Aliases, emails, phone numbers

Target specific users or groups of users (up to 20,000 entries). This method is best for Transactional Messages.


Segments

Target groups of users based on predefined Segments.


filters

Use filters to target groups of users dynamically without creating predefined Segments.


Craft your message

Each messaging channel has its own set of parameters that control how the message appears, behaves, and is delivered. At a minimum, you need the following to send a displayable message:

  • Push & SMS use contents
  • Email uses email_subject and email_body
  • If you created Templates, you can use template_id instead.
// Message request body
{
  "contents": {
    "en": "Hello, world",
    "es": "Hola Mundo",
    "fr": "Bonjour le monde",
    "zh-Hans": "你好世界"
  }
}

For advanced customization—like adding images, buttons, sounds, or tracking—see the channel-specific options below.

Push notification options

Below are the most common parameters for push notifications. For the full list of options, see the Push notification reference.

Email options

SMS/MMS options


Schedule & per-user delivery options

By default, messages are sent immediately. You can schedule delivery in advance and optimize timing per-user based on their local timezone or recent activity.


Submit the request

This final example sends a localized push notification to all subscribed users:

curl -X "POST" "https://api.onesignal.com/notifications" \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Key YOUR_API_KEY' \
     -d $'{
  "target_channel": "push",
  "included_segments": [
    "Subscribed Users"
  ],
  "app_id": "YOUR_APP_ID",
  "contents": {
    "en": "Hello, world",
    "es": "Hola mundo",
    "fr": "Bonjour le monde",
    "zh-Hans": "你好世界"
  }
}'

Next steps

Refer to the channel-specific APIs to customize delivery further: