# REST API

URL: https://notifly.io/docs/api

> The versioned Notifly REST API at api.notifly.io — quickstart, API-key authentication, environments, errors, pagination, idempotency, rate limits, and subscriber credentials.

Everything in Notifly is driven by one versioned REST surface at `https://api.notifly.io/v1` — workflows, subscribers, topics, messages, notifications, integrations, layouts, environments, and audit logs. The dashboard uses the same API, so anything it can do, you can automate.

* **Interactive reference:** [API reference](https://notifly.io/docs/api-reference) — every endpoint, schema, and example request, generated from the OpenAPI document.
* **OpenAPI spec:** [openapi.json](https://notifly.io/docs/api/openapi.json) same-origin, or [api.notifly.io/openapi.json](https://api.notifly.io/openapi.json) / [openapi.yaml](https://api.notifly.io/openapi.yaml) straight from the live API, for codegen and tooling.

<Callout title="Heading ids are a contract">
  Anchors on this page are linked from outside the docs: the API's idempotency
  `Link` response header points at `https://notifly.io/docs/api#idempotency`, and
  the OpenAPI document's external-docs link points at this page. Rename a heading
  only alongside every consumer.
</Callout>

## Quickstart

**1. Get an API key.** API keys live per environment in the [Notifly dashboard](https://app.notifly.io) under **API Keys**. Sign up, pick an environment, and copy its secret key.

**2. Trigger a workflow.** Create a workflow in the dashboard, then fire it for a subscriber:

```bash
curl -X POST https://api.notifly.io/v1/events/trigger \
  -H "Authorization: ApiKey $NOTIFLY_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"<workflow-id>","to":{"subscriberId":"<subscriber-id>"},"payload":{"body":"Hello from Notifly"}}'
```

`to` also accepts a plain subscriber ID string (`"to":"<subscriber-id>"`), an array of recipients, or a topic object; the object form above is the one that can also create or update the subscriber inline.

**3. Read your subscribers.** Every recipient is a subscriber you can list, inspect, and update:

```bash
curl "https://api.notifly.io/v1/subscribers?page=0&limit=10" \
  -H "Authorization: ApiKey $NOTIFLY_SECRET_KEY"
```

## Trigger responses

`POST /v1/events/trigger` answers `201` once it has understood the request, and the body says what happened to the run:

```json
{ "data": { "acknowledged": true, "status": "processed", "transactionId": "txn_..." } }
```

| `status`                    | `acknowledged` | Meaning                                                                                                                                                    |
| --------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `processed`                 | `true`         | The run was queued. Delivery is asynchronous, so a step can still fail afterwards (a missing payload value, a channel with no provider, a provider error). |
| `trigger_not_active`        | `false`        | The workflow exists but is switched off (or switched off for that tenant). Nothing ran.                                                                    |
| `no_workflow_steps_defined` | `false`        | The workflow has no steps. Nothing ran.                                                                                                                    |
| `no_tenant_found`           | `false`        | The `tenant` in the request does not exist in this environment. Nothing ran.                                                                               |
| `invalid_recipients`        | `false`        | None of the recipients in `to` is a valid subscriber id or topic key. Nothing ran.                                                                         |

When `acknowledged` is `false`, `error` holds a short reason. The HTTP status stays `201` and `status` keeps the same values as before, so a client that branches on `status` needs no change; check `acknowledged` (or `status === "processed"`) before you treat the run as sent. A workflow id that does not exist is a `422` with the message `workflow_not_found`, and a payload that fails the workflow's [payload schema](https://notifly.io/docs/payload-schema) is a `400`.

`processed` only means the run was queued. To see how it ended, read the notification for the `transactionId` (`GET /v1/notifications?transactionId=<transactionId>`) or open the run in the dashboard's activity feed.

Each item of `POST /v1/events/trigger/bulk` has the same shape. An item that failed validation comes back with `status: "error"`, `acknowledged: false` and the reason in `error`.

### Severity

A notification's severity (`none`, `low`, `medium` or `high`) is a property of the workflow, set in the dashboard or with the workflows API. It is not read from the `payload`, because the payload is your own data and a `severity` key in it often means something else (`critical`, `sev1`). To set it for one run, pass it in `overrides`:

```json
{ "name": "<workflow-id>", "to": "<subscriber-id>", "payload": { "body": "Disk is full" }, "overrides": { "severity": "high" } }
```

The override wins over the workflow's own severity for that run, and shows up in the Inbox and in the activity feed.

## Authentication

Authenticate every request with the `ApiKey` scheme in the `Authorization` header:

```
Authorization: ApiKey <secret-key>
```

Keys are environment-scoped — a Development key can never touch Production data. Treat the secret key like a password: keep it server-side, never ship it in browser or mobile code, and roll it from the dashboard if it leaks.

## Environments

Each organization has separate environments (Development and Production by default). Workflows, subscribers, messages, and API keys all belong to exactly one environment, so you can iterate safely in Development and promote to Production when ready. The environment a request operates on is determined by the API key you authenticate with.

## Errors

The API uses standard HTTP status codes: `2xx` success, `400` invalid input, `401` missing or bad key, `404` not found, `409`/`422` conflicts, `429` rate limited. Error responses carry a JSON body with a `message` and a `statusCode`:

```json
{
  "statusCode": 404,
  "message": "Workflow not found",
  "error": "Not Found"
}
```

## Pagination

List endpoints accept `page` (0-based) and `limit` query parameters and return items in `data`. Responses include either a `hasMore` boolean or a total count depending on the endpoint — when `hasMore` is `true`, request the next `page`.

## Idempotency

Send an `Idempotency-Key` header (any unique string, e.g. a UUID) on `POST` and `PATCH` requests to make retries safe. Idempotency applies to ApiKey-authenticated requests.

```bash
curl -X POST https://api.notifly.io/v1/events/trigger \
  -H "Authorization: ApiKey $NOTIFLY_SECRET_KEY" \
  -H "Idempotency-Key: 0d1f6c1e-8f2a-4b0c-9d3e-5a6b7c8d9e0f" \
  -H "Content-Type: application/json" \
  -d '{"name":"<workflow-id>","to":{"subscriberId":"<subscriber-id>"},"payload":{"body":"Hello"}}'
```

* Replays within the **24-hour window** return the original response with the `Idempotency-Replay: true` header.
* Reusing a key with a different request body is rejected with `422`.
* A concurrent duplicate (first request still in flight) returns `409` with a `Retry-After` header.

## Rate limits

Requests are metered with a token-bucket algorithm: each environment has a steady refill rate plus burst capacity, and heavier endpoints draw more from the bucket. Every response includes `RateLimit-*` headers describing the current limit, remaining allowance, and reset time. On `429`, back off for the `Retry-After` duration and retry — read the headers rather than hard-coding numbers, since exact limits depend on the deployment and plan.

## Subscriber credentials

Push device tokens and chat webhook credentials are stored per subscriber, per provider. Set them with `PUT /v1/subscribers/{subscriberId}/credentials` — they also show up in the subscriber drawer in the dashboard.

```bash
curl -X PUT https://api.notifly.io/v1/subscribers/<subscriber-id>/credentials \
  -H "Authorization: ApiKey $NOTIFLY_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"providerId":"fcm","credentials":{"deviceTokens":["<device-token>"]}}'
```

## SDKs

* **Python** — `notifly-sdk` (import name `notifly_py`) is published on PyPI and covers the full REST surface. See the [Python SDK page](https://notifly.io/docs/python-sdk).
* **Node.js / TypeScript (server)** — `@notiflyio/api` on npm (`npm install @notiflyio/api`).
* **JavaScript, React, Next.js, React Native** — the open-source client SDKs are published on npm as `@notiflyio/js`, `@notiflyio/react`, `@notiflyio/nextjs` and `@notiflyio/react-native`.

## MCP server

Notifly also ships a remote MCP server at `api.notifly.io/mcp` with OAuth 2.1 sign-in and every Notifly feature as a tool for AI clients, served through Code Mode. See [Connect AI assistants](https://notifly.io/docs/connecting-ai-assistants) for the tool list and the setup command.
