# API keys, webhooks & MCP

> Automate posting with pb_live_ API keys (Pro+), HMAC-SHA256-signed webhooks on post events, and a built-in MCP endpoint that lets Claude or any MCP client manage your posts.

Everything the Post UI does, the API does — create posts, schedule them, list results — so you can wire Studiobase into your own pipelines, or hand the keys to an AI agent over MCP.

> **PLAN GATE:** API keys require the **Pro** plan or higher.

## API keys

1. **Create a key** — Go to **Post → API Keys** and generate one. Keys look like `pb_live_…`.
2. **Copy it immediately** — The secret is shown **once**. Studiobase stores only a SHA-256 hash — lose it and you'll create a new key.
3. **Authenticate with Bearer** — Send the key as an `Authorization: Bearer` header on every request. It authenticates the whole social API and the MCP endpoint.

```bash
curl -X POST https://studio.frsh.work/social/posts \
  -H "Authorization: Bearer pb_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "caption": "Shipped a new feature today.",
    "scheduledAt": "2026-07-10T15:00:00Z",
    "accountIds": ["acc_123", "acc_456"]
  }'
```

## Webhooks

Set your endpoint URL in [Posting settings](/docs/social/settings). After the auto-poster publishes a post, Studiobase delivers an event with the per-target results. Every delivery is signed with **HMAC-SHA256** in the `X-Signature` header — recompute the digest over the raw body with your webhook secret and compare before trusting the payload.

## MCP: post from Claude

Studiobase exposes an **MCP endpoint** at `POST /social/mcp` (JSON-RPC: `initialize`, `tools/list`, `tools/call`) with **7 tools** for managing posts — create, schedule, list, and more. Add it to Claude or any MCP client using the connect card in [Posting settings](/docs/social/settings), authenticated with the same Bearer key.

```json
{
  "mcpServers": {
    "studiobase": {
      "url": "https://studio.frsh.work/social/mcp",
      "headers": {
        "Authorization": "Bearer pb_live_YOUR_KEY"
      }
    }
  }
}
```

> **TIP:** With MCP connected, "schedule my three drafts for Tuesday, Thursday, and Saturday at 9am" is a sentence to your assistant, not fifteen clicks.

## Security notes

- Treat `pb_live_` keys like passwords — server-side env vars only, never in client code or repos.
- Rotate by creating a new key and deleting the old; deletion revokes it immediately.
- Always verify the `X-Signature` header before acting on a webhook.

## What's next

- [Posting settings](/docs/social/settings) — Webhook URL and the MCP connect card.
- [Create a post](/docs/social/create-post) — What the API automates, in the UI.
