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

> Organisation keys and partner keys, which one you need, what each can call, how much a key may do (full access, content, read only or custom), and how to tell which one you hold

Widgetic has two kinds of API key. You send both the same way, as `Authorization: Bearer <key>`, but they open different parts of the API. **The workspace decides which kind you get**: a key made in a partner's workspace is a partner key, and a key made in any other workspace is an organisation key. There is nothing to choose when you make one.

> [card] Organisation key
>
> Works for the content of **one workspace**: widgets, compositions, uploads, credits and everything else an account does for itself. It starts with `wdg_org_` and you make it in the dashboard. It is also called a workspace key.

> [card] Partner key
>
> Does all of that, and also the calls a platform needs to run Widgetic for its own customers: managed users, editor sessions, your contract, storage and notifications. It starts with `wgt_prt_` and you make it in your partner's home workspace. For partners only.

## Which key do I need?

| You are | Use |
| - | - |
| Building on your own workspace: scripts, integrations, automations | An organisation key |
| Running a platform where your own customers make widgets (a [partner](https://docs.widgetic.com/docs/partners/overview.md)) | A partner key |
| Showing Widgetic's editors to one of your customers in your page | A partner key on your server, which makes an [editor session](https://docs.widgetic.com/docs/partners/editor-sessions.md). The browser holds only that short-lived token, never a key |
| Showing a published widget on a page | No key: the [embed routes](https://docs.widgetic.com/docs/api/embedding.md) take none |

## What makes a key a partner key

A key is a partner key when it was made in your **partner's home workspace**, the workspace of your partner account. It starts with `wgt_prt_` and it acts as your partner.

That workspace is made for you when Widgetic invites you, and it is the only workspace your partner account has: you do not add others, and nobody can be invited into it. You do not choose the kind of a key. You make every key the same way, under **Settings → API keys** (see [Make a key](#make-a-key)), and the workspace decides: your partner's home workspace makes partner keys, and every other workspace makes organisation keys (`wdg_org_`). You make each partner key yourself, one for each integration, with only the access that integration needs. Widgetic does not make or send you a key: you sign in with the shared mailbox Widgetic invited.

An organisation key acts as a customer, so the partner endpoints refuse it.

## The two keys side by side

| | Organisation key | Partner key |
| - | - | - |
| Starts with | `wdg_org_` | `wgt_prt_` |
| Acts as | The workspace it was made in, and no other | Your partner, from your partner's home workspace |
| Made by | The owner of the workspace, in the dashboard under **Settings → API keys** | The owner of your partner's home workspace, in the same place. Widgetic does not make or send a partner key |
| Calls it can make | Every call that takes either key | Those, and the calls that need a partner key |
| What it needs | A paid plan on its workspace | An account in force. A partner pays by the invoices of its contract and has no plan |
| Request allowance | Counted on its own, by plan | A ceiling of 1,000,000 requests per 15 minutes (see [Rate limits](https://docs.widgetic.com/docs/reference/rate-limits.md)) |
| When the account is stopped | The key is switched off, not deleted, until the workspace has a plan again | Calls that make something or start work are refused. Reading, paying, your storage, your notifications and your keys stay open (see [Account Status](https://docs.widgetic.com/docs/partners/account-status.md)) |
| When the partnership ends | Not applicable | The key keeps reading, and stops writing, from the day after the last day, for 60 days. Then every call is refused. Nothing is deleted, so the key works again if the partnership is reopened (see [Ending a Partnership](https://docs.widgetic.com/docs/partners/ending-a-partnership.md)) |

## What each key can call

Every endpoint in the [API reference](https://docs.widgetic.com/api-reference/introduction.md) has an access level. These are the calls of each group that take an organisation key, and the ones that need a partner key:

| Group of the API | Calls | An organisation key can make | A partner key can make |
| :- | -: | :- | :- |
| Widgets | 6 | 4 of 6 | All |
| Compositions | 41 | 39 of 41 | All |
| Canvases | 5 | All | All |
| Workflows | 21 | 19 of 21 | All |
| A/B Testing | 15 | All | All |
| Translations | 9 | All | All |
| Uploads | 7 | 5 of 7 | All |
| Brand Kit | 8 | All | All |
| Tokens | 1 | All | All |
| Users | 4 | All | All |
| Credits | 2 | All | All |
| Organizations | 11 | All | All |
| Operations | 1 | All | All |
| Partners | 41 | None | All |
| Managed Users | 18 | None | All |
| Invoices | 1 | None | All |
| Entitlements | 2 | None | All |
| Public Embed | 10 | No key needed | No key needed |

In all, 10 calls take no key, 123 take an organisation key or a partner key, and 70 need a partner key.

An endpoint that needs a partner key carries a **Partner key** label in the sidebar of the API reference, and an endpoint that takes no key carries **No key**. Every other endpoint takes either key.

The table follows the access level of each endpoint. Other rules still apply on top of it: how much the key may do (see [Choose how much a key may do](#choose-how-much-a-key-may-do)), the plan, and the few calls that need a person signed in on widgetic.com, such as making a key.

## Choose how much a key may do

Whichever kind it is, a key also has an **access**, which you choose when you make it. Give a key only what its application needs: a leaked key can then do no more than that. The dialog **Create API key** in the dashboard offers four choices:

| Choice | What the key may do | Use it for |
| - | - | - |
| **Full access** | Everything the workspace can do, including managing its keys. A key can never make a new key. | Your own servers and scripts. The [MCP server](https://docs.widgetic.com/docs/agents/authentication.md#api-keys) and `widgetic mcp` need it |
| **Content** | Builds and manages widgets and compositions, and runs the AI. No billing, no people, no partner settings. | A build server, a publishing job, an integration that makes widgets |
| **Read only** | Looks at everything the workspace holds and changes nothing. | Reports, monitoring and dashboards of your own |
| **Custom** | You choose, area by area: widgets and compositions, billing and account (and, in a partner's home workspace, the partner area). Each is set to nothing, read, or read and change, and AI generation is on or off. | A key that needs a mix, such as the one your server uses to make [editor sessions](https://docs.widgetic.com/docs/partners/editor-sessions.md#make-a-session) |

* **The access is fixed when the key is made.** To give a key more or less, make a new one and delete the old one: see [Make a key](#make-a-key).
* **A call outside the access is refused** with `403` and the code `API_KEY_SCOPE_MISSING`. `error.details.missingScopes` lists what a new key needs.
* **Access only narrows.** A limited key still needs what its kind needs: the role of a partner key, the plan of the workspace.
* **The list of keys shows the access of each key**, as a tag between its name and the date it was made: **Full access**, **Content**, **Read only** or **Custom**. Hover over the tag to see what a key may do.

The scopes behind each choice, and what each one lets a key do, are in [Limit what a key can do](https://docs.widgetic.com/docs/authentication.md#limit-what-a-key-can-do).

## Check which key you hold

Two calls tell you. `GET /tokens/validate` says what the key is, and `data.workspace` names the workspace it works in. `GET /partners/mine` answers only a key that acts as a partner: an organisation key is refused with `403`.

```bash cURL theme={"theme":"css-variables"}
# What the key is, and the workspace it works in
curl -sS "https://api.widgetic.com/v1/tokens/validate" \
  -H "Authorization: Bearer $WIDGETIC_API_KEY"

# 200 for a partner key, 403 for an organisation key
curl -sS -o /dev/null -w "%{http_code}\n" "https://api.widgetic.com/v1/partners/mine" \
  -H "Authorization: Bearer $WIDGETIC_API_KEY"
```

```typescript TypeScript theme={"theme":"css-variables"}
import { PartnersApi, ResponseError, TokensApi } from '@widgetic/api-sdk-ts';

const apiKey = process.env.WIDGETIC_API_KEY!;

// What the key is, and the workspace it works in
const { data: token } = await new TokensApi(apiKey).validateToken();
console.log(`Workspace: ${token.workspace?.name ?? 'unnamed'}`);

// Does it act as a partner? Only a partner key is answered
try {
  const { data: mine } = await new PartnersApi(apiKey).getMyPartners();
  console.log(`Partner key. The account is ${mine.standing}`);
} catch (error) {
  if (error instanceof ResponseError && error.response.status === 403) {
    console.log('Organisation key: the partner endpoints are closed to it');
  } else {
    throw error;
  }
}
```

## When a call is refused

Branch on `error.code` (see [Errors](https://docs.widgetic.com/api-reference/errors.md)). These are the refusals that come from the key itself:

* **`401` `AUTH_TOKEN_INVALID`**: There is no key, or it is not one of ours: mistyped, deleted or switched off. Check the key, or make a new one.
* **`403` `AUTHZ_INSUFFICIENT_PERMISSIONS`**: The endpoint needs a partner key and the key is an organisation key. Use a partner key: the owner of your partner's workspace makes one under **Settings → API keys**.
* **`403` `API_KEY_SCOPE_MISSING`**: The key was limited when it was made, and this call is outside the limit. Make a new key that includes the scope (`error.details.missingScopes` lists what it needs).
* **`403` `AUTHZ_PLAN_RESTRICTION` or `WORKSPACE_LOCKED`**: An organisation key's workspace is in its free trial, has no plan, or is overdue. Choose a plan or update billing, and the same key works again (see [Keys and your workspace plan](https://docs.widgetic.com/docs/authentication.md#keys-and-your-workspace-plan)).
* **`403` `PARTNER_INACTIVE`, `PARTNER_SUSPENDED` or `PARTNER_PAYMENT_ARREARS`**: A partner key whose account is not in force, on a call that makes something or starts work. See [Account Status](https://docs.widgetic.com/docs/partners/account-status.md).
* **`403` `PARTNER_WINDING_DOWN` or `PARTNER_CLOSED`**: The partnership has ended. During the 60-day wind-down a partner key can read and export but not make or change anything (`PARTNER_WINDING_DOWN`); after it every call is refused (`PARTNER_CLOSED`). See [Ending a Partnership](https://docs.widgetic.com/docs/partners/ending-a-partnership.md).
* **`503` `SERVICE_UNAVAILABLE`**: Widgetic could not check just now whether the key's workspace is a partner's home workspace. Try the same call again in a moment.

## Make a key

**1. Sign in and open the workspace**

Sign in on widgetic.com and open the workspace the key is for. For a partner key, sign in with the owner login of your partner (the shared mailbox Widgetic sent the invitation to) and open your partner's workspace, the only one it has.

**2. Make the key**

Open [**Settings → API keys**](https://widgetic.com/workspaces?settings=api-keys) (the owner of a workspace opens that page; the link opens the workspace you used last, or your first) and select **Create key**. Name the key after the integration it serves, such as "Checkout server" or "Support tool", so that you know which one to rotate or delete later, and choose what it may do: Full access, Content, Read only or Custom (see [Choose how much a key may do](#choose-how-much-a-key-may-do)). There is no kind to choose: in your partner's home workspace the key is a partner key, and anywhere else it is an organisation key. A key made here works for ten years.

**3. Store the secret**

The secret is shown once. Keep it in an environment variable or a secrets manager, never in client code or in git.

To rotate a key, make the new one, switch your servers over, then delete the old one. A key that is deleted or switched off is refused at once by the server that took the request, and within a minute by the others. The limit of a key cannot change once it is made, so widening or narrowing it is a rotation too.

> [!WARNING]
>
> Only a person signed in on widgetic.com can make a key. A request made with an API key is refused, so a leaked key cannot make a second one that outlives its revocation. If a key leaks, delete it in the dashboard and make a new one there.

## Next steps

> [card] [Authentication](https://docs.widgetic.com/docs/authentication.md)
>
> Scopes, plans and how to limit a key

> [card] [Security](https://docs.widgetic.com/resources/security.md)
>
> Keep keys safe, and rotate or delete them

> [card] [Partner overview](https://docs.widgetic.com/docs/partners/overview.md)
>
> What a partner can build, and how to get started

> [card] [Partner integration guide](https://docs.superhuman.com/d/_do4kTYR8IRR/Widgetic-Partner-integration-guide_suGRjp1a)
>
> The step-by-step guide for partners, with a test plan and go-live checklist


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