> ## Documentation Index
> Fetch the complete documentation index at: https://docs.widgetic.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API reference

> The base URL, authentication, responses, errors and the conventions that every Widgetic API endpoint shares.

The Widgetic API is a REST API. It takes and returns JSON over HTTPS. The [SDKs](https://docs.widgetic.com/docs/sdks/overview.md) and the [CLI](https://docs.widgetic.com/docs/cli/getting-started.md) are generated from the same contract, and you can [download the OpenAPI specification](https://raw.githubusercontent.com/widgetic/docs/main/openapi/widgetic-api-public.json) for your own tooling.

## Base URL

Every path in this reference is relative to:

```bash theme={"theme":"css-variables"}
https://api.widgetic.com/v1
```

`GET /widgets` is therefore `https://api.widgetic.com/v1/widgets`. Send every request over HTTPS.

> [!NOTE]
>
> The public embed endpoints, the ones under `/embed`, are the exception: they are served from `https://api.widgetic.com`, without `/v1`. A visitor's browser calls them, so they take no key. See [Embedding widgets](https://docs.widgetic.com/docs/api/embedding.md).

## Authentication

Send your API key in the `Authorization` header as a bearer token:

```bash theme={"theme":"css-variables"}
Authorization: Bearer <your API key>
```

There are two kinds of key, and they work differently:

* An **organisation key** (`wdg_org_`) is made in the dashboard under **Settings → API keys**. It acts as one workspace and works in that workspace only. Most endpoints in this reference take it.
* A **partner key** (`wgt_prt_`) is made in the same place, in your partner's home workspace, and is for platforms that run Widgetic for their own customers. The endpoints for managed users, editor sessions, credits, billing and notifications need it. An endpoint that needs one says so at the top of its page.

Keep keys on your server. A browser never holds one: to let a customer's browser edit, make an [editor session](https://docs.widgetic.com/docs/partners/editor-sessions.md) on your server and send its short-lived token instead.

[API keys](https://docs.widgetic.com/docs/api-keys.md) lists what each kind of key can call and shows how to tell which one you hold. Read [Authentication](https://docs.widgetic.com/docs/authentication.md) for scopes, plans and how to limit a key, and [Partner overview](https://docs.widgetic.com/docs/partners/overview.md#partner-api-key) if you are a partner. `GET /tokens/validate` tells you which account and workspace a key belongs to.

## Requests and responses

Send `Content-Type: application/json` with a request body, and ask for `application/json` back. Every answer has the same envelope.

```json Success theme={"theme":"css-variables"}
{
  "success": true,
  "data": { "id": "6f1e2d3c-4b5a-4c0e-9a51-7d5f3c1a2b64", "name": "Launch countdown" }
}
```

```json Error theme={"theme":"css-variables"}
{
  "success": false,
  "error": {
    "code": "AUTH_TOKEN_EXPIRED",
    "message": "The authentication token has expired",
    "correlationId": "req_123e4567-e89b-12d3-a456-426614174000"
  }
}
```

Branch on `error.code`, which is meant for programs, and not on `error.message`, which is meant for people. Quote `error.correlationId` when you write to [the support team](https://docs.widgetic.com/docs/introduction.md#need-help). The full list of codes is in [Errors](https://docs.widgetic.com/api-reference/errors.md).

## Response codes

| Code | Meaning |
| - | - |
| `200`, `201`, `204` | The request worked: it returned data, created something, or had nothing to return |
| `400` | The request was malformed, or a required header such as `Idempotency-Key` is missing |
| `401` | The key is missing, invalid or expired |
| `402` | There are not enough credits for the request |
| `403` | The key may not do this, or the workspace has no plan |
| `404` | The thing does not exist, or it is not yours |
| `409`, `422` | The request conflicts with the state of the thing, or breaks a rule of the product |
| `429` | You sent too many requests: wait for `Retry-After` seconds |
| `5xx` | Something went wrong on our side: retry after a short wait |

## Pagination

Lists take `page` (from 1) and `size` (20 by default, at most 100), and answer with a `meta` object that holds `total`, `hasNextPage` and `hasPreviousPage`. `GET /widgets` returns the whole list when you pass neither `page` nor `size`, so always page it. See [Pagination](https://docs.widgetic.com/api-reference/pagination.md).

## Idempotency

Creating calls take an `Idempotency-Key` header, so you can retry after a timeout without making the thing twice. The reference lists the header on every call that takes it, and a call that requires it answers `400` without it. Send the same key when you retry. See [Idempotency](https://docs.widgetic.com/docs/reference/idempotency.md).

## Rate limits

A key is counted over 15-minute windows, on its own: about 3,000 requests for a key and 1,000,000 for a partner key. Read the allowance that applies to a call in its `RateLimit-Limit` header, and wait `Retry-After` seconds after a `429`. See [Rate limits](https://docs.widgetic.com/docs/reference/rate-limits.md) and [Usage limits](https://docs.widgetic.com/api-reference/usage-limits.md).

> [!TIP]
>
> **Do not poll for changes.** A partner account can have signed webhooks sent to its server when an invoice is paid, credits run low or a customer publishes a widget, and polling counts against your rate limit. See [Webhooks and events](https://docs.widgetic.com/docs/webhooks/overview.md).

## SDKs, CLI and specification

> [card] [SDKs](https://docs.widgetic.com/docs/sdks/overview.md)
>
> Typed clients for TypeScript, Python, Go, Java, C#, Ruby, PHP and Bash.

> [card] [CLI](https://docs.widgetic.com/docs/cli/getting-started.md)
>
> Every REST call from a terminal, a script or CI.

> [card] [OpenAPI](https://raw.githubusercontent.com/widgetic/docs/main/openapi/widgetic-api-public.json)
>
> The specification this reference is built from, as JSON.

## Ask the assistant

Every page has a menu at the top right: copy the page as Markdown, or open it in ChatGPT, Claude or Cursor with a question about it. The whole site is also available as [`llms.txt`](https://docs.widgetic.com/llms.txt) for your own tools.

Need help? Write to [the support team](https://docs.widgetic.com/docs/introduction.md#need-help).


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