Skip to main content
POST
Create in-app message

Overview

Create a custom HTML in-app message. Block editor style in-app messages and carousels can only be created from the dashboard. The API manages an in-app message’s default language only. Language variants cannot be created or edited through the API. See Design in-app messages with HTML for how to write the HTML and the in-app message JavaScript API for click handling.
Every in-app message this API creates is shown full screen with no margin. Placement is not configurable through the API, though you can build a modal-style layout in your HTML.

How to use this API

Authenticate with your App API Key. The body has two top-level keys: is_draft and in_app_message. Inside in_app_message, only name, display_duration, and html are required.

Draft or publish

is_draft is required and decides whether the in-app message goes live.
Send is_draft at the top level of the body, beside in_app_message. A missing key, null, or an is_draft nested inside in_app_message is rejected with a 400 and nothing is created.
Publishing an in-app message that targets a paused Segment is rejected.

Permissions

An API key can create and publish in-app messages in its app. A request made with an OAuth access token, such as through the OneSignal MCP server, acts with the role of the signed-in user. A role that can create in-app messages but cannot activate them, such as Composer, can create drafts only. That role receives a 403 for is_draft: false.

Schedule and audience

  • start_time and end_time are ISO 8601 timestamps. start_time defaults to now and end_time defaults to no end. end_time cannot be before start_time.
  • included_segment_ids lists the Segments the in-app message is shown to. excluded_segment_ids lists the Segments the in-app message is never shown to. Every ID must be a Segment of this app.
  • display_duration is the number of seconds the in-app message stays on screen. 0 keeps the in-app message until the user dismisses it.

Triggers

triggers is an array of trigger sets. A set fires when all of its conditions hold. The in-app message shows when any set fires. Omit triggers or send [] to show the in-app message on app open. See In-app message triggers for how triggers behave on the device.

Redisplay

An in-app message is shown once per user by default. To show it again, send redisplay_delay and redisplay_limit together. Sending one without the other is rejected.
  • redisplay_limit is the maximum number of re-showings per user. It must be at least 1. 2147483647 means unlimited.
  • redisplay_delay is the number of seconds between showings. It must be at least 1. 0 is accepted only with a redisplay_limit of 2147483647, which shows the in-app message every time its triggers are satisfied.

Limits

Response

A successful request returns 200 OK with the id of the new in-app message:

Headers

Authorization
string
default:Key YOUR_APP_API_KEY
required

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

Content-Type
string
default:application/json; charset=utf-8
required

Path Parameters

app_id
string
default:YOUR_APP_ID
required

Your OneSignal App ID in UUID v4 format. See Keys & IDs.

Body

application/json
is_draft
boolean
required

true saves the in-app message as a paused draft. false publishes it. Send it at the top level of the body, beside in_app_message.

in_app_message
object
required

The in-app message definition.

Response

200

success
boolean

true when the request succeeded.

payload
object