> For the complete documentation index, see [llms.txt](https://docs.fastn.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastn.ai/reference/api.md). Agents can also search and read this documentation through its [MCP server](https://docs.fastn.ai/~gitbook/mcp).

# HTTP API

Calling workflows and unified endpoints over HTTP.

## Base URL

Base URL: `https://api.fastn.dev`. Every path starts `/v1`, for example `https://api.fastn.dev/v1/workflows/{workflowId}/execute`. The same routes also answer under `/api/v1`, which older examples use. Your workflow's **API** tab shows the full URL for that workflow.

From Node.js or TypeScript, the [SDK](https://docs.fastn.ai/reference/sdk.md) (`@fastn-ai/sdk`) wraps the same API in typed methods. Every other endpoint, including installations, triggers, and alerts, is in the [REST API reference](https://docs.fastn.ai/reference/api/rest.md).

***

## Authentication

Every request carries an API key, as a bearer token or in `X-API-Key`:

```
Authorization: Bearer fsk_live_<your-key>
```

```
X-API-Key: fsk_live_<your-key>
```

These two are the only headers the platform API reads a key from. Webhook URLs accept others, listed below.

### Which header carries the key

Every key starts `fsk_live_` or `fsk_test_`. The header it goes in depends on what you call:

| You call                                                                                                                        | Send the key as                                                                  |
| ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| The platform API, `https://api.fastn.dev/v1/…` (a workflow's `/execute`, `/embed/token`, every other route)                     | `Authorization: Bearer fsk_…` or `X-API-Key: fsk_…`                              |
| A [webhook trigger](https://docs.fastn.ai/build/integrations/triggers/webhooks.md)'s URL                                        | `X-API-Key: fsk_…`, `Authorization: Bearer fsk_…` or `x-fastn-access-key: fsk_…` |
| A [connector's webhook URL](https://docs.fastn.ai/build/integrations/connectors/webhook-config.md), with **Require API key** on | `X-API-Key: fsk_…` or `x-fastn-access-key: fsk_…`                                |

`X-API-Key` works on all three. `x-fastn-access-key` on the platform API, or `Authorization` on a connector's webhook URL, is answered `401`. No endpoint reads `x-fastn-api-key`.

### Test and live keys

Keys are created under [Embed → API keys](https://docs.fastn.ai/embed/api-keys.md) and come in two modes.

| Header              | Live key                                     | Test key                                             |
| ------------------- | -------------------------------------------- | ---------------------------------------------------- |
| `Authorization`     | `Bearer fsk_live_…`                          | `Bearer fsk_test_…`                                  |
| `X-fastn-Test-Mode` | Not needed                                   | Must be `true`: **a test key is refused without it** |
| `x-fastn-env`       | Its pinned environment or `test` (see below) | Only `test`                                          |

A test key without `X-fastn-Test-Mode: true` is rejected with `403`.

`x-fastn-env` picks which code runs:

* `test`: the workflow's latest published version.
* any other slug: the version deployed to that environment.

Which environments a key may name:

* **Test key:** only `test`. Any other slug is refused with `403` `ENV_NOT_PERMITTED`.
* **Live key pinned to an environment:** that environment or `test`; anything else is refused with `403` `ENV_NOT_PERMITTED`. Every new live key is pinned, to `live` when you do not pick an environment.
* **Live key made before keys were pinned:** any environment slug.

When `x-fastn-env` is omitted, a test key runs `test` and a live key runs `live` (a pinned live key runs its pinned environment).

Test keys act on real data. See [API keys](https://docs.fastn.ai/embed/api-keys.md).

***

## Execute a workflow

```
POST /v1/workflows/{workflowId}/execute
```

The workflow id is shown on the workflow's API tab, in the form `wf_b5880b29eb25`.

```bash
curl -X POST https://api.fastn.dev/v1/workflows/WORKFLOW_ID/execute \
  -H "Authorization: Bearer fsk_test_<your-key>" \
  -H "X-fastn-Test-Mode: true" \
  -H "x-fastn-env: test" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "saleId": "S-1024",
      "isRetry": false,
      "syncMode": "incremental"
    }
  }'
```

### Request body

```json
{
  "input": {
    "key": "value"
  }
}
```

The `input` object is what arrives as `ctx.input`. Its shape comes from the workflow's input contract.

{% hint style="info" %}
Every workflow's **API** tab generates a ready-to-run curl filled in with that workflow's own host, id, and contract fields. When this page and the tab differ, copy from the tab: it is generated from the deployment you call.
{% endhint %}

### Response: Instant tier

The workflow's return value comes back inline, synchronously, as a `200`. The run is cut off at 25 seconds (2 minutes for organizations with the "Increase Instant timeout" entitlement). The execution id is in the `X-Execution-Id` response header, because the body is the workflow's own return value. Its shape is the workflow's own **output contract**: read it on the Contract tab rather than from an example here, because it is different for every workflow.

### Response: Standard and Long tiers

`202 Accepted`, with the execution id in the body at `data.executionId`. The run continues in the background; the id is what identifies it afterwards in [Executions](https://docs.fastn.ai/operate/operate/executions.md), where each row expands to its input, output, and per-step timings.

To get the outcome of a Standard or Long run, poll:

```
GET /v1/workflows/{workflowId}/executions/{executionId}
```

The workflow id is part of the path.

***

## Scoping a call to a customer

The same workflow serves all of your customers, and headers on the request say which one a call is for.

| Header                        | Carries                                                                    |
| ----------------------------- | -------------------------------------------------------------------------- |
| `x-org-id`                    | The customer this call acts for: your own id for it, or Fastn's id for it. |
| `x-installation-id`           | Which installation of the integration the call belongs to.                 |
| `x-fastn-connections`         | The connections the installation uses.                                     |
| `x-fastn-installation-config` | The configuration values that installation was set up with.                |

**Naming the customer:** `x-org-id` is the one header that names a customer. Send your own id for it or Fastn's id for it; see [Find a customer's id](https://docs.fastn.ai/embed/api-keys/finding-your-org-identifier.md). Leave it out to act as your own organization.

* **A key set to Enforce** under [Verify caller identity](https://docs.fastn.ai/embed/api-keys/identity-verification.md) must also send `x-user-id` and `x-identity-hmac` on every call, even with no `x-org-id` (`401 IDENTITY_HEADERS_REQUIRED`).
* **A key limited to one customer** refuses an `x-org-id` that names any other customer, and a request whose `x-org-id` and `?orgId=` name two different customers (`400 IDENTITY_HEADERS_CONFLICT`).
* **A key limited to some customers** refuses a customer outside them (`403 API_KEY_SCOPE_MISMATCH`), and when it covers several, the call must name one in `x-org-id` (`400 API_KEY_SCOPE_AMBIGUOUS`).
* **An `x-org-id` that isn't one of your customers** returns `404 IDENTITY_ORG_NOT_FOUND`.

`x-fastn-connections` and `x-fastn-installation-config` are only read together with `x-installation-id`. On `/execute`, Fastn reloads the named installation and overlays its stored connections and configuration on the headers, so callers name an installation; they cannot pick connections by sending them.

Inside the workflow these arrive on `ctx.headers`. See [Workflow runtime API](https://docs.fastn.ai/reference/workflow-runtime.md). The workflow editor's autocomplete lists the exact shapes; check there before you hard-code one.

***

## Unified endpoints

Where a [unified API](https://docs.fastn.ai/build/integrations/unified-apis.md) covers an entity, call it directly rather than a specific connector.

```http
GET  /v1/unified/crm/account?page_size=50
GET  /v1/unified/crm/account/{recordId}
POST /v1/unified/crm/account
POST /v1/unified/crm/note
```

Fastn routes to whichever provider the customer authorized. Each endpoint on the Unified APIs page has a **Copy curl** button with the correct headers filled in.

***

## Webhook endpoints

A [webhook trigger](https://docs.fastn.ai/build/integrations/triggers.md) gives you a public URL. Whether callers must authenticate is set on the trigger:

| Authentication setting  | Caller must send                                                                                                                                 |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| **API Key (x-api-key)** | `x-api-key: <your-key>` (a Fastn key, starting `fsk_`) or `Authorization: Bearer <your-key>`; `x-fastn-access-key: <your-key>` is still accepted |
| **None (public)**       | Nothing                                                                                                                                          |

`X-API-Key` and `Authorization: Bearer` count only when the value starts `fsk_`, the prefix every Fastn key has, so a sender's own `x-api-key` or bearer token is not mistaken for one. Write the scheme as `Bearer`, here and on the platform API: `bearer fsk_…` in lowercase is not read. A connector's webhook URL (with **Require API key** on) takes `x-api-key` or `x-fastn-access-key` only, not `Authorization`.

***

## Embed tokens

An embed token opens the widget for one of your customers. Mint it from your backend with your API key, and never expose the key to a browser.

| Endpoint                       | What it does                                                       |
| ------------------------------ | ------------------------------------------------------------------ |
| `POST /v1/embed/token`         | Mint a token for a customer. It lasts eight hours.                 |
| `POST /v1/embed/token/refresh` | Swap a live token for a new one, for up to seven days per session. |

The page then loads the widget with the token:

```
https://api.fastn.dev/v1/embed/iframe?token=emb_…
```

That URL carries a live credential: build it per session, and don't log or share it.

* Every header, body field and error: [Embed token API](https://docs.fastn.ai/embed/embedding/token-api.md).
* The backend function, with code: [Generate embed tokens](https://docs.fastn.ai/embed/embedding/generating-embed-tokens.md).

***

## Errors

| Response                    | Means                                                                                                                                                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `WORKFLOW_NOT_PUBLISHED`    | The workflow has never had a snapshot published, so there is no version to run. **Every call returns this until you publish one**. It is the most common cause of "the API did nothing". Publish from the workflow editor. |
| `401` / `403`               | The key is wrong, revoked, expired, outside its IP allowlist, or lacks the permission for what you called. Check the key on [Embed → API keys](https://docs.fastn.ai/embed/api-keys.md).                                   |
| Test key rejected           | The key is a test key and `X-fastn-Test-Mode: true` was not sent.                                                                                                                                                          |
| `ENV_NOT_PERMITTED` (`403`) | The key may not run the environment named in `x-fastn-env`. See [Test and live keys](#test-and-live-keys).                                                                                                                 |

A workflow that runs and throws is a **Failed** execution rather than a transport error: look for it in [Executions](https://docs.fastn.ai/operate/operate/executions.md), not in the HTTP response.

***

## Rate limits

Two limits apply to API calls, both counted per minute:

| Limit                | What it counts                                                                                                                   | Ceiling                                                                |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| **Per organization** | Every call made with an API key or an embed session, across your whole account. Your customers' calls count toward your account. | 100 requests per minute on Launch, 500 on Scale, custom on Enterprise. |
| **Per caller**       | Calls from one identity (one API key, one embed session, one signed-in person), held separately on each gateway instance.        | A cap on calls from a single caller, separate from your plan's limit.  |

Two narrower limits can also apply: an API key can carry its own per-minute limit, and calls to `/execute` share one per-minute bucket per customer, so many embed sessions for one customer cannot run workflows without bound (code `EXECUTE_RATE_LIMITED`).

Going over any of these returns `429` with a `Retry-After` header. The organization limit answers with code `ORG_RATE_LIMITED`. Calls to the billing, plans, quota and usage endpoints never count toward the organization limit, so you can always see why you are limited. Your plan's limits are on [Settings → Billing](https://docs.fastn.ai/settings/manage/billing.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fastn.ai/reference/api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
