An easy-to-follow guide for developers to start sending push notifications, emails, and SMS using OneSignal’s API.
Aliases, emails, and phone numbers targeting parameters.
include_aliases
external_id
, onesignal_id
, or a custom alias. Use with target_channel
to control the delivery channel. See Users and Aliases for more details.target_channel
include_aliases
. Accepts "push"
, "email"
, or "sms"
.include_subscription_ids
subscription_id
per API call.email_to
include_phone_numbers
Segments targeting parameters.
filters
Filters targeting parameter details.
AND
/OR
logic. No need to create predefined Segments.You can include up to 200 total entries per request. This limit includes each filter condition (e.g., field
) and logic operators like "OR"
.Performance guidance:"="
or "exists"
, and filters on last_session
, session_count
, or country
."!="
, "not_exists"
)—especially with users who have many tags. Contact support to request indexing optimizations.">"
, "<"
) on tags or custom properties. Indexing may be available on request.operator
AND
logic (default). AND
filters must be satisfied for the recipient to be included"operator": "OR"
to separate branches of logic. OR
filters are mutually exclusive. Recipients only need to satisfy one condition."AND"
, "OR"
.tag
include_aliases
targeting property.relation
= ">"
, "<"
, "="
, "!="
, "exists"
, "not_exists"
, "time_elapsed_gt"
, (time elapsed greater than) and "time_elapsed_lt"
(time elapsed less than)
time_elapsed_gt/lt
fields 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"
.
last_session
hours_ago
).relation
= ">"
or "<"
hours_ago
= number of hours before or after the user’s last session. Example: "1.1"
first_session
hours_ago
).relation
= ">"
or "<"
hours_ago
= number of hours before or after the user’s first session. Example: "1.1"
session_count
relation
= ">"
, "<"
, "="
or "!="
value
= number sessions. Example: "1"
session_time
relation
= ">"
or "<"
value
= Time in seconds the user has been in your app. Example: 1 day is "86400"
seconds
language
relation
= "="
or "!="
value
= 2 character language code. Example: "en"
.
app_version
relation
= ">"
, "<"
, "="
or "!="
value
= app version. Example: "1.0.0"
location
radius
= in meters
lat
= latitude
long
= longitude
contents
email_subject
and email_body
template_id
instead.📲 Push Notification Options.
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.ios_attachments
– Images/video/media.big_picture
– Large image (Android).chrome_web_image
– Large image (Chrome).small_icon
large_icon
buttons
– Action buttons.android_channel_id
priority
– Delivery urgency.ios_interruption_level
collapse_id
– Replaces older messages.📧 Email Options
template_id
– Use a pre-defined template for common message types.💬 SMS/MMS Options
contents
template_id
– Use a pre-defined template for common message types.Schedule delivery and per-user optimization parameters.
send_after
JavaScript’s Date() parser
.delayed_option
'timezone'
: Sends at the same local time across time zones.'last-active'
: Delivers based on each user’s most recent session.throttle_rate_per_minute
to 0
.delivery_time_of_day
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)200
response code if the request is valid and accepted.
id
is returned, the message was created successfully. Save this id
for future tracking and reference of message stats via View Message API.id
is returned, then the message was not created, likely due to no valid Subscriptions in the target audience.