Documentation Index
Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide walks you through sending messages with the OneSignal API — from choosing a target audience to composing content, scheduling delivery, and validating responses. Each section covers channel-specific options and performance guidance.Prerequisites
- Complete Channel Setup for the channels you plan to use: push, email, SMS, Live Activities.
- Start accumulating Subscriptions for your users.
- Have your REST API Key and App ID ready. See Keys and IDs.
Choose your target audience
You can target users with one of the following methods per request:- Aliases: Specific users via unique IDs, emails, or phone numbers.
- Segments: Groups based on predefined behaviors or attributes.
- Filters: Custom rules using tags, location, activity, and more.
isAndroid, isIos, isAnyWeb) when sending push notifications. By default, all push platforms are enabled.
Aliases, emails, phone numbers
Target specific users or lists of users (up to 20,000 entries per request). This method is best for Transactional Messages.Aliases, emails, and phone numbers targeting parameters
Aliases, emails, and phone numbers targeting parameters
Target up to 20,000 users by their
external_id, onesignal_id, or a custom alias. Combine with target_channel to select the delivery channel.The targeted delivery channel. Required when using
include_aliases or included_segments and sending SMS/RCS. Accepts "push", "email", or "sms". The "sms" value covers both SMS and RCS — RCS messages are delivered through the SMS channel.Target users’ specific Subscriptions by ID. Max 20,000
subscription_id per request.Send to specific email addresses (max 20,000 per request). Can only be used when sending email. If the email address does not exist within the OneSignal App, a new email subscription is created.
Send SMS/MMS/RCS to phone numbers in E.164 format (max 20,000 per request). Can only be used when sending SMS/MMS/RCS. If the phone number does not exist within the OneSignal App, a new SMS subscription is created.
Segments
Target users in existing segments. Users in multiple segments only receive the message once.Segments targeting parameters
Segments targeting parameters
Target predefined segments. Users who are in multiple segments only receive the message once. Combine with
excluded_segments to exclude users from specific segments. When sending SMS/RCS, set target_channel to "sms" (or use the legacy isSms=true field).Filters
Build real-time audiences withAND/OR logic without creating segments first.
You can include up to 200 total entries per request. This includes filter rows (for example, each field) and logical operators like {"operator": "OR"}.
Filters targeting parameter details
Filters targeting parameter details
Performance guidance:
- Fast: Tag filters using
"="or"exists", and filters onlast_session,session_count, orcountry. - Slower: Negation filters (
"!=","not_exists") — especially with users who have many tags. Contact support to request indexing optimizations. - Slow by default: Numeric comparisons (
">","<") on tags or custom properties. Indexing may be available on request. - Mixed performance: Combining tag filters with other fields may increase computation time.
- Implicit
ANDlogic between filters. Use"operator": "OR"to start a new branch. ORfilters are mutually exclusive. Recipients only need to satisfy one condition.- Allowed values:
"AND","OR".
tag
Target based on custom user Tags.relation=">","<","=","!=","exists","not_exists","time_elapsed_gt", (time elapsed greater than) and"time_elapsed_lt"(time elapsed less than)time_elapsed_gt/ltfields correspond to Time Operators and require a paid plan.
key= Tag key to compare.value= Tag value to compare. Not required for"exists"or"not_exists".
country
Country code of your Users. Uses ISO 3166-1 Alpha-2 format (two-letter country code).-
relation="=","!=","in_array", or"not_in_array" -
value= Two-letter country code in uppercase. Example:"US","GB","CA". For"in_array"and"not_in_array", the value should be a comma-separated list of values.
last_session
Time since the Subscription last used the app (in hours_ago).-
relation=">"or"<" -
hours_ago= number of hours before or after the user’s last session. Example:"1.1"
first_session
Time since the User first used the app or was created within OneSignal (in hours_ago).-
relation=">"or"<" -
hours_ago= number of hours before or after the user’s first session. Example:"1.1"
session_count
Total number of sessions by the Subscription.-
relation=">","<","="or"!=" -
value= number of sessions. Example:"1"
session_time
Total time the Subscription has spent in the app, in seconds.-
relation=">"or"<" -
value= time in seconds the user has been in your app. Example: 1 day is"86400"seconds.
language
User’s language code (e.g., “en”). See Multi-Language Messaging for details and supported language codes.-
relation="=","!=","in_array", or"not_in_array" -
value= 2 character language code. Example:"en". For"in_array"and"not_in_array", the value should be a comma-separated list of values.
app_version
App version set on the Subscription.-
relation=">","<","="or"!=" -
value= app version. Example:"1.0.0"
location
Target by GPS coordinates and radius. Location tracking must be turned on and accepted by the user. See Location-Triggered Notifications for details.-
radius= in meters -
lat= latitude -
long= longitude
Craft your message
Each channel has its own set of fields. At a minimum, you need the following to send a displayable message:- Push and SMS use
contents - Email uses
email_subjectandemail_body - Or reuse
template_idif you created templates.
Push notification options
Below are the most common parameters for push notifications. For the full list of options, see the Push notification reference.Push notification options
Push notification options
Content and text
contents– Main message body.headings– Title of the notification.subtitle– Secondary line of text.template_id– Use a pre-defined template for common message types.
Appearance
ios_attachments– Images/video/media.big_picture– Large image (Android).chrome_web_image– Large image (Chrome).small_iconlarge_iconbuttons– Action buttons.
Delivery and priority
android_channel_idpriority– Delivery urgency.ios_interruption_levelcollapse_id– Replaces older messages.
Data and extras
Email options
Email options
Email options
SMS/MMS options
SMS/MMS options
SMS/MMS options
Content
contentstemplate_id– Use a pre-defined template for common message types.
Media (MMS only)
Sender info
Schedule and per-user delivery
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.Schedule delivery and per-user optimization parameters
Schedule delivery and per-user optimization parameters
Schedule delivery for a future date/time (in UTC). The format must be valid per the ISO 8601 standard and compatible with
JavaScript's Date() parser.Controls how push and email messages are delivered on a per-user basis. Not available for SMS.
"timezone": Sends at the same local time across time zones."last-active": Delivers based on each user’s most recent session.
delayed_option is set, you must also set throttle_rate_per_minute to 0.Use with
delayed_option: "timezone" to set a consistent daily delivery time. Accepted formats:"9:00AM"(12-hour)"21:45"(24-hour)"09:45:30"(HH:mm:ss)
Submit the request
This final example sends a localized push notification to all subscribed users:- Push: FCM, APNs, or HMS
- Email: your email service provider
- SMS: Twilio
Handle the response
You receive a200 response code if the request is valid and accepted.
- If an
idis returned, the message was created successfully. Save thisidfor future tracking and reference of message stats via the View message API. - If no
idis returned, the message was not created, likely because there are no valid subscriptions in the target audience.
See our REST API Overview page for details on retries and rate limits.
FAQ
Can I combine include_aliases, included_segments, and filters in one request?
No. Each request must use exactly one targeting method. Mixing them returns a validation error. Choose aliases for transactional sends to specific users, segments for predefined audiences, or filters for ad-hoc audiences built with AND/OR logic.
Does target_channel: "sms" cover RCS?
Yes. The target_channel enum accepts "push", "email", and "sms". RCS messages are delivered through the SMS channel — there is no separate "rcs" value. OneSignal decides whether to send via RCS or SMS based on the recipient’s device and your sender configuration.
My request returned 200 but no id. What happened?
The request was valid but no message was created, typically because the target audience contains no valid subscriptions for the selected channel. Common causes include a segment that resolves to zero users, all targeted aliases being unsubscribed, or phone numbers that don’t match an existing SMS subscription.
Can I use // comments in the JSON request body?
No. The // comments in the examples on this page are illustrative only. Strict JSON does not support comments — strip them before sending to the API.
How is the Sent count in reports related to the API response?
The dashboard Sent metric is a composite. To derive it from the View message API, sum successful + failed + errored. See the Metrics glossary for the full mapping between dashboard, API, CSV, and Event Streams names.