---
title: "Create a widget"
method: POST
path: "/{teamPid}/widgets"
tags: ["Widgets"]
---

# Create a widget

`POST /{teamPid}/widgets`

## Request

- Base URL: `https://api.rightmessage.com/v1`
- URL: `https://api.rightmessage.com/v1/{teamPid}/widgets`
- Auth: HTTP bearer

Adds a widget to the project's draft. Publish the draft to make it live.

Requires an API token with the `write` ability. Tokens created without abilities have `*`, which grants every ability.

## Path parameters

- `teamPid` string, required

## Request body

- StoreWidgetRequest
  - `name` string, required
  - `type` 'modal' | 'bar' | 'toaster' | 'inline' | 'takeover'
  - `flow_id` string, nullable
  - `is_enabled` boolean
  - `frequency` 'startover' | 'immediately' | 'pageview' | 'session' | 'none'
  - `visibility` object
    - `conditions` string[], nullable
    - `show_on_specific_pages` string
    - `show_pages` string
    - `hide_on_specific_pages` string
    - `hide_pages` string
    - `isWhitelistEnabled` string
    - `whitelist` string
    - `isBlacklistEnabled` string
    - `blacklist` string
    - `trigger` string, nullable
  - `options` string[]

## Response `201`

`WidgetResource`

- object
  - `data` WidgetResource, required
    - `id` string, nullable, required
    - `name` string, nullable, required
    - `type` union, required
      - string
      - 'modal'
    - `is_enabled` union, required
      - string
      - boolean
    - `flow_id` string, nullable, required
    - `frequency` union, required
      - string
      - 'session'
    - `visibility` object, required
      - `conditions` string, nullable, required
      - `trigger` string, nullable, required
    - `options` string, nullable, required

## Other responses

- `401`: Missing, invalid or revoked API token.
- `403`: Authorization error
- `404`: Not found
- `422`: Validation error
- `429`: Rate limit exceeded: 120 requests per minute for project endpoints, 60 per minute for token and connection endpoints. Retry after the `Retry-After` seconds.

---

[API](https://skmtc.dev/rightmessage/apis/rightmessage-api.md) - [All operations](https://skmtc.dev/rightmessage/apis/rightmessage-api/llms.txt) - [OpenAPI document](https://skmtc.dev/rightmessage/apis/rightmessage-api/revisions/adec35e9720c?raw)
