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

# Agency API

> Manage your sub-accounts, their plans and add-ons, and your webhooks from your own code with an agency API key.

The Agency API lets your own code do what you do in the Agency Dashboard: create customers, give them plans and add-ons, suspend and restore them, and manage your webhooks. It is included when your whitelabel plan includes the Partner API.

## Create a key

**1. Open the API page**

In the Agency Dashboard, open **API** and click **New key**.

**2. Name it**

Give the key a **Name** that says where it is used, such as "CRM integration", and click **Create**.

**3. Copy it now**

The key is shown once. Copy it into your secret manager straight away.

![The API page with the base URL and two keys](https://mintcdn.com/onlysocial/_kl1T5u7Oy1U4YMh/images/whitelabel/agency/api-keys.jpg?fit=max\&auto=format\&n=_kl1T5u7Oy1U4YMh\&q=85\&s=9dd037e008b99226e43ba906b7accd26)

The page lists each key by name, with the start of the key, when it was created and when it was last used. **Revoke** stops a key at once. Create one key per system, so you can revoke one without stopping the others.

## Make a request

Use the **Base URL** shown on the API page. It is on your own domain once your [domain is connected](https://api.onlysocial.io/whitelabel/domains.md), for example `https://app.youragency.com/api/agency/v1`.

Send the key as a Bearer token, or in the `X-API-KEY` header:

```bash theme={null}
curl https://app.youragency.com/api/agency/v1/workspaces \
  -H "Authorization: Bearer YOUR_AGENCY_API_KEY" \
  -H "Accept: application/json"
```

Every request acts for your agency only. A key reaches your own customers and plans, never another agency's, and never your own workspace. Requests and responses are JSON.

Each key may make 120 requests a minute.

## Endpoints

Paths are relative to the base URL. `{workspace}` is a sub-account's `uuid`.

### Plans

| Method | Path | What it does |
| - | - | - |
| `GET` | `/plans` | Lists your plans and add-ons, with their `uuid`, `name`, `type` (`base` or `addon`), `addon_kind`, `addon_quantity`, `currency`, `monthly_amount` and `yearly_amount`. Use it to find the `uuid` to send below. |

### Sub-accounts

| Method | Path | What it does |
| - | - | - |
| `GET` | `/workspaces` | Lists your sub-accounts, newest first. Optional query: `search` (part of the name) and `per_page` (1 to 100, default 25). The `meta` object has `current_page`, `last_page`, `per_page` and `total`. |
| `POST` | `/workspaces` | Creates a sub-account and its owner. Send `name` (the owner's name), `business_name` (the workspace name), `email` (must not already have a login), `password` (at least 8 characters) and, optionally, `plan` (a base plan's `uuid`). Answers `201` with the sub-account and its `owner`. |
| `GET` | `/workspaces/{workspace}` | One sub-account, with its plan, add-ons and limits. |
| `PATCH` | `/workspaces/{workspace}` | Renames it. Send `name`. |
| `POST` | `/workspaces/{workspace}/suspend` | Suspends it. |
| `POST` | `/workspaces/{workspace}/restore` | Restores it. |

A sub-account looks like this:

```json theme={null}
{
  "data": {
    "uuid": "11111111-1111-1111-1111-111111111111",
    "name": "Harbour Bakery",
    "status": "active",
    "plan": { "uuid": "22222222-2222-2222-2222-222222222222", "name": "Starter" },
    "created_at": "2026-11-29T10:15:00+00:00",
    "addons": [
      { "uuid": "33333333-3333-3333-3333-333333333333", "name": "Extra 1,000 contacts", "kind": "extra_contacts", "quantity": 1, "granted_total": 1000 }
    ]
  }
}
```

`status` is `active` or `suspended`. `plan` is `null` when the customer has no plan.

### Plans and add-ons of a sub-account

| Method | Path | What it does |
| - | - | - |
| `GET` | `/workspaces/{workspace}/subscription` | The sub-account's status, plan, add-ons and limits. |
| `PUT` | `/workspaces/{workspace}/subscription` | Gives it a plan, as **Assign plan** does in the dashboard. Send `plan` (the `uuid` of an enabled base plan). |
| `POST` | `/workspaces/{workspace}/addons` | Grants an add-on. Send `plan` (the add-on's `uuid`) and, optionally, `quantity` (1 to 1000, default 1). |
| `DELETE` | `/workspaces/{workspace}/addons/{addon}` | Takes an add-on back. `{addon}` is the `uuid` from the sub-account's `addons` list. |

Assigning a plan or an add-on here works like the dashboard: no payment goes through Stripe. See [Manage customers](https://api.onlysocial.io/whitelabel/customers.md).

### Webhooks

| Method | Path | What it does |
| - | - | - |
| `GET` | `/webhooks/events` | The event names you can subscribe to. |
| `GET` | `/webhooks` | Lists your webhook endpoints. |
| `POST` | `/webhooks` | Adds one. Send `name`, `url`, `events` (an array of event names) and, optionally, `active` (default `true`). The answer includes the signing `secret`, once. |
| `GET` | `/webhooks/{webhook}` | One endpoint. |
| `PATCH` | `/webhooks/{webhook}` | Changes it. Send `name`, `url` and `events`, and optionally `active`. |
| `DELETE` | `/webhooks/{webhook}` | Removes it. |
| `POST` | `/webhooks/{webhook}/rotate-secret` | Replaces the signing secret and returns the new one. The old one stops working at once. |
| `POST` | `/webhooks/{webhook}/test` | Sends a test event. |

The events and the delivery format are described in [Integrations and webhooks](https://api.onlysocial.io/whitelabel/integrations.md#webhooks).

## Errors

Errors answer with a JSON `message`:

| Status | When |
| - | - |
| `401` | The key is missing, or it is not a valid key. |
| `403` | Your agency is not active, or your plan no longer includes API access. Keys made earlier work again once your plan includes it. |
| `404` | The sub-account, add-on or webhook is not one of yours. |
| `422` | The request is not valid, for example a plan that is not yours, an email that already has a login, or no sub-accounts left in your allowance. The answer names the problem. |
| `429` | More than 120 requests in a minute with this key. Wait and try again. |


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