> ## 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.

# Create in-app message

> Create a custom HTML in-app message with a schedule, audience, and triggers. It can be set as a draft or published right away. The in-app message is shown full screen, without margin, and your HTML controls how it looks.

## Overview

Create a custom HTML [in-app message](https://documentation.onesignal.com/docs/en/in-app-messages-setup.md). 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](https://documentation.onesignal.com/docs/en/design-your-in-app-message-with-html.md) for how to write the HTML and the [in-app message JavaScript API](https://documentation.onesignal.com/docs/en/in-app-message-api.md) for click handling.

> [!NOTE]
>
> 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](https://documentation.onesignal.com/docs/en/keys-and-ids.md). 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.

```json theme={null}
{
  "is_draft": false,
  "in_app_message": {
    "name": "Welcome offer",
    "display_duration": 0,
    "html": "<!doctype html><html><body><h1>Welcome!</h1><p>20% off your first order.</p></body></html>",
    "start_time": "2026-11-01T00:00:00Z",
    "included_segment_ids": ["YOUR_SEGMENT_ID"],
    "triggers": [
      { "conditions": [{ "kind": "session_time", "operator": "greater", "value": 30 }] }
    ]
  }
}
```

### Draft or publish

`is_draft` is required and decides whether the in-app message goes live.

* `is_draft: true` saves the in-app message paused. Publish it later with [Update in-app message](https://documentation.onesignal.com/reference/update-in-app-message.md) or [Pause or resume in-app message](https://documentation.onesignal.com/reference/pause-or-resume-in-app-message.md).
* `is_draft: false` publishes the in-app message. It starts displaying at `start_time`, which defaults to now.

> [!WARNING]
>
> 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](https://documentation.onesignal.com/docs/en/segmentation.md) 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](https://documentation.onesignal.com/docs/en/model-context-protocol.md), acts with the [role](https://documentation.onesignal.com/docs/en/manage-team-members.md) 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](https://documentation.onesignal.com/docs/en/iam-triggers.md) for how triggers behave on the device.

```json theme={null}
{
  "triggers": [
    {
      "conditions": [
        { "kind": "session_time", "operator": "greater", "value": 30 },
        { "kind": "custom", "property": "plan", "operator": "equal", "value": "trial" }
      ]
    }
  ]
}
```

| Field | Type | Description |
| - | - | - |
| `kind` | string | `custom`, `session_time`, or `min_time_since`. |
| `property` | string | The trigger key your app sets through the SDK. Required for `custom`. Omit for the time kinds. |
| `operator` | string | `greater`, `less`, `greater_or_equal`, `less_or_equal`, `equal`, `not_equal`, `exists`, or `not_exists`. |
| `value` | string or integer | The value to compare against. Its type depends on `kind`. |

| Kind | `value` | Rules |
| - | - | - |
| `custom` | string | Compared against the trigger value your app sets. Required for every operator except `exists` and `not_exists`. Must be numeric for `greater`, `less`, `greater_or_equal`, and `less_or_equal`. |
| `session_time` | integer | Seconds since the current session started. Always required. `1` to `2147483647`. |
| `min_time_since` | integer | Seconds since the last in-app message was shown. Always required. `1` to `2147483647`. |

### 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

| Limit | Maximum | At the limit |
| - | - | - |
| Trigger sets per in-app message | 30 | The request is rejected with a `400` and nothing is saved. |
| Conditions per trigger set | 30 | The request is rejected with a `400` and nothing is saved. |
| Clickable elements in the HTML | 20 distinct `data-onesignal-unique-label` values | The request is rejected with a `400` and nothing is saved. |

## Response

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

```json theme={null}
{
  "success": true,
  "payload": { "id": "2c5c6b7e-0f6d-4a5e-9a2b-1a2b3c4d5e6f" }
}
```


## OpenAPI

````yaml POST /apps/{app_id}/in_app_messages
openapi: 3.1.0
info:
  title: api.onesignal.com
  version: '11.6'
servers:
  - url: https://api.onesignal.com
security:
  - {}
paths:
  /apps/{app_id}/in_app_messages:
    post:
      summary: Create in-app message
      description: >-
        Create a custom HTML in-app message with a schedule, audience, and
        triggers. Returns the `id` of the new in-app message. The in-app message
        is shown full screen with no margin.
      operationId: create-in-app-message
      parameters:
        - name: app_id
          in: path
          description: >-
            Your OneSignal App ID in UUID v4 format. See [Keys &
            IDs](/docs/en/keys-and-ids).
          schema:
            type: string
            default: YOUR_APP_ID
          required: true
        - name: Authorization
          in: header
          description: >-
            Your App API key with prefix `Key `. See [Keys &
            IDs](/docs/en/keys-and-ids).
          required: true
          schema:
            type: string
            default: Key YOUR_APP_API_KEY
        - name: Content-Type
          in: header
          required: true
          schema:
            type: string
            default: application/json; charset=utf-8
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - is_draft
                - in_app_message
              properties:
                is_draft:
                  type: boolean
                  description: >-
                    `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:
                  type: object
                  required:
                    - name
                    - display_duration
                    - html
                  properties:
                    name:
                      type: string
                      description: Name shown in the dashboard.
                      default: YOUR_IN_APP_MESSAGE_NAME
                    display_duration:
                      type: integer
                      minimum: 0
                      default: 0
                      description: >-
                        Seconds the in-app message stays on screen. `0` keeps it
                        until dismissed.
                    html:
                      type: string
                      description: >-
                        The full HTML document to display. Limited to 20
                        distinct `data-onesignal-unique-label` values.
                    start_time:
                      type: string
                      format: date-time
                      description: >-
                        When the in-app message becomes eligible to display, in
                        ISO 8601 format. Defaults to now.
                    end_time:
                      type:
                        - string
                        - 'null'
                      format: date-time
                      description: >-
                        When the in-app message stops displaying, in ISO 8601
                        format. Must not be before `start_time`. Defaults to no
                        end.
                    triggers:
                      type: array
                      maxItems: 30
                      items:
                        $ref: '#/components/schemas/InAppMessageTriggerSet'
                      description: >-
                        Trigger sets that decide when the in-app message shows.
                        Maximum 30. Omit or send `[]` to show on app open.
                    redisplay_delay:
                      type: integer
                      description: >-
                        Seconds between showings to the same user. Send together
                        with `redisplay_limit`.
                    redisplay_limit:
                      type: integer
                      description: >-
                        Maximum re-showings per user. Send together with
                        `redisplay_delay`. `2147483647` means unlimited.
                    included_segment_ids:
                      type: array
                      items:
                        type: string
                      description: >-
                        UUIDs of the Segments the in-app message is shown to.
                        Every ID must be a Segment of this app.
                    excluded_segment_ids:
                      type: array
                      items:
                        type: string
                      description: >-
                        UUIDs of the Segments the in-app message is never shown
                        to.
                  description: The in-app message definition.
            examples:
              Request:
                value:
                  is_draft: false
                  in_app_message:
                    name: Welcome offer
                    display_duration: 0
                    html: >-
                      <!doctype html><html><body><h1>Welcome!</h1><p>20% off
                      your first order.</p></body></html>
                    start_time: '2026-11-01T00:00:00Z'
                    included_segment_ids:
                      - YOUR_SEGMENT_ID
                    triggers:
                      - conditions:
                          - kind: session_time
                            operator: greater
                            value: 30
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    description: '`true` when the request succeeded.'
                  payload:
                    type: object
                    properties:
                      id:
                        type: string
                        description: UUID of the in-app message.
              example:
                success: true
                payload:
                  id: 2c5c6b7e-0f6d-4a5e-9a2b-1a2b3c4d5e6f
        '400':
          description: The request is invalid. `errors` lists every problem found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InAppMessageErrorResponse'
              example:
                success: false
                errors:
                  - '''name'' Message name required'
                  - '''body'' Display duration is required'
        '401':
          description: >-
            The API key is missing or invalid, or belongs to another app or
            organization. This body has no `success` key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicErrorResponse'
              example:
                errors:
                  - >-
                    Access denied.  Please include an 'Authorization: ...'
                    header with a valid API key
                    (https://documentation.onesignal.com/docs/en/keys-and-ids#api-keys).
        '403':
          description: >-
            The role behind the request cannot activate in-app messages. This
            body has no `success` key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicErrorResponse'
              example:
                errors:
                  - Current user permissions do not allow this action.
        '429':
          description: >-
            Rate limit exceeded. Requests to this path are blocked for 60
            seconds. This body has no `success` key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      type: string
                  limit:
                    type: string
                    description: Name of the rate limit that was exceeded.
              example:
                errors:
                  - API rate limit exceeded
                limit: API Per App
components:
  schemas:
    InAppMessageTriggerSet:
      type: object
      required:
        - conditions
      properties:
        id:
          type: string
          description: >-
            UUID of the trigger set. Returned in responses. Optional in
            requests.
        conditions:
          type: array
          maxItems: 30
          items:
            $ref: '#/components/schemas/InAppMessageTriggerCondition'
          description: Conditions that must all hold for the set to fire. Maximum 30.
    InAppMessageErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Always `false`.
        errors:
          type: array
          items:
            type: string
          description: >-
            Every problem found with the request. Field-level errors start with
            the quoted field name, for example `'name' Message name required`.
    BasicErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: One or more human-readable error messages.
        success:
          type: boolean
          description: >-
            Present (and `false`) on some endpoints (notifications, templates,
            segments). Not emitted by every endpoint.
        reference:
          type: array
          items:
            type: string
          description: >-
            Documentation URL fragments related to the error. Only emitted by
            the API-key auth error helpers.
    InAppMessageTriggerCondition:
      type: object
      required:
        - kind
        - operator
      properties:
        id:
          type: string
          description: UUID of the condition. Returned in responses. Optional in requests.
        kind:
          type: string
          enum:
            - custom
            - session_time
            - min_time_since
          description: >-
            `custom` compares a trigger your app sets through the SDK.
            `session_time` is seconds since the current session started.
            `min_time_since` is seconds since the last in-app message was shown.
        property:
          type: string
          description: >-
            The trigger key your app sets through the SDK. Required for
            `custom`. Omit for the time kinds.
        operator:
          type: string
          enum:
            - greater
            - less
            - greater_or_equal
            - less_or_equal
            - equal
            - not_equal
            - exists
            - not_exists
          description: How the trigger value is compared with `value`.
        value:
          oneOf:
            - type: string
            - type: integer
          description: >-
            A string for `custom`. An integer from `1` to `2147483647` for
            `session_time` and `min_time_since`. Not required for `custom` with
            `exists` or `not_exists`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.