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

# Schedule your first post

> Make a key, find your ids, save a draft, schedule it for 15 March 2030 and see it on your calendar.

This page takes you from a new API key to a post on your PostSyncer calendar, in five requests. Nothing is published: the post starts as a draft, then you schedule it for 15 March 2030.

It works on every plan, Free included. On Free, the schedule step uses one of your 20 posts this month. Drafts don't count.

**You need** a PostSyncer workspace you own, since only owners make API keys, with one connected social account (connect one under **Accounts** in the [app](https://app.postsyncer.com)). You also need curl, Node.js 18 or later, or Python 3 with `requests`.

> [!NOTE]
>
> Replace `YOUR_API_KEY`, `WORKSPACE_ID`, `ACCOUNT_ID` and `POST_ID` with your own values. The ids are numbers. In Node.js, save a block as a `.mjs` file and run it with `node`.

## Get a key

1. Open [Settings → API](https://app.postsyncer.com/settings/api) and click **New key**.
2. Name it, for example "Quickstart". Under **Start from**, choose **Pick myself**, then click **Next: check what it can do**.
3. Set **Workspaces** to **Read**, **Social accounts** to **Read** and **Posts** to **Schedule & publish**. Leave the rest at **No access**. The key then has `workspaces:read`, `accounts:read`, `posts:read`, `posts:create`, `posts:update`, `posts:schedule` and `posts:publish`.
4. Click **Create API Key** and copy the key. It's shown once.

The key acts as you: it reaches the workspaces you own or joined, and in each one it can do what your role there allows. Send it on every request as `Authorization: Bearer YOUR_API_KEY`.

## 1. List your workspaces

This read checks the key and gives you the workspace's `id` and `timezone`.

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

```javascript Node.js theme={null}
const res = await fetch("https://postsyncer.com/api/v1/workspaces", {
  headers: { Authorization: "Bearer YOUR_API_KEY" },
});
console.log(res.status, await res.json());
```

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

res = requests.get(
    "https://postsyncer.com/api/v1/workspaces",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
)
print(res.status_code, res.json())
```

The answer is a list, one item per workspace (shortened here):

```json Response theme={null}
[
  {
    "id": 4815,
    "name": "Halden Coffee",
    "timezone": "Europe/London",
    "accounts": [
      {
        "id": 16234,
        "platform": "twitter",
        "username": "haldencoffee"
      }
    ]
  }
]
```

Post times you send and get back are in the workspace's `timezone`. Use this workspace's `id` as `WORKSPACE_ID`.

## 2. Find the account to post to

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

```javascript Node.js theme={null}
const res = await fetch("https://postsyncer.com/api/v1/accounts", {
  headers: { Authorization: "Bearer YOUR_API_KEY" },
});
console.log(res.status, await res.json());
```

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

res = requests.get(
    "https://postsyncer.com/api/v1/accounts",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
)
print(res.status_code, res.json())
```

The answer lists the connected accounts of every workspace the key reaches (shortened here):

```json Response theme={null}
[
  {
    "id": 16234,
    "workspace_id": 4815,
    "platform": "twitter",
    "username": "haldencoffee",
    "name": "Halden Coffee",
    "needs_reconnect": false,
    "plan_allows_posting": true
  }
]
```

Pick one whose `workspace_id` is your workspace, whose `needs_reconnect` is `false` and whose `plan_allows_posting` is `true` (on Free outside a first week, new posts go to 2 accounts and the others are refused with `"limit": "free_accounts"`). Its `id` is `ACCOUNT_ID`.

## 3. Save a draft

A draft is saved in PostSyncer and goes nowhere. This one is text only, for one account.

```bash cURL theme={null}
curl -X POST "https://postsyncer.com/api/v1/posts" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": WORKSPACE_ID,
    "schedule_type": "draft",
    "content": [
      { "text": "Oat-milk flat whites are back at Halden Coffee this spring." }
    ],
    "accounts": [
      { "id": ACCOUNT_ID }
    ]
  }'
```

```javascript Node.js theme={null}
const res = await fetch("https://postsyncer.com/api/v1/posts", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    workspace_id: WORKSPACE_ID,
    schedule_type: "draft",
    content: [
      { text: "Oat-milk flat whites are back at Halden Coffee this spring." },
    ],
    accounts: [{ id: ACCOUNT_ID }],
  }),
});
console.log(res.status, await res.json());
```

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

res = requests.post(
    "https://postsyncer.com/api/v1/posts",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "workspace_id": WORKSPACE_ID,
        "schedule_type": "draft",
        "content": [
            {"text": "Oat-milk flat whites are back at Halden Coffee this spring."}
        ],
        "accounts": [{"id": ACCOUNT_ID}],
    },
)
print(res.status_code, res.json())
```

It answers `201` with the post (shortened here):

```json Response theme={null}
{
  "id": 92731,
  "status": "DRAFT",
  "scheduled_at": null,
  "content": [
    {
      "text": "Oat-milk flat whites are back at Halden Coffee this spring.",
      "media": []
    }
  ],
  "platforms": [
    {
      "platform": "twitter",
      "status": "PENDING"
    }
  ],
  "skipped_accounts": [],
  "needs_media": []
}
```

`platforms` has one row per account, each with its own `status`. The post's `id` is `POST_ID`.

## 4. Schedule it

Update the post with `schedule_type: "schedule"` and a time. This needs `posts:update` and `posts:schedule`.

```bash cURL theme={null}
curl -X PUT "https://postsyncer.com/api/v1/posts/POST_ID" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": WORKSPACE_ID,
    "schedule_type": "schedule",
    "schedule_for": { "date": "2030-03-15", "time": "09:00" },
    "content": [
      { "text": "Oat-milk flat whites are back at Halden Coffee this spring." }
    ]
  }'
```

```javascript Node.js theme={null}
const res = await fetch("https://postsyncer.com/api/v1/posts/POST_ID", {
  method: "PUT",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    workspace_id: WORKSPACE_ID,
    schedule_type: "schedule",
    schedule_for: { date: "2030-03-15", time: "09:00" },
    content: [
      { text: "Oat-milk flat whites are back at Halden Coffee this spring." },
    ],
  }),
});
console.log(res.status, await res.json());
```

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

res = requests.put(
    "https://postsyncer.com/api/v1/posts/POST_ID",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "workspace_id": WORKSPACE_ID,
        "schedule_type": "schedule",
        "schedule_for": {"date": "2030-03-15", "time": "09:00"},
        "content": [
            {"text": "Oat-milk flat whites are back at Halden Coffee this spring."}
        ],
    },
)
print(res.status_code, res.json())
```

```json Response theme={null}
{
  "id": 92731,
  "status": "SCHEDULED",
  "scheduled_at": "2030-03-15 09:00",
  "platforms": [
    {
      "platform": "twitter",
      "status": "PENDING"
    }
  ]
}
```

* An update sends the full `content` again. What you leave out, such as `accounts`, keeps what the post has.
* `schedule_for` is read in the workspace's timezone. To give the time in another one, add `"timezone": "America/New_York"` to `schedule_for`. It applies to this post only, and answers still show times in the workspace's timezone.
* The time must be in the future, or the API answers `422`.

## 5. Check the post

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

```javascript Node.js theme={null}
const res = await fetch("https://postsyncer.com/api/v1/posts/POST_ID", {
  headers: { Authorization: "Bearer YOUR_API_KEY" },
});
console.log(res.status, await res.json());
```

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

res = requests.get(
    "https://postsyncer.com/api/v1/posts/POST_ID",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
)
print(res.status_code, res.json())
```

```json Response theme={null}
{
  "id": 92731,
  "status": "SCHEDULED",
  "scheduled_at": "2030-03-15 09:00",
  "workspace": {
    "id": 4815,
    "name": "Halden Coffee",
    "timezone": "Europe/London"
  },
  "platforms": [
    {
      "platform": "twitter",
      "status": "PENDING",
      "posted_on": [],
      "notes": []
    }
  ]
}
```

The post is `SCHEDULED` for 09:00 on 15 March 2030, and its X row is `PENDING`: not sent yet. The row's `posted_on` is a list of the times it went out, such as `["2030-03-15 09:00"]`, so it's empty for now. When it goes out, the post ends `PUBLISHED`, `PARTIALLY_FAILED` or `FAILED`. [Core concepts](/docs/concepts.md#post-statuses) has every status.

## 6. See it on the calendar

In the app, switch to this workspace and open [the calendar on March 2030](https://app.postsyncer.com/calendar?view=month\&date=2030-03-15). The post is on 15 March at 09:00.

To remove it, delete it in the app, or call [`DELETE /posts/{id}`](/docs/api-reference/posts/delete) with a key that has `posts:delete`. It was never sent, so nothing changes on X.

## Next steps

> [card] [Core concepts](/docs/concepts.md)
>
> Workspaces, accounts, posts, platform rows and statuses.

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

> [card] [Create a post](/docs/api-reference/posts/create.md)
>
> Media, threads, first comments, repeats and settings per network.

> [card] [Webhooks](/docs/api-reference/webhooks/overview.md)
>
> Hear when a post is published or fails.


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