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

# Authenticate with an API key

> Make a key, send it as a Bearer token, and give it only the permissions it needs. AI clients can connect with OAuth instead.

Every request to the REST API needs an API key, sent as a Bearer token, except the two that give a person their first key ([agent sign-up](/docs/guides/agent-signup.md)). The MCP server takes the same key, or an OAuth connector instead. A key works on the REST API (`/api/v1`), the MCP server and [OAuth delegation](/docs/oauth-delegation.md). The PostSyncer app's own routes answer it `403`, with `"error": "api_key_not_allowed"`.

## Make a key

Only a workspace owner can make keys: [Settings → API](https://app.postsyncer.com/settings/api) isn't shown to other roles. It works on every plan, Free included.

1. Open [Settings → API](https://app.postsyncer.com/settings/api) and click **New key**.
2. Name it. Under **Start from**, pick what the key may do (see [Presets](#presets)). **Everything** is picked to begin with.
3. Optionally set an expiry date. After it, the key answers `401`.
4. Create the key and copy it. It's shown once.

Edit a key's name, permissions or expiry date there at any time, or delete it. A deleted key answers `401` from then on.

An AI agent in a terminal can also get a key for a person, with a code emailed to them: see [Sign up from an AI agent](/docs/guides/agent-signup.md). Its two routes, `POST /agent-signup/code` and `POST /agent-signup/verify`, are the only ones that need no key. The key has every permission, is named after the agent, and shows in Settings → API like any other.

## Send the key

Send the key on every request as `Authorization: Bearer YOUR_API_KEY`. The base URL is `https://postsyncer.com/api/v1`. [Upload a file](/docs/api-reference/media/upload-file.md) is the one exception: it uses `https://upload.postsyncer.com/api/v1`, with the same key.

```bash curl theme={null}
curl https://postsyncer.com/api/v1/workspaces \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```javascript JavaScript theme={null}
const response = await fetch('https://postsyncer.com/api/v1/workspaces', {
  headers: { Authorization: 'Bearer YOUR_API_KEY' },
});

console.log(response.status, await response.json());
```

```python Python theme={null}
import requests

response = requests.get(
    "https://postsyncer.com/api/v1/workspaces",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
)

print(response.status_code, response.json())
```

```php PHP theme={null}
<?php

$ch = curl_init('https://postsyncer.com/api/v1/workspaces');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_API_KEY']);

$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $status, ' ', $body, PHP_EOL;
```

Keep the key on your server. Anyone who has it can act as you.

## Who a key acts as

A key acts as the owner who made it. It reaches every workspace that person owns or joined, and in each one it can do only what their role there allows. A request needs both: the key's [permission](#permissions) and the person's role.

When the role doesn't allow it, the answer is `403`:

```json 403 theme={null}
{
  "message": "Your role in the workspace \"Halden Coffee\" does not allow you to delete posts. Ask the workspace owner or a manager to do it, or to change your role."
}
```

The plan that applies is the workspace owner's, not the key's: a key used in someone else's workspace gets that owner's [plan limits](/docs/plan-limits.md).

## Permissions

Every permission is a `resource:action` pair, and every endpoint needs one. An MCP tool needs the permission of the endpoint it mirrors: `list-posts` needs `posts:read`, `create-post` needs `posts:create`. Without it, the answer is `403` and nothing is done:

```json 403 theme={null}
{
  "message": "This API key does not have the \"posts:delete\" permission. Edit the key in PostSyncer under Settings → API to grant it."
}
```

Paths are relative to `https://postsyncer.com/api/v1`.

| Permission | What the key can do |
| - | - |
| `workspaces:read` | `GET /workspaces`, `GET /workspaces/{id}/settings` |
| `workspaces:create` | `POST /workspaces` |
| `workspaces:update` | `PATCH /workspaces/{id}/settings` |
| `workspaces:delete` | `DELETE /workspaces/{id}` |
| `brand:read` | `GET /brand` |
| `brand:update` | `PATCH /brand`, `POST /brand/suggestion/accept`, `POST /brand/suggestion/dismiss` |
| `accounts:read` | `GET /accounts`, `GET /accounts/{id}`, `GET /accounts/{id}/linkedin/mentions`, `GET /accounts/{id}/pinterest/boards/{board}/sections` |
| `accounts:create` | `POST /accounts/connect-links`, and starting [OAuth delegation](/docs/oauth-delegation.md) (`POST https://postsyncer.com/api/oauth/delegate/sessions`, outside `/api/v1`) |
| `accounts:delete` | `DELETE /accounts/{id}` |
| `posts:read` | `GET /posts`, `GET /posts/{id}`, `GET /posts/by-url/{post_url}`, `GET /posts/by-platform-post-id/{platform_post_id}`, `GET /posts/{id}/history`, `POST /posts/analyze-twitter` |
| `posts:create` | `POST /posts` with `"schedule_type": "draft"`. Alone, it can only save drafts. |
| `posts:update` | `PUT /posts/{id}` with `"schedule_type": "draft"`, and the post settings `PATCH /posts/{id}/auto-plug`, `PATCH /posts/{id}/comment-moderation` and `PATCH /posts/{id}/contact-collection`. With `posts:schedule`, also `POST /accounts/{id}/put-back-posts`. |
| `posts:schedule` | `"schedule_type": "schedule"` on create and update. An update that leaves `schedule_type` out keeps a scheduled post, or one waiting for approval, on the schedule, so it needs this too. `POST /accounts/{id}/put-back-posts` needs it as well. |
| `posts:publish` | `"schedule_type": "publish_now"` on create and update, and `POST /posts/{id}/retry`. |
| `posts:approve` | `POST /posts/{id}/approve`. With this permission alone, a key can approve a post that's waiting for approval with `type` `publish` (it goes out now), `schedule` or `draft`. It needs neither `posts:publish` nor `posts:schedule` for that. |
| `posts:delete` | `DELETE /posts/{id}` |
| `media:read` | `GET /media`, `GET /media/{id}`, `POST /media/download/url`, `POST /media/analyze-video`, `GET /media/upload-links/{id}` |
| `media:create` | `POST /media/upload/file`, `POST /media/upload/url`, `POST /media/upload-links` |
| `media:delete` | `DELETE /media/{id}` |
| `folders:read` | `GET /folders`, `GET /folders/{id}` |
| `folders:create` | `POST /folders` |
| `folders:update` | `PUT /folders/{id}` |
| `folders:delete` | `DELETE /folders/{id}` |
| `comments:read` | `GET /comments`, `GET /comments/{id}`, `POST /comments/sync`, `GET /posts/{id}/people`, `GET /posts/{id}/comments/summary`, and for Google reviews `GET /reviews`, `GET /reviews/{id}`, `POST /reviews/sync` |
| `comments:create` | `POST /comments` |
| `comments:update` | `PUT /comments/{id}`, `PATCH /comments/{id}/hide`, and `PUT /reviews/{id}/reply` |
| `comments:delete` | `DELETE /comments/{id}`, and `DELETE /reviews/{id}/reply` |
| `analytics:read` | `GET /analytics`, `GET /analytics/workspaces/{id}`, `GET /analytics/accounts/{id}`, `GET /analytics/posts`, `GET /analytics/posts/{id}`, `POST /analytics/posts/{id}/sync` |
| `campaigns:read` | `GET /campaigns`, `GET /campaigns/{id}` |
| `campaigns:create` | `POST /campaigns` |
| `campaigns:update` | `PUT /campaigns/{id}` |
| `campaigns:delete` | `DELETE /campaigns/{id}` |
| `labels:read` | `GET /labels`, `GET /labels/{id}` |
| `labels:create` | `POST /labels` |
| `labels:update` | `PUT /labels/{id}` |
| `labels:delete` | `DELETE /labels/{id}` |
| `snippets:read` | `GET /snippets` |
| `snippets:create` | `POST /snippets` |
| `snippets:update` | `PUT /snippets/{id}` |
| `snippets:delete` | `DELETE /snippets/{id}` |
| `webhooks:read` | `GET /webhooks`, `GET /webhooks/{id}`, `GET /webhooks/{id}/deliveries` |
| `webhooks:create` | `POST /webhooks` |
| `webhooks:update` | `PUT /webhooks/{id}`, `POST /webhooks/{id}/test` |
| `webhooks:delete` | `DELETE /webhooks/{id}` |
| `team:read` | `GET /team-members` |
| `team:create` | `POST /team-members` |
| `team:update` | `PUT /team-members/{id}` |
| `team:delete` | `DELETE /team-members/{id}` |
| `notifications:read` | `GET /notifications`, `GET /notification-settings`, `GET /notification-settings/slack/{installation}/channels` |
| `notifications:create` | `POST /notification-settings/connect-links`, `POST /notification-destinations` |
| `notifications:update` | `POST /notifications/read`, `PUT /notification-settings`, `POST /notification-destinations/{id}/test` |
| `notifications:delete` | `DELETE /notification-destinations/{id}` |
| `blog_sources:read` | `GET /blog-sources` |
| `blog_sources:create` | `POST /blog-sources` |
| `blog_sources:update` | `PUT /blog-sources/{id}` |
| `blog_sources:delete` | `DELETE /blog-sources/{id}` |
| `products:read` | `GET /products` |
| `products:create` | `POST /products` |
| `products:update` | `PUT /products/{id}` |
| `products:delete` | `DELETE /products/{id}` |
| `contacts:read` | `GET /contacts`, `GET /contacts/{id}` |
| `contacts:update` | `PATCH /contacts/{id}`, `PUT /contact-lists` |
| `contacts:delete` | `DELETE /contacts/{id}`, `DELETE /contacts/{id}/notes/{note_id}`, `DELETE /contact-lists/{id}` |
| `profile:read` | `GET /profile` |
| `profile:update` | `PATCH /profile` |
| `api_keys:read` | `GET /api-keys` |
| `api_keys:delete` | `DELETE /api-keys/{id}` |
| `billing:read` | `GET /billing` |
| `billing:create` | `POST /billing/links` |

Google reviews use the comments permissions.

Two `read` permissions can spend AI credits on paid plans: `POST /posts/analyze-twitter` (`posts:read`) and `POST /media/analyze-video` (`media:read`). On Free, both answer `403` with `"limit": "ai"`.

### Presets

**Start from** ticks permissions for you. You can change them on the next step.

| Preset | Permissions |
| - | - |
| **Everything** | Every permission, and any added later. This is the key's starting choice. |
| **An agent that drafts** | `workspaces:read`, `brand:read`, `accounts:read`, `posts:read`, `posts:create`, `media:read`, `media:create`, `folders:read`, `labels:read`, `campaigns:read`, `snippets:read`. It writes drafts in the brand's voice, with media. Nothing goes out until a person schedules it. |
| **Reports** | Every `read` permission. |
| **Pick myself** | An access level for each area: **No access**, **Read**, **Read & write**, **Full access**. Posts also offer **Drafts only** (`posts:read`, `posts:create`) and **Schedule & publish** (every posts permission except `posts:approve` and `posts:delete`). |

> [!TIP]
>
> For an AI agent, start from **An agent that drafts**. Without `posts:schedule`, `posts:publish` and `posts:approve` it can't send anything to a network, and without `posts:update` and `posts:delete` it can't change or remove a post you already scheduled.

### Older keys

Keys keep the permissions they were made with.

* A key made with **Everything** has `*`: every permission, including ones added later.
* Keys made before permissions were split into actions hold one permission per resource. Each still works as before:

| Older permission | Covers |
| - | - |
| `workspaces` | `workspaces:read` |
| `accounts` | every `accounts:` permission |
| `posts` | every `posts:`, `media:`, `folders:`, `comments:` and `analytics:` permission |
| `campaigns` | every `campaigns:` permission |
| `labels` | every `labels:` permission |

No older permission covers `brand`, `snippets` or `webhooks`. To use those, edit the key and pick them.

## Connect an AI client with OAuth

Claude, ChatGPT and other MCP clients can connect to `https://postsyncer.com/mcp` as a connector instead of using a key: you sign in to PostSyncer and approve it once. [Client setup](/docs/mcp/integrating-clients.md) has the steps.

| | API key | OAuth connector |
| - | - | - |
| Works on | The REST API and the MCP server | The MCP server only |
| Made by | A workspace owner, in Settings → API | Anyone with a PostSyncer login, by approving the client |
| Acts as | The owner who made it | The person who approved it |
| Can do | The permissions picked for the key, within that person's role | Everything that person's role allows. It has no `resource:action` permissions. |
| Rate limit | The person's 60 requests a minute | The same 60: [one count per person](/docs/rate-limits.md) |
| Ends | When you delete it, or on its expiry date | When its tokens run out (see below) |

PostSyncer has no setting that ends a connector's access. Removing the connector in your client stops that client using it, but the tokens it was given stay valid until they run out: the access token after 15 days, the refresh token after 30. Each time the client renews, it gets new ones. To end a connector's access sooner, write to [support@postsyncer.com](mailto:support@postsyncer.com).

## When a request is refused

| Status | Body | Why |
| - | - | - |
| `401` | `{"message": "Unauthenticated."}` | No key, a wrong or deleted key, or one past its expiry date. |
| `403` | `{"message": "This API key does not have the \"…\" permission. …"}` | The key lacks the endpoint's [permission](#permissions). |
| `403` | `{"message": "Your role in the workspace \"…\" does not allow you to …"}` | The person's role in that workspace doesn't allow it. |
| `403` | `{"message": "Your account is inactive."}` | The key's owner can't use PostSyncer right now. Write to support. |
| `403` | `{"message": "API keys don't work on the PostSyncer app's own routes. Use the API (/api/v1) or the MCP server.", "error": "api_key_not_allowed"}` | The key was sent to one of the PostSyncer app's own routes. |

[Error handling](/docs/essentials/error-handling.md) lists every other answer.

## Related

> [card] [Quickstart](/docs/quickstart.md)
>
> Make a key and schedule your first post.

> [card] [Test safely](/docs/test-safely.md)
>
> A draft-only key, and what can't be undone.


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