# Quickstart: your first Beplan API call

Make a personal API token in Beplan, check who it acts for, then create a post and schedule it, with curl, TypeScript or Python.

## 1. Make a token

In Beplan, open your account menu, then **Developers**, then **New token**:

1. **Name** it after what will use it ("Weekly planner script").
2. **Expiry**: 30, 90 or 365 days, or never. An organization can cap how long its members' tokens live; a token that outlives the cap stops working there.
3. **Where**: the organizations it may touch, and in each one either all the workspaces you see (including ones added later) or a list you pick.
4. **What it can do**: a preset, or the scopes you tick. For this quickstart, the token needs [`organization:read`](https://beplan.io/docs/oauth/scopes/#scope-organization-read), [`accounts:read`](https://beplan.io/docs/oauth/scopes/#scope-accounts-read), [`posts:read`](https://beplan.io/docs/oauth/scopes/#scope-posts-read), [`posts:write`](https://beplan.io/docs/oauth/scopes/#scope-posts-write) and [`posts:publish`](https://beplan.io/docs/oauth/scopes/#scope-posts-publish) ([`profile:read`](https://beplan.io/docs/oauth/scopes/#scope-profile-read), for step 2, is always included). **Everything my role allows** gives it the [`all`](https://beplan.io/docs/oauth/scopes/#scope-all) scope: every scope, present and future, and only personal tokens can have it.

If you signed in more than 10 minutes ago, Beplan asks for your password (or a two-factor code) first. Then it shows the token, `beplan_pat_` followed by random characters, **once**. Copy it into your secret store; Beplan keeps only a hash.

> **Keep it secret.** The token acts as you. Never put it in a page's code, an app sent to users, or a repository. If it leaks, revoke it in **Developers**: it stops at once.

An organization in **Approval** mode for API tokens can still be picked: the token works there once an admin approves it. Until then that organization answers [`INTEGRATION_PENDING_APPROVAL`](https://beplan.io/docs/api/errors/#INTEGRATION_PENDING_APPROVAL).

## 2. Check who the token acts for

Every request sends the token in the `Authorization` header, and nowhere else:

Example (A personal token given one organization), `GET /me`:

```bash
curl -X GET "https://api.beplan.io/v1/me" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/me", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/me",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": {
    "user": {
      "id": "user_2x8Kq",
      "name": "Alex Martin"
    },
    "connection": {
      "id": "3c9d1e2f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
      "kind": "personal_token",
      "name": "n8n weekly report",
      "clientId": null,
      "scopes": [
        "profile:read",
        "posts:read",
        "media:read"
      ],
      "expiresAt": "2027-02-17T10:00:00.000Z"
    },
    "organizations": [
      {
        "id": "org_8Hq2LmN4",
        "name": "Studio Halden",
        "state": "active",
        "reason": null,
        "allWorkspaces": true,
        "workspaces": [
          {
            "id": "5d2e8f14-3a6b-4c7d-9e0f-1a2b3c4d5e60",
            "name": "Studio Halden",
            "timezone": "Europe/Paris"
          }
        ]
      }
    ]
  }
}
```

The answer lists:

- `user`: the person the token acts for (`id`, `name`).
- `connection`: the token itself: `kind` (`personal_token`), `name`, the `scopes` it may use, and `expiresAt`.
- `organizations`: each organization it was given, with its `state` (`active`, `pending` while an admin has to approve it, or `blocked` with a `reason`), `allWorkspaces`, and the `workspaces` it reaches (`id`, `name`, `timezone`).

Keep an organization `id` and a workspace `id` from it: every other path takes them.

## 3. Find a workspace and an account

The workspaces of an organization, with their time zones:

Example (One workspace), `GET /organizations/{organizationId}/workspaces`:

```bash
curl -X GET "https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": [
    {
      "id": "3f6c2a8e-91b4-4d7e-a2c5-7e0b9d1f4a62",
      "name": "Northwind",
      "avatarUrl": null,
      "timezone": "Europe/Paris",
      "defaultAccountIds": []
    }
  ]
}
```

The workspace's connected social accounts. A post names the accounts it goes to by these ids; an account whose `status` is `disconnected`, or that `needsSetup`, can't publish until a person fixes it in Beplan.

Example (An Instagram account), `GET /organizations/{organizationId}/workspaces/{workspaceId}/social-accounts`:

```bash
curl -X GET "https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces/3f6c2a8e-91b4-4d7e-a2c5-7e0b9d1f4a62/social-accounts" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces/3f6c2a8e-91b4-4d7e-a2c5-7e0b9d1f4a62/social-accounts", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces/3f6c2a8e-91b4-4d7e-a2c5-7e0b9d1f4a62/social-accounts",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": [
    {
      "id": "5b9e2d7a-0c4f-4a18-9e3b-7d6c1f8a2e05",
      "platform": "instagram",
      "username": "northwind.studio",
      "displayName": null,
      "avatarUrl": null,
      "status": "connected",
      "missingPermissions": false,
      "needsSetup": false,
      "setupStep": null,
      "linkedinKind": null,
      "lastErrorCode": null,
      "connectedAt": "2026-03-02T09:20:00.000Z",
      "syncedAt": "2026-11-19T04:00:00.000Z",
      "profileUrl": "https://www.instagram.com/northwind.studio",
      "xSubscribed": false
    }
  ]
}
```

## 4. Create a post

[`POST …/posts`](https://beplan.io/docs/api/posts/#posts.create) makes a draft with whatever you send; every field is optional. `platforms` lists the accounts it goes to; `media` takes ids from the workspace's media library ([upload media](https://beplan.io/docs/guides/upload-media/) first, or leave it out for a text post).

Example (A LinkedIn post with one image), `POST /organizations/{organizationId}/workspaces/{workspaceId}/posts`:

```bash
curl -X POST "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts" \
  -H "Authorization: Bearer beplan_pat_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Spring drop teaser",
  "caption": "Something new lands Thursday.",
  "hashtags": "#springdrop",
  "media": [
    {
      "mediaId": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f",
      "altText": "The spring collection on a table"
    }
  ],
  "platforms": [
    {
      "socialAccountId": "0b6f5c1e-2a7d-4c3b-9e8f-1a2b3c4d5e6f",
      "isActive": true,
      "additionalParams": {
        "linkedin_visibility": "PUBLIC"
      }
    }
  ]
}'
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts", {
  method: "POST",
  headers: {
    Authorization: "Bearer beplan_pat_…",
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "title": "Spring drop teaser",
    "caption": "Something new lands Thursday.",
    "hashtags": "#springdrop",
    "media": [
      {
        "mediaId": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f",
        "altText": "The spring collection on a table"
      }
    ],
    "platforms": [
      {
        "socialAccountId": "0b6f5c1e-2a7d-4c3b-9e8f-1a2b3c4d5e6f",
        "isActive": true,
        "additionalParams": {
          "linkedin_visibility": "PUBLIC"
        }
      }
    ]
  }),
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import uuid

import requests

response = requests.post(
    "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts",
    headers={"Authorization": "Bearer beplan_pat_…", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "title": "Spring drop teaser",
        "caption": "Something new lands Thursday.",
        "hashtags": "#springdrop",
        "media": [
            {
                "mediaId": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f",
                "altText": "The spring collection on a table",
            },
        ],
        "platforms": [
            {
                "socialAccountId": "0b6f5c1e-2a7d-4c3b-9e8f-1a2b3c4d5e6f",
                "isActive": True,
                "additionalParams": {
                    "linkedin_visibility": "PUBLIC",
                },
            },
        ],
    },
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 201:

```json
{
  "data": {
    "id": "6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7",
    "title": "Spring drop teaser",
    "caption": "Something new lands Thursday.",
    "hashtags": "#springdrop",
    "formatIds": [],
    "ignoreOpenFormatSlots": false,
    "status": "idea",
    "scheduledAt": null,
    "media": [
      {
        "mediaId": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f",
        "altText": "The spring collection on a table",
        "item": {
          "id": "c3d4e5f6-a7b8-4c9d-8e0f-1a2b3c4d5e6f",
          "folderId": null,
          "filename": "spring-collection.jpg",
          "altText": "The spring collection on a table",
          "mediaType": "image",
          "mimeType": "image/jpeg",
          "size": 482133,
          "width": 1080,
          "height": 1350,
          "aspectRatio": 0.8,
          "duration": null,
          "waveform": null,
          "createdAt": "2026-11-18T09:30:00.000Z",
          "formats": [],
          "usage": "used",
          "processing": {
            "state": "ready",
            "error": null
          },
          "previewUrl": "https://storage.beplan.io/org-media/…/preview?X-Amz-Signature=…",
          "mediaUrl": "https://storage.beplan.io/org-media/…?X-Amz-Signature=…",
          "playback": null,
          "publishCopy": null
        },
        "crop": null
      }
    ],
    "platforms": [
      {
        "socialAccountId": "0b6f5c1e-2a7d-4c3b-9e8f-1a2b3c4d5e6f",
        "platform": "linkedin",
        "isActive": true,
        "type": "post",
        "customCaption": null,
        "additionalParams": {
          "linkedin_visibility": "PUBLIC"
        },
        "media": null,
        "thread": [],
        "publishedUrl": null,
        "publishedUrlKind": null,
        "publishState": "pending",
        "publishError": null
      }
    ],
    "updatedAt": "2026-11-19T10:12:00.000Z",
    "pendingApproval": null,
    "scheduledVia": null
  }
}
```

It answers `201` with the post, status `idea`. Nothing is published yet. The `Idempotency-Key` header makes a retry safe: the same key with the same body returns the first answer instead of creating a second post ([idempotency](https://beplan.io/docs/guides/idempotency/)).

## 5. Schedule it

[`POST …/posts/{postId}/schedule`](https://beplan.io/docs/api/posts/#posts.schedule) takes an ISO 8601 instant in the future. Every check that publishing needs runs now (accounts connected and set up, media processed, platform rules, the plan's monthly scheduled posts), so a post that could not go out fails here with a precise error instead of failing later.

Example (Thursday at 14:00 UTC), `POST /organizations/{organizationId}/workspaces/{workspaceId}/posts/{postId}/schedule`:

```bash
curl -X POST "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7/schedule" \
  -H "Authorization: Bearer beplan_pat_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "scheduledAt": "2026-12-03T14:00:00.000Z"
}'
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7/schedule", {
  method: "POST",
  headers: {
    Authorization: "Bearer beplan_pat_…",
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "scheduledAt": "2026-12-03T14:00:00.000Z"
  }),
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import uuid

import requests

response = requests.post(
    "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7/schedule",
    headers={"Authorization": "Bearer beplan_pat_…", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "scheduledAt": "2026-12-03T14:00:00.000Z",
    },
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": {
    "id": "6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7",
    "title": "Spring drop teaser",
    "caption": "Something new lands Thursday.",
    "status": "scheduled",
    "scheduledAt": "2026-12-03T14:00:00.000Z",
    "order": 0,
    "formats": [],
    "platforms": [
      {
        "platform": "linkedin",
        "state": "pending",
        "url": null,
        "error": null
      }
    ],
    "media": [],
    "mediaCount": 0
  }
}
```

`200`: the post is `scheduled`. Beplan publishes it at that time.

### When the answer is `202`

An organization can require a person's approval for posts that integrations schedule or publish. It is off unless the organization switches it on. When it is on, the post is **not** scheduled: the answer is `202`, the post unchanged, and an `approval` object with its `id`, `status: "pending"` and the `url` of the post in Beplan, where a member approves or rejects it.

Example (The organization requires approval: the post waits for a person), `POST /organizations/{organizationId}/workspaces/{workspaceId}/posts/{postId}/schedule`:

```bash
curl -X POST "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7/schedule" \
  -H "Authorization: Bearer beplan_pat_…" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "scheduledAt": "2026-12-03T14:00:00.000Z"
}'
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7/schedule", {
  method: "POST",
  headers: {
    Authorization: "Bearer beplan_pat_…",
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "scheduledAt": "2026-12-03T14:00:00.000Z"
  }),
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import uuid

import requests

response = requests.post(
    "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7/schedule",
    headers={"Authorization": "Bearer beplan_pat_…", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "scheduledAt": "2026-12-03T14:00:00.000Z",
    },
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 202:

```json
{
  "data": {
    "id": "6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7",
    "title": "Spring drop teaser",
    "caption": "Something new lands Thursday.",
    "status": "ready",
    "scheduledAt": null,
    "order": 0,
    "formats": [],
    "platforms": [
      {
        "platform": "linkedin",
        "state": "pending",
        "url": null,
        "error": null
      }
    ],
    "media": [],
    "mediaCount": 0,
    "approval": {
      "id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
      "status": "pending",
      "url": "https://app.beplan.io/…"
    }
  }
}
```

Follow it with [`GET …/posts/{postId}/approval`](https://beplan.io/docs/api/posts/review-and-approval/#posts.approval.get), or withdraw it with [`DELETE …/posts/{postId}/approval`](https://beplan.io/docs/api/posts/review-and-approval/#posts.approval.cancel). Approving and rejecting are for people in Beplan only. [Post approval](https://beplan.io/docs/concepts/approval/) has the details.

## 6. Check the result

[`GET …/posts/{postId}`](https://beplan.io/docs/api/posts/#posts.get) shows where the post stands on each account: `publishState` is `pending`, then `published` with `publishedUrl`, or `failed` with `publishError`.

Example (A draft for LinkedIn), `GET /organizations/{organizationId}/workspaces/{workspaceId}/posts/{postId}`:

```bash
curl -X GET "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/organizations/ORGANIZATION_ID/workspaces/WORKSPACE_ID/posts/6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": {
    "id": "6f1c2a3b-4d5e-4f60-8a71-92b3c4d5e6f7",
    "title": "Spring drop teaser",
    "caption": "Something new lands Thursday.",
    "hashtags": "#springdrop",
    "formatIds": [],
    "ignoreOpenFormatSlots": false,
    "status": "idea",
    "scheduledAt": null,
    "media": [],
    "platforms": [
      {
        "socialAccountId": "0b6f5c1e-2a7d-4c3b-9e8f-1a2b3c4d5e6f",
        "platform": "linkedin",
        "isActive": true,
        "type": "post",
        "customCaption": null,
        "additionalParams": {
          "linkedin_visibility": "PUBLIC"
        },
        "media": null,
        "thread": [],
        "publishedUrl": null,
        "publishedUrlKind": null,
        "publishState": "pending",
        "publishError": null
      }
    ],
    "updatedAt": "2026-11-19T10:12:00.000Z",
    "pendingApproval": null,
    "scheduledVia": null
  }
}
```

## What to do next

- Handle errors by their `code`: [errors](https://beplan.io/docs/guides/errors/).
- Upload images and videos: [upload media](https://beplan.io/docs/guides/upload-media/).
- Everything about posts, links in captions and edits while someone has the post open: [schedule a post](https://beplan.io/docs/guides/schedule-a-post/).
- Get told when a post is published instead of polling: [webhooks](https://beplan.io/docs/guides/webhooks/) (app webhooks are for OAuth apps; with a personal token, an admin can set up the organization's own webhook).
- Stay under the limits: [rate limits](https://beplan.io/docs/guides/rate-limits/).

## Copy as a prompt

Paste this into an AI coding tool to have it write the integration:

Copy as a prompt:

```text
Write a small program that schedules a social media post through the Beplan API.

- Base URL: https://api.beplan.io/v1. JSON in, JSON out.
- Auth: header "Authorization: Bearer <token>", the token read from the environment variable BEPLAN_TOKEN (a personal token, beplan_pat_…). Never log it, never put it in a URL.
- Step 1: GET /v1/me. Take an organization id from data.organizations (state must be "active") and a workspace id from its workspaces.
- Step 2: GET /v1/organizations/{organizationId}/workspaces/{workspaceId}/social-accounts. Pick an account whose status is "connected" and needsSetup is false.
- Step 3: POST /v1/organizations/{organizationId}/workspaces/{workspaceId}/posts with {"caption": "...", "platforms": [{"socialAccountId": "<id>", "isActive": true}]}, header "Idempotency-Key: <a new UUID>". Answers 201 with data.id.
- Step 4: POST /v1/organizations/{organizationId}/workspaces/{workspaceId}/posts/{postId}/schedule with {"scheduledAt": "<ISO 8601 instant in the future>"} and a new Idempotency-Key. 200: data.status is "scheduled". 202: the organization requires approval; print data.approval.url and stop.
- Errors answer {"error": {"code", "message", "details", "requestId"}}: branch on error.code, print message and requestId. On 429 wait Retry-After seconds and retry; on 401 stop (TOKEN_EXPIRED or TOKEN_REVOKED mean a new token is needed). Retry a POST only with the same Idempotency-Key.
- Docs: https://beplan.io/docs/quickstart/api-token.md and https://beplan.io/docs/api/openapi.json
```

---
HTML version: https://beplan.io/docs/quickstart/api-token/
