---
title: Posting from an AI agent
description: "Let an AI agent write, schedule or publish posts, choose whether it may publish, and read what it did."
sidebar:
  icon: bot
---

An AI agent can post through Peal the way a member does. It reads the workspace's channels, brings in images and videos, writes a draft for you to review, or schedules and publishes a post itself, then reads how it went. It reaches Peal through the [MCP endpoint](/developers/mcp), the [command line](/developers/cli) or the [HTTP API](/developers). For each application, you decide whether it may put posts out or only write drafts.

**Give a coding agent this prompt to post through the `peal` command line.**

> Post to Peal for me through its `peal` command line.
>
> 1. Run `peal doctor --json`, and fix each check that fails as it says.
> 2. Run `peal whoami` to see the workspace, and whether this sign-in may schedule and publish.
> 3. Run `peal channels list`, and ask me which channels the post goes to.
> 4. Write the post as a draft with `peal drafts save --text "…" --channel <channel-id>`, show it to me, and wait for my OK.
> 5. Only once I say so, schedule it with `peal posts schedule <post-id> --at <instant>`, then read how it went with `peal posts show <post-id>`.
>
> A draft is safe; publishing is public and cannot be taken back. Never repost a target that is `unconfirmed`: ask me to look on the platform. Branch on error codes, never on messages, and stop to ask me when a command fails.

## What an agent can do [#what]

Each task maps to one or more MCP tools:

| It can                                                                                         | With                                                                                          |
| ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| See who it acts for, in which workspace, and what it may do there                              | `whoami`                                                                                      |
| Find the tool for a task, and learn which tools the connection may call                        | `find_tools`                                                                                  |
| List the channels a post can go to, the media it can show, drafts and posts                    | `list_channels`, `list_media`, `list_drafts`, `list_posts`                                    |
| Bring an image or a video in from a public address                                             | `import_media`                                                                                |
| Read one media, see which posts show it, describe it, or delete it when the user asks          | `get_media`, `get_media_usage`, `describe_media`, `delete_media`                              |
| Make a link that shows a post to a reviewer without an account, to view or comment, and end it | `list_review_links`, `create_review_link`, `revoke_review_link`                               |
| Write a draft, change it or discard it                                                         | `create_draft`, `update_draft`, `discard_draft`                                               |
| Write a new draft from a post the workspace has                                                | `duplicate_post`                                                                              |
| Give a channel the workspace's own name, turn it off or back on                                | `rename_channel`, `disable_channel`, `enable_channel`                                         |
| File posts under the workspace's tags, and list a tag's posts                                  | `list_tags`, `create_tag`, `tag_post`, `list_posts`                                           |
| Post to a saved set of channels, with a saved signature and a channel's default options        | `list_channel_sets`, `list_signatures`, `get_channel_defaults`, `create_draft`, `create_post` |
| Schedule a draft, publish a post now, or create and send one in a single call                  | `schedule_post`, `publish_post`, `create_post`                                                |
| Check a post before sending it, and see what each channel would receive                        | `validate_post`                                                                               |
| Create and send up to 50 posts in one call                                                     | `create_posts`                                                                                |
| Move a scheduled post, take a channel off it, take it back to draft or cancel it               | `reschedule_post`, `remove_post_target`, `unschedule_post`, `cancel_post`                     |
| Read how a post went on each channel, and every attempt Peal made                              | `get_post`, `list_post_attempts`                                                              |
| Wait until a post that goes out now has its result on every channel                            | `await_post`                                                                                  |
| Post again where a post failed, or record what you found on the platform                       | `repost_target`, `confirm_target`                                                             |

[Connect an MCP client](/developers/mcp/tools#tools) lists every tool with what it changes.

An agent connects no channel. You connect accounts in the web app, where you sign in on each platform ([Connect channels](/guides/channels)). The agent acts in one workspace, as you, with no more than your [role](/guides/posts#roles) allows: owners, admins and editors schedule and publish, and contributors write drafts.

## Connect an MCP client [#connect]

The endpoint is `/api/mcp` at the address you open Peal at, such as `https://peal.example.com/api/mcp`. Give it to your AI assistant, or to any other MCP client, the way its documentation says to add a remote server over HTTP. `peal mcp` prints a configuration most clients take ([Connect an MCP client](/developers/mcp#endpoint)).

You don't give the client a key. On its first request it opens a browser on Peal:

1. **Sign in**

    If you aren't signed in yet.

2. **Pick a workspace**

    The client acts in that one only.

3. **Check the consent page**

    Check what the application asks for and where it sends you back. Publishing
    has a line of its own, with a checkbox: **Let it schedule and publish posts
    to your connected accounts, where everyone can see them**. Leave it
    selected, or clear it to let the application write drafts only. Then click
    **Allow**, or **Deny**.

> **Allow only an application you trust**
>
> Peal doesn't check who made an application that registered itself, and the
> consent page says so. Allow one only if you trust it and started the
> connection yourself.

## An agent with nobody to sign in [#headless]

An agent that runs on a schedule or on a server has no browser to sign in with. Give it an [API key](/guides/workspace#api-keys) of the workspace instead, created with only the permissions it needs. Where the key goes depends on how the agent connects:

- On the MCP endpoint, in the `Authorization` header, as `Bearer peal_…`, never in the address ([Connect with an API key](/developers/mcp#api-key)).
- On the [HTTP API](#api), in the same header.
- On the [command line](#cli), in the `PEAL_API_KEY` variable, never a flag ([Run it with an API key](/developers/cli#api-key)).

A key has no scope. What it may do is the list of its permissions, which `whoami` answers, and `GET /api/v1/credential` over HTTP ([SDKs](/developers/sdks#credential)). It puts posts out only when it holds `post:schedule`, and the tools only a person uses, such as inviting someone, refuse it.

Keep the key in the agent's secrets. Revoke it under **API keys** the day the agent stops.

## What each permission allows [#scopes]

An application asks for up to three permissions on the workspace, which OAuth calls scopes:

| Scope               | The consent page says                                                                                                           | What it allows                                                                                                                                                                                                                                                 |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `workspace:read`    | Read the workspace: posts, channels, media and analytics                                                                        | Reading, and no change                                                                                                                                                                                                                                         |
| `workspace:write`   | Do what your role allows in the workspace, such as writing drafts and managing media, without scheduling or publishing anything | Everything your role allows but what puts posts out: drafts, media, webhooks. Nothing it does reaches a platform.                                                                                                                                              |
| `workspace:publish` | Let it schedule and publish posts to your connected accounts, and answer comments there, where everyone can see them            | What your role allows of what puts posts out: scheduling, moving, publishing and reposting a post, unscheduling it, cancelling it, confirming how it went, and approving a post that waits for an [approval](/guides/posts/review) or asking for changes on it |

> **The ads scope spends money**
>
> A fourth scope, `workspace:ads`, is for [ads](/guides/engage/ads#access), and
> opens nothing alone. Next to `workspace:write`, it lets the application
> disconnect ad accounts and pause or stop boosts. Next to `workspace:publish`,
> it lets it boost posts, which spends money on an ad network, within the
> monthly ceiling an owner set. No application ever decides whether an ad
> account may spend, or how much. That stays with an owner, signed in to Peal.

No application but Peal's command line invites people, cancels an invitation, changes a member's role or removes a member, or sets where the writing assistant's prompts go, whatever its scopes. A refusal says so, and names no scope to ask for.

Both `workspace:write` and `workspace:publish` include reading. Without `workspace:publish`, the tools that write drafts and handle media still work. Those that put posts out are refused, and the refusal names the scope.

`workspace:publish` also covers answering the comments under your published posts ([Inbox](/guides/engage/inbox)), because a reply is public, as a post is. Reading them takes `workspace:read`.

Publishing is a scope of its own so that you can leave it out. An application you connected before it existed holds `workspace:write` alone. It publishes nothing, and no longer unschedules, reposts or confirms, until you connect it again and allow publishing. A connection keeps the scopes it was given until then.

## An example session [#session]

Here an agent posts a picture to two channels. Each step is a tool call with its arguments, and the ids and addresses are made up.

### See what it may do [#session-whoami]

`whoami` tells the agent the workspace and what the connection may do. Its `permissions` hold `post:schedule` only when you allowed publishing. It takes no arguments:

```json
{}
```

### Find the channels [#session-channels]

`list_channels` gives the ids of the channels the post goes to. It takes no arguments either:

```json
{}
```

### Bring the picture in [#session-media]

`import_media` brings the picture into the workspace's media. The answer is the media, and it can be attached once its `status` is `ready`. The call takes the picture's address and its alternative text:

```json
{
  "url": "https://files.example/spring/cover.jpg",
  "altText": "A paper catalogue open on a wooden table, next to a cup of coffee."
}
```

### Write a draft [#session-draft]

`create_draft` lets you review the post before anything goes out. It joins the workspace's **Drafts**, where you schedule it. The agent can also schedule it later with `schedule_post`. The draft names its channels, its text and its media:

```json
{
  "channelIds": [
    "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11",
    "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b12"
  ],
  "content": {
    "text": "Our spring catalogue is out. Read it at https://example.com/spring",
    "media": [
      {
        "mediaId": "019a6c3e-88d0-7e15-a4b7-0c2d9f3e5a01",
        "altText": "A paper catalogue open on a wooden table, next to a cup of coffee."
      }
    ],
    "overrides": []
  }
}
```

### Or schedule it in one call [#session-post]

When you asked for this post to go out at a time, the agent calls `create_post`, which creates and schedules it in one call. `when` is `at` an instant, with the IANA time zone it was chosen in, or `{ "_tag": "now" }`, which publishes within seconds.

The `idempotencyKey` is any text the agent picks, new for each post, of 255 characters at most. Say an answer gets lost: called again with the same key and the same arguments within 24 hours, the tool answers the post the first call made and makes no second one. The call is the draft's, with `when` and the key:

```json
{
  "channelIds": [
    "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11",
    "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b12"
  ],
  "content": {
    "text": "Our spring catalogue is out. Read it at https://example.com/spring",
    "media": [
      {
        "mediaId": "019a6c3e-88d0-7e15-a4b7-0c2d9f3e5a01",
        "altText": "A paper catalogue open on a wooden table, next to a cup of coffee."
      }
    ],
    "overrides": []
  },
  "when": {
    "_tag": "at",
    "at": "2026-11-16T08:00:00Z",
    "timeZone": "Europe/Paris"
  },
  "idempotencyKey": "spring-catalogue-2026-11-16"
}
```

Keys aside, a post whose content already goes to one of its channels less than 23 hours from its time is refused, and the refusal names the post that has it ([Duplicate posts](/developers/posting#duplicates)). `allowDuplicate: true` lets it through, and an agent passes it only when you mean to post the same thing twice.

With `waitSeconds`, 60 at most, a post that goes out `now` is answered once every channel has its result, or as it stands when the time runs out. `await_post` waits for the rest.

`validate_post` takes the same arguments and makes nothing. It answers what would be refused, and what each channel would receive. `create_posts` sends up to 50 posts in one call, each as `create_post` would, and answers for each whether it was made or why it was refused.

### Read the outcome [#session-outcome]

Once its time has passed, `get_post` reads the outcome. The post's `status` is `finished` when every channel is done. Its `outcome` and each of its `targets` say how it went, with the post's address on the platform, or why it failed. It takes the post's id:

```json
{ "postId": "019a6c3f-1b72-7d3c-8e90-4f5a6b7c8d02" }
```

When something failed or went out late, `list_post_attempts` lists every attempt Peal made, by channel, with how each ended and when Peal tried again. It takes the post's id too:

```json
{ "postId": "019a6c3f-1b72-7d3c-8e90-4f5a6b7c8d02" }
```

The channels of a YouTube or TikTok account ask for more than text and media. `create_draft` and `create_post` take those fields in `options` ([Platform options](/guides/posts#options)), and `get_tiktok_creator` reads what a TikTok account offers first.

## How refusals read [#refusals]

A post is checked against every channel's platform before it's scheduled: text length, media types, sizes and counts, required options, and what the account itself refuses. When anything is wrong, nothing is saved, scheduled or published. The refusal lists every violation at once, as data, so one more call can fix them all:

```json
[
  {
    "_tag": "textTooLong",
    "channelId": "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11",
    "platform": "bluesky",
    "length": 342,
    "maximum": 300,
    "unit": "graphemes"
  },
  {
    "_tag": "mediaTooLarge",
    "channelId": "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11",
    "platform": "bluesky",
    "mediaId": "019a6c3e-88d0-7e15-a4b7-0c2d9f3e5a01",
    "byteSize": 3481600,
    "maximum": 2000000
  }
]
```

Each violation names what's wrong (`_tag`), the channel (`channelId`) and its `platform`, the option (`field`) or the media (`mediaId`) concerned, and the limit it broke. The API answers the same list in `PostContentInvalid` (422).

Other refusals are sentences the agent can act on, or pass on to you:

- A missing scope is named, with how to grant it: "the user did not give this client the scope workspace:publish (schedule and publish posts). To grant it, the user connects this client to Peal again and allows it there".
- A role that doesn't allow the action is named with its permission, such as `post:schedule`. An owner or admin changes the role in the workspace's settings.
- Each of these says so, and that nothing was made: a time more than a minute in the past, a time zone that isn't an IANA zone, a channel or media that isn't the workspace's, a post whose status doesn't allow the action, and a plan with no room left.

## Before you let an agent publish [#safety]

What goes out is public on the platforms and seen by the accounts' followers. Peal can't take it back once it's out, so deleting it is done on each platform. Here's how to keep control.

### Review drafts first [#safety-drafts]

A draft goes out at no time until someone schedules it. Let a new application write drafts, read them in the web app, and schedule them yourself until you trust what it writes. Grant publishing only to applications you trust.

### Stop a post before its time [#safety-stop]

`unschedule_post` takes a scheduled post back to draft, and `cancel_post` cancels it for good. **Back to draft** and **Cancel the post** in the composer do the same. A post that's already publishing can't be unscheduled, and cancelling it stops only the channels not yet sent.

### Check the platform before reposting [#safety-repost]

When a post is unconfirmed, Peal couldn't tell whether the platform published it. Reposting it then may show it twice. Look on the platform first, then repost, or record what you found with `confirm_target`.

### Read what the agent did [#safety-activity]

The workspace's [activity log](/guides/workspace#activity) keeps every request that asked to change something, done or refused, and every call of a tool that changes something. Each entry has when, which operation, how it was answered, and the key or the application it came through, by name.

Owners read it with `GET …/workspace/activity`, `peal activity list` or the tool `list_activity`, and so does a key an owner gave `activity:read`. It's kept 90 days, and holds no text of any post.

Each post's page also shows how it was created and how it was scheduled: in the web app, with an API key, or by an application, by name. The API answers the same in `createdVia` and `scheduledVia` (`via`: `web`, `apiKey` or `application`, with the key's or the application's `id` and `name`), with the member who last scheduled or moved it in `scheduledBy`.

### Disconnect an application [#safety-disconnect]

Under **Settings**, go to **Security and access**, then **Connected applications**, and disconnect it there. It can no longer renew its access, and the access it holds ends within 15 minutes. Posts it scheduled stay scheduled, so cancel or unschedule those you don't want.

### Imports fetch public addresses only [#safety-imports]

The Peal server downloads the file itself, without credentials, from an `https://` URL on the default port whose host is public. It follows at most three redirects, and checks each one the same way. The file must arrive within 90 seconds:

- JPEG, PNG, GIF and WebP images up to 16 MiB.
- MP4 and QuickTime videos up to 1 GiB.

Each import adds a file to the workspace's media, which counts against its plan on an instance that bills. Upload larger or slower files yourself.

## An agent that runs for a long time [#reliability]

An agent that runs unattended meets lost answers, unconfirmed posts and rate limits. These rules keep it from posting twice.

### Send again only what's safe to send again [#reliability-retry]

A missing answer doesn't mean the post wasn't made. `create_post`, `peal post` and `POST …/posts` take an idempotency key. Under the same key and the same post, a second call within 24 hours answers the first post. Creating a draft or importing media a second time makes a second one, and reposting sends the post again ([Idempotency](/developers/conventions/idempotency#idempotency)).

### Leave an unconfirmed post alone [#reliability-unconfirmed]

`unconfirmed` means Peal couldn't tell whether the platform published it. An agent that reposts it may show it twice, so have it ask you, and record what you found with `confirm_target`.

### Branch on the error code [#reliability-codes]

Every API error has a stable `code`, such as `post_status_conflict`, and a `message` in English that may be reworded ([Error codes](/developers/conventions/errors#error-codes)). Each publishing attempt carries the platform's own code in `refusalCode`.

### Stay within the rate limit [#reliability-rate]

A key, or an application for each member it acts for, may send 600 requests a minute (60 on a billing account without a payment method), through MCP and the API together. Every answer says what's left in the `RateLimit` header, and a 429 says how long to wait in `Retry-After` ([Rate limits](/developers/conventions/rate-limits#rate-limits)).

### Keep the request id [#reliability-request-id]

Every answer carries `X-Request-Id`, which is also in every error and in the activity log. An agent can send its own, 8 to 128 letters, digits, `.`, `_`, `:` or `-`, and then find its calls there under its own numbering ([Requests and answers](/developers/conventions#requests)).

## From the command line [#cli]

An agent that runs commands in a terminal uses [`peal`](/developers/cli), signed in as you with `peal login`, which asks for the permission to schedule and publish. An agent with nobody to sign in runs it with an API key in `PEAL_API_KEY` instead ([Run it with an API key](/developers/cli#api-key)).

With `--json`, `peal` prints the API's answer as one JSON document on stdout. A failure is one JSON document on stderr, `{"error": {"code", "message", "requestId", …}}`, with exit code 1 ([Output for scripts](/developers/cli#json)).

Have the agent run `peal doctor --json` first. It checks the server, the credential, whether it may schedule and publish, and the workspace. It changes nothing, and says what to do about each check that fails ([Check the setup](/developers/cli#doctor)).

Each tool has a command:

| Tool                                           | Command                                                                                                       |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `whoami`                                       | `peal whoami`                                                                                                 |
| `list_channels`                                | `peal channels list`                                                                                          |
| `rename_channel`                               | `peal channels rename <channel-id> "…"`                                                                       |
| `disable_channel`, `enable_channel`            | `peal channels disable <channel-id>`, `peal channels enable <channel-id>`                                     |
| `list_media`, `import_media`                   | `peal media list`, `peal media import <url> --alt "…"`. `peal media upload <file>` sends a file from the disk |
| `list_drafts`, `create_draft`                  | `peal drafts list`, `peal drafts save --text "…" --channel <channel-id>`                                      |
| `duplicate_post`                               | `peal posts duplicate <post-id>`                                                                              |
| `create_post`                                  | `peal post "…" --channel <channel-id> --at <instant>`, or `--now`                                             |
| `validate_post`                                | `peal post "…" --channel <channel-id> --at <instant> --dry-run`                                               |
| `schedule_post`                                | `peal posts schedule <post-id> --at <instant>`                                                                |
| `publish_post`                                 | `peal posts publish <post-id>`                                                                                |
| `reschedule_post`                              | `peal posts reschedule <post-id> --at <instant>`                                                              |
| `unschedule_post`, `cancel_post`               | `peal posts unschedule <post-id>`, `peal posts cancel <post-id>`                                              |
| `get_post`                                     | `peal posts show <post-id>`                                                                                   |
| `list_posts`, `await_post`                     | `peal posts list`, `peal posts wait <post-id>`                                                                |
| `list_post_attempts`                           | `peal posts attempts <post-id>`                                                                               |
| `list_tags`, `tag_post`                        | `peal tags list`, `peal posts tag <post-id> --tag <tag>`                                                      |
| `list_signatures`, `list_channel_sets`         | `peal signatures list`, `peal sets list`                                                                      |
| `get_channel_defaults`, `set_channel_defaults` | `peal channels defaults show <channel-id>`, `peal channels defaults set <channel-id> --options <json>`        |
| `list_activity`                                | `peal activity list`                                                                                          |
| `repost_target`, `confirm_target`              | `peal posts repost <post-id> <target-id>`, `peal posts confirm <post-id> <target-id> published`               |
| `remove_post_target`                           | `peal posts remove-target <post-id> <target-id>`                                                              |

This command schedules the example session's post in one go:

```sh
peal post "Our spring catalogue is out. Read it at https://example.com/spring" \
  --channels 019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11,019a5f10-2c41-7a08-b3d2-6e1f4a9c0b12 \
  --at 2026-11-16T09:00 --time-zone Europe/Paris \
  --media https://files.example/spring/cover.jpg \
  --alt "A paper catalogue open on a wooden table, next to a cup of coffee." \
  --json
```

`peal post` never publishes by default, because it needs `--at` or `--now`. With `--idempotency-key`, running it again within 24 hours with the same post makes no second one. Give `--media` as media ids then, because a file or an address is stored anew on each run. [Command line](/developers/cli/posts#post) describes every flag.

## The agent skill [#skill]

The repository holds a skill for agents in the folder [`packages/peal-skills/skills/peal/`](https://github.com/peal-social/peal/tree/main/packages/peal-skills/skills/peal), in the [Agent Skills](https://agentskills.io) format. It's a set of instructions an agent loads when a task calls for Peal.

It teaches the command line and the HTTP API: setting up and checking with `peal doctor --json`, signing in or using a workspace API key, finding channel and media ids, drafting, scheduling and publishing, sending under an idempotency key, reading how a post went, and handling errors and rate limits. Its first two rules are this page's: a draft is safe and publishing is public, and a refusal is never to be worked around. To get it and share it:

- To install it, run `npx skills add peal-social/peal`, which puts it where your agent reads skills, or copy the folder there yourself.
- It's also part of Peal's plugin, which adds the MCP server beside it in the clients that install plugins ([Install Peal's plugin](/developers/mcp#plugin)).
- Peal's site publishes it for discovery, at `https://peal.social/.well-known/agent-skills/index.json`, which lists the skill with its address and its digest.
- It's under the Apache License 2.0, unlike most of the repository, so you can install it, change it and share it.

## Through the HTTP API [#api]

Your own agent or script can call the endpoints the tools are built on, under `/api/v1/` ([API overview](/developers)). With an API key they act in the key's workspace, so no request names it. Another credential sends the `Peal-Workspace` header ([The workspace of a request](/developers/conventions#workspace)). [API conventions](/developers/conventions) describes their errors, paging and limits. Each tool maps to these endpoints:

| Tool                                           | Endpoint                                                                                   |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `list_channels`                                | `GET …/channels`, `GET …/channels/search`                                                  |
| `rename_channel`                               | `PATCH …/channels/{channelId}`                                                             |
| `disable_channel`, `enable_channel`            | `POST …/channels/{channelId}/disable`, `…/enable`                                          |
| `list_media`, `import_media`                   | `GET …/media`, `POST …/media/import`                                                       |
| `list_drafts`, `list_posts`                    | `GET …/posts/drafts`, `GET …/posts`                                                        |
| `create_draft`, `update_draft`                 | `POST …/posts/drafts`, `PUT …/posts/{postId}`                                              |
| `duplicate_post`                               | `POST …/posts/{postId}/duplicate`                                                          |
| `create_post`                                  | `POST …/posts`                                                                             |
| `create_posts`                                 | `POST …/posts/bulk`                                                                        |
| `validate_post`                                | `POST …/posts/validate`                                                                    |
| `schedule_post`                                | `POST …/posts/{postId}/schedule`                                                           |
| `reschedule_post`, `publish_post`              | `POST …/posts/{postId}/reschedule`, with the present instant for now                       |
| `unschedule_post`, `cancel_post`               | `POST …/posts/{postId}/unschedule`, `POST …/posts/{postId}/cancel`                         |
| `get_post`, `list_post_attempts`               | `GET …/posts/{postId}`, `GET …/posts/{postId}/attempts`                                    |
| `list_tags`, `create_tag`                      | `GET …/posts/tags`, `POST …/posts/tags`                                                    |
| `tag_post`                                     | `PUT …/posts/{postId}/tags`                                                                |
| `list_signatures`, `create_signature`          | `GET …/posts/signatures`, `POST …/posts/signatures`                                        |
| `list_channel_sets`, `create_channel_set`      | `GET …/channels/sets`, `POST …/channels/sets`                                              |
| `get_channel_defaults`, `set_channel_defaults` | `GET …/channels/{channelId}/default-options`, `PUT …/channels/{channelId}/default-options` |
| `await_post`                                   | `GET …/posts/{postId}/outcome`                                                             |
| `repost_target`, `confirm_target`              | `POST …/posts/{postId}/targets/{targetId}/repost`, `…/confirm`                             |
| `remove_post_target`                           | `DELETE …/posts/{postId}/targets/{targetId}`                                               |

### Send a post [#api-send]

`POST …/posts` creates a post and sends it in one request. Send an `Idempotency-Key` header so that you can send the request again safely. The key is any text you pick, 255 characters at most, such as a UUID:

```ts Node.js
import { PealClient } from "@peal-social/sdk";

const peal = new PealClient({ token: process.env.PEAL_API_KEY });

const post = await peal.posts.create({
  "idempotency-key": "7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44",
  channelIds: ["019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11"],
  content: {
    text: "Our spring catalogue is out. Read it at https://example.com/spring",
    media: [],
    overrides: [],
  },
  when: { _tag: "at", at: "2026-11-16T08:00:00Z", timeZone: "Europe/Paris" },
});
```

```python Python
import os

from peal import Peal, PostContent, PostTiming_At

peal = Peal(token=os.environ["PEAL_API_KEY"])

post = peal.posts.create(
    idempotency_key="7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44",
    channel_ids=["019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11"],
    content=PostContent(
        text="Our spring catalogue is out. Read it at https://example.com/spring",
        media=[],
        overrides=[],
    ),
    when=PostTiming_At(at="2026-11-16T08:00:00Z", time_zone="Europe/Paris"),
)
```

```go Go
import (
	"context"
	"os"

	peal "github.com/peal-social/peal/packages/peal-sdk/go"
	"github.com/peal-social/peal/packages/peal-sdk/go/client"
	"github.com/peal-social/peal/packages/peal-sdk/go/option"
)

// The client is named `client`, so that `peal` stays the package of the
// request types.
client := client.NewClient(option.WithToken(os.Getenv("PEAL_API_KEY")))

post, err := client.Posts.Create(context.Background(), &peal.NewPost{
	IdempotencyKey: peal.String("7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44"),
	ChannelIDs:     []string{"019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11"},
	Content: &peal.PostContent{
		Text:      "Our spring catalogue is out. Read it at https://example.com/spring",
		Media:     []*peal.MediaAttachment{},
		Overrides: []*peal.TextOverride{},
	},
	When: &peal.PostTiming{
		At: &peal.PostTimingAt{At: "2026-11-16T08:00:00Z", TimeZone: "Europe/Paris"},
	},
})
```

```ruby Ruby
require "peal"

peal = Peal::Client.new(token: ENV.fetch("PEAL_API_KEY"))

post = peal.posts.create(
  idempotency_key: "7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44",
  channel_ids: ["019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11"],
  content: {
    text: "Our spring catalogue is out. Read it at https://example.com/spring",
    media: [],
    overrides: []
  },
  when: { _tag: "at", at: "2026-11-16T08:00:00Z", timeZone: "Europe/Paris" }
)
```

```java Java
import java.util.List;
import social.peal.PealClient;
import social.peal.resources.posts.requests.NewPost;
import social.peal.types.Post;
import social.peal.types.PostContent;
import social.peal.types.PostTiming;
import social.peal.types.PostTimingAt;

PealClient peal = PealClient.builder()
    .token(System.getenv("PEAL_API_KEY"))
    .build();

Post post = peal.posts().create(NewPost.builder()
    .content(PostContent.builder()
        .text("Our spring catalogue is out. Read it at https://example.com/spring")
        .build())
    .when(PostTiming.at(PostTimingAt.builder()
        .at("2026-11-16T08:00:00Z")
        .timeZone("Europe/Paris")
        .build()))
    .idempotencyKey("7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44")
    .channelIds(List.of("019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11"))
    .build());
```

```php PHP
<?php
use Peal\PealClient;
use Peal\Posts\Requests\NewPost;
use Peal\Types\PostContent;
use Peal\Types\PostTiming;
use Peal\Types\PostTimingAt;

$peal = new PealClient(token: getenv('PEAL_API_KEY'));

$post = $peal->posts->create(new NewPost([
    'idempotencyKey' => '7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44',
    'channelIds' => ['019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11'],
    'content' => new PostContent([
        'text' => 'Our spring catalogue is out. Read it at https://example.com/spring',
        'media' => [],
        'overrides' => [],
    ]),
    'when' => PostTiming::at(new PostTimingAt([
        'at' => '2026-11-16T08:00:00Z',
        'timeZone' => 'Europe/Paris',
    ])),
]));
```

```csharp .NET
using Peal;

var peal = new PealClient(Environment.GetEnvironmentVariable("PEAL_API_KEY")!);

var post = await peal.Posts.CreateAsync(new NewPost
{
    IdempotencyKey = "7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44",
    ChannelIds = new List<string> { "019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11" },
    Content = new PostContent
    {
        Text = "Our spring catalogue is out. Read it at https://example.com/spring",
        Media = new List<MediaAttachment>(),
        Overrides = new List<TextOverride>(),
    },
    When = new PostTiming(new PostTiming.At(new PostTimingAt
    {
        At = "2026-11-16T08:00:00Z",
        TimeZone = "Europe/Paris",
    })),
});
```

```rust Rust
use peal_sdk::prelude::*;

let peal = PealClient::new(ClientConfig {
    token: std::env::var("PEAL_API_KEY").ok(),
    ..Default::default()
})?;

// NewPost has no field for the key: it goes in the request's headers.
let post = peal
    .posts
    .create(
        &NewPost::builder()
            .channel_ids(vec!["019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11".to_string()])
            .content(PostContent {
                text: "Our spring catalogue is out. Read it at https://example.com/spring"
                    .to_string(),
                ..Default::default()
            })
            .when(PostTiming::at(
                "2026-11-16T08:00:00Z".to_string(),
                "Europe/Paris".to_string(),
            ))
            .build()?,
        Some(RequestOptions::new().additional_header(
            "Idempotency-Key",
            "7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44",
        )),
    )
    .await?;
```

```bash curl
curl -X POST https://api.example.com/api/v1/posts \
  -H "Authorization: Bearer $PEAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7d1c9a52-0b7e-4f0a-9c1e-3a5b8e2f6d44" \
  -d '{
    "channelIds": ["019a5f10-2c41-7a08-b3d2-6e1f4a9c0b11"],
    "content": {
      "text": "Our spring catalogue is out. Read it at https://example.com/spring",
      "media": [],
      "overrides": []
    },
    "when": { "_tag": "at", "at": "2026-11-16T08:00:00Z", "timeZone": "Europe/Paris" }
  }'
```

What the key does when you send again:

- Within 24 hours, the same key with the same body answers the post the first request made, as it now stands, and makes no other.
- The same key with another body answers 409 `idempotency_key_reused`, and makes nothing. Send a new request under a new key.
- Once that post was deleted, the key answers 404 `post_not_found`. Keys are kept per workspace.

The [SDKs](/developers/sdks) make these calls in eight languages. [Posting through the API](/developers/posting) shows the other requests with examples: checking a post without making it, waiting for the outcome of a post that goes out now, sending several posts at once, importing them from a CSV file, the duplicate refusal, and listing posts with filters.

`POST …/media/import` takes `{ "url": "https://files.example/spring/cover.jpg", "altText": "…" }` and answers the media, as `import_media` does. It needs `media:upload`.

### What a token or a key may put out [#api-publish]

An OAuth token and an API key are held back in different ways:

- An OAuth access token needs the scope `workspace:publish` for every endpoint that needs `post:schedule`: sending, scheduling, moving, unscheduling, cancelling, reposting and confirming. It needs it too for those that need `post:approve`: approving a post that waits, since approving is what sends it out, and asking for changes on it.
- In a workspace that asks for [approvals](/guides/posts/review#policy), what a token or a key sends or schedules isn't refused. It's answered with the status `awaitingApproval`, keeps its time, and goes out only once a person approves it, with no `post.scheduled` [webhook](/developers/webhooks) until then.
- An [API key](/guides/workspace#api-keys) has no scope. It carries the permissions chosen when it was created, so a key without `post:schedule` gets 403 on those endpoints and writes drafts at most.
- The workspace's **API keys** page says of each key whether it **can schedule and publish posts**, which is so when it holds `post:schedule`, `post:publish` or `post:approve`. Give a key those permissions only when the script that holds it must publish.
