---
title: Posting through the API
description: Check a post before sending it, publish now and wait for the outcome, and understand the duplicate refusal.
sidebar:
  icon: square-pen
---

You can send posts from your own code through the [HTTP API](/developers), the SDKs, the command line or MCP. Each request below has a sample in every language, and the [API reference](/reference) lists every field.

## Before you start [#start]

Every endpoint here is under `/api/v1/posts`. You need an [API key](/guides/workspace#api-keys), which looks like `peal_…`. It acts in its own workspace, so no request names the workspace ([The workspace of a request](/developers/conventions#workspace)).

The samples read the key from `$PEAL_API_KEY`. The first sample builds the client, as [SDKs](/developers/sdks#credential) shows, and the others reuse it: `peal` in every language but Go, where it's `client`. The commands run in the workspace `peal` is signed in to ([Command line](/developers/cli)).

The ids are made up and the answers are shortened. A real answer always holds the whole post, as `GET …/posts/{postId}` returns it.

Each request needs these permissions:

| Request                        | What it does                              | Needs                                        |
| ------------------------------ | ----------------------------------------- | -------------------------------------------- |
| `POST …/posts/validate`        | Checks a post, and makes nothing          | `post:read`, `channel:read`                  |
| `POST …/posts`                 | Creates a post and sends it, now or later | `post:schedule`, `channel:read`              |
| `GET …/posts/{postId}/outcome` | Waits until a post has gone out           | `post:read`                                  |
| `POST …/posts/bulk`            | Creates and sends up to 50 posts          | `post:schedule`, `channel:read`              |
| `POST …/posts/import`          | Creates and sends the posts of a CSV file | `post:schedule`, `post:read`, `channel:read` |
| `GET …/posts`                  | Lists the workspace's posts, with filters | `post:read`, `channel:read`                  |

A post that shows media also needs `media:read`. An OAuth access token needs the scope `workspace:publish` for `create`, `bulk` and `import` ([What each permission allows](/developers/agents#scopes)).

> **Peal can't take back a post once it's out**
>
> What `create`, `bulk` and `import` publish reaches the platforms' public, and
> you can't take it back from Peal once it's out. Until its time, you can still
> cancel or unschedule a post.

## Check a post without making it [#validate]

`POST …/posts/validate` takes the same body as `create`, or a draft's, which has no `when`. It writes nothing. The answer is 200 whether or not the post would go through, with `valid` and every reason it would be refused, all at once.

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

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

const check = await peal.posts.validate({
  channelIds: ["0190f3a0-0000-7000-8000-00000000c001"],
  content: {
    text: "Our spring catalogue is out. Read it at https://example.com/spring #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"])

check = peal.posts.validate(
    channel_ids=["0190f3a0-0000-7000-8000-00000000c001"],
    content=PostContent(
        text="Our spring catalogue is out. Read it at https://example.com/spring #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"
)

client := client.NewClient(option.WithToken(os.Getenv("PEAL_API_KEY")))

check, err := client.Posts.Validate(context.TODO(), &peal.PostToValidate{
	ChannelIDs: []string{"0190f3a0-0000-7000-8000-00000000c001"},
	Content: &peal.PostContent{
		Text:      "Our spring catalogue is out. Read it at https://example.com/spring #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"))

check = peal.posts.validate(
  channel_ids: ["0190f3a0-0000-7000-8000-00000000c001"],
  content: {
    text: "Our spring catalogue is out. Read it at https://example.com/spring #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.*;
import social.peal.types.*;

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

PostValidation check = peal.posts().validate(
    PostToValidate.builder()
        .content(PostContent.builder()
            .text("Our spring catalogue is out. Read it at https://example.com/spring #spring")
            .build())
        .channelIds(List.of("0190f3a0-0000-7000-8000-00000000c001"))
        .when(PostTiming.at(PostTimingAt.builder()
            .at("2026-11-16T08:00:00Z")
            .timeZone("Europe/Paris")
            .build()))
        .build());
```

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

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

$check = $peal->posts->validate(new PostToValidate([
    'channelIds' => ['0190f3a0-0000-7000-8000-00000000c001'],
    'content' => new PostContent([
        'text' => 'Our spring catalogue is out. Read it at https://example.com/spring #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 check = await peal.Posts.ValidateAsync(new PostToValidate
{
    ChannelIds = new List<string> { "0190f3a0-0000-7000-8000-00000000c001" },
    Content = new PostContent
    {
        Text = "Our spring catalogue is out. Read it at https://example.com/spring #spring",
    },
    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()
})?;

let check = peal
    .posts
    .validate(
        &PostToValidate::builder()
            .channel_ids(vec!["0190f3a0-0000-7000-8000-00000000c001".to_string()])
            .content(
                PostContent::builder()
                    .text("Our spring catalogue is out. Read it at https://example.com/spring #spring")
                    .media(vec![])
                    .overrides(vec![])
                    .build()?,
            )
            .when(PostTiming::at(
                "2026-11-16T08:00:00Z".to_string(),
                "Europe/Paris".to_string(),
            ))
            .build()?,
        None,
    )
    .await?;
```

```bash curl
curl -X POST https://api.example.com/api/v1/posts/validate \
  -H "Authorization: Bearer $PEAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channelIds": ["0190f3a0-0000-7000-8000-00000000c001"],
    "content": {
      "text": "Our spring catalogue is out. Read it at https://example.com/spring #spring",
      "media": [],
      "overrides": []
    },
    "when": { "_tag": "at", "at": "2026-11-16T08:00:00Z", "timeZone": "Europe/Paris" }
  }'
```

```sh CLI
peal post "Our spring catalogue is out. Read it at https://example.com/spring #spring" \
  --channel 0190f3a0-0000-7000-8000-00000000c001 \
  --at 2026-11-16T09:00 --time-zone Europe/Paris \
  --dry-run
```

```json MCP (validate_post)
{
  "channelIds": ["0190f3a0-0000-7000-8000-00000000c001"],
  "content": {
    "text": "Our spring catalogue is out. Read it at https://example.com/spring #spring",
    "media": [],
    "overrides": []
  },
  "when": {
    "_tag": "at",
    "at": "2026-11-16T08:00:00Z",
    "timeZone": "Europe/Paris"
  }
}
```

```json
{
  "valid": true,
  "channels": [
    {
      "channelId": "0190f3a0-0000-7000-8000-00000000c001",
      "platform": "bluesky",
      "text": "Our spring catalogue is out. Read it at https://example.com/spring #spring",
      "textCounts": [
        { "length": 74, "maximum": 300, "unit": "graphemes" },
        { "length": 74, "maximum": 3000, "unit": "utf8Bytes" }
      ],
      "hashtags": { "count": 1, "maximum": null },
      "mentions": { "count": 0, "maximum": null },
      "links": { "count": 1, "maximum": null },
      "media": { "count": 0, "maximum": 4 },
      "parts": [],
      "violations": []
    }
  ],
  "violations": [],
  "unknownChannels": [],
  "unknownMedia": [],
  "schedule": "ok",
  "planLimit": null,
  "awaitsApproval": false,
  "duplicates": []
}
```

The answer holds these fields:

| Field             | What it holds                                                                                                                                                                                      |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `valid`           | True when nothing below refuses the post                                                                                                                                                           |
| `channels`        | One entry for each of the workspace's channels the post names, in the order you gave them                                                                                                          |
| `violations`      | What's wrong whatever the channel: no channel at all, or a text or options for a channel the post doesn't go to                                                                                    |
| `unknownChannels` | The channels it names that aren't the workspace's                                                                                                                                                  |
| `unknownMedia`    | The media it shows that aren't the workspace's, or aren't ready                                                                                                                                    |
| `schedule`        | `ok`, `inPast` (more than a minute ago) or `invalidTimeZone` (not an IANA zone). Null without `when`.                                                                                              |
| `planLimit`       | The limit of the workspace's plan the post would pass, as `PlanLimitReached` describes it. Null when the plan has room, on an instance that doesn't bill, or without `when`.                       |
| `awaitsApproval`  | Whether the post, sent as it is, would wait for an [approval](/guides/posts/review) before it's scheduled. It would still be made, with the status `awaitingApproval`. False without `when`.       |
| `duplicates`      | The channels that already get the same content from another post near its time, each with that post ([Duplicate posts](#duplicates)). Empty without `when`, or when the request allows duplicates. |

`awaitsApproval` refuses nothing. It tells you what the workspace asks of this caller.

Each entry of `channels` holds:

| Field                                       | What it holds                                                                                                                                                                                                                                                                                                           |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `text`                                      | The text the channel receives: its override there, or the post's own                                                                                                                                                                                                                                                    |
| `textCounts`                                | That text's length against each of the platform's limits, counted the way the platform counts. Bluesky has two, in graphemes and in bytes.                                                                                                                                                                              |
| `hashtags`, `mentions`, `links` and `media` | How many the post holds (`count`) and the most the platform takes (`maximum`, null when Peal knows no limit). `links` counts distinct links. `media` counts what the channel receives: its own when its override gives some ([Media of its own on a channel](#channel-media)), otherwise the post's.                    |
| `parts`                                     | The parts after the first of a [thread](/guides/posts#threads), in order, each with its `part` (its place, from 1), its `text` on the channel and the same counts. Empty for a single post. A platform that only takes single posts still lists them, and refuses them with `tooManyParts`.                             |
| `violations`                                | Every platform rule the post breaks, in any part (text, media formats, sizes, counts and durations, options), plus the account's own rules where its platform reports them. A violation about a later part names it by `part`. They read as in `PostContentInvalid` ([How refusals read](/developers/agents#refusals)). |

A post that would be refused also gets a 200, with `valid` false:

```json
{
  "valid": false,
  "channels": [
    {
      "channelId": "0190f3a0-0000-7000-8000-00000000c001",
      "platform": "bluesky",
      "textCounts": [
        { "length": 342, "maximum": 300, "unit": "graphemes" },
        { "length": 342, "maximum": 3000, "unit": "utf8Bytes" }
      ],
      "parts": [],
      "violations": [
        {
          "_tag": "textTooLong",
          "channelId": "0190f3a0-0000-7000-8000-00000000c001",
          "platform": "bluesky",
          "length": 342,
          "maximum": 300,
          "unit": "graphemes"
        }
      ]
    }
  ],
  "unknownChannels": ["0190f3a0-0000-7000-8000-00000000c009"],
  "schedule": "inPast"
}
```

Without `when`, the request is checked as a draft, so the time, the plan's room and duplicates aren't checked.

> **A post that's valid now can still be refused later**
>
> That happens if a channel is disconnected or the plan's month fills up in the
> meantime.

## Publish now and wait for the outcome [#wait]

`POST …/posts` answers as soon as the post is made, while it's still publishing. Add `wait`, a number of seconds from 0 to 60, and a post that goes out now is answered once every channel has its result. The `Idempotency-Key` header lets you send the request again safely if the answer is lost ([Idempotency](/developers/conventions/idempotency#idempotency)).

```ts Node.js
const post = await peal.posts.create({
  wait: "30",
  "idempotency-key": "5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90",
  channelIds: [
    "0190f3a0-0000-7000-8000-00000000c001",
    "0190f3a0-0000-7000-8000-00000000c002",
  ],
  content: {
    text: "Our spring catalogue is out. Read it at https://example.com/spring",
    media: [],
    overrides: [],
  },
  when: { _tag: "now" },
});
```

```python Python
from peal import PostTiming_Now

post = peal.posts.create(
    wait="30",
    idempotency_key="5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90",
    channel_ids=[
        "0190f3a0-0000-7000-8000-00000000c001",
        "0190f3a0-0000-7000-8000-00000000c002",
    ],
    content=PostContent(
        text="Our spring catalogue is out. Read it at https://example.com/spring",
        media=[],
        overrides=[],
    ),
    when=PostTiming_Now(),
)
```

```go Go
post, err := client.Posts.Create(context.TODO(), &peal.NewPost{
	Wait:           peal.String("30"),
	IdempotencyKey: peal.String("5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90"),
	ChannelIDs: []string{
		"0190f3a0-0000-7000-8000-00000000c001",
		"0190f3a0-0000-7000-8000-00000000c002",
	},
	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{Now: &peal.PostTimingNow{}},
})
```

```ruby Ruby
post = peal.posts.create(
  wait: "30",
  idempotency_key: "5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90",
  channel_ids: [
    "0190f3a0-0000-7000-8000-00000000c001",
    "0190f3a0-0000-7000-8000-00000000c002"
  ],
  content: {
    text: "Our spring catalogue is out. Read it at https://example.com/spring",
    media: [],
    overrides: []
  },
  when_: { _tag: "now" }
)
```

```java Java
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.now(PostTimingNow.builder().build()))
        .wait("30")
        .idempotencyKey("5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90")
        .channelIds(List.of(
            "0190f3a0-0000-7000-8000-00000000c001",
            "0190f3a0-0000-7000-8000-00000000c002"))
        .build());
```

```php PHP
use Peal\Posts\Requests\NewPost;
use Peal\Types\PostTimingNow;

$post = $peal->posts->create(new NewPost([
    'wait' => '30',
    'idempotencyKey' => '5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90',
    'channelIds' => [
        '0190f3a0-0000-7000-8000-00000000c001',
        '0190f3a0-0000-7000-8000-00000000c002',
    ],
    'content' => new PostContent([
        'text' => 'Our spring catalogue is out. Read it at https://example.com/spring',
        'media' => [],
        'overrides' => [],
    ]),
    'when' => PostTiming::now(new PostTimingNow([])),
]));
```

```csharp .NET
var post = await peal.Posts.CreateAsync(new NewPost
{
    Wait = "30",
    IdempotencyKey = "5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90",
    ChannelIds = new List<string>
    {
        "0190f3a0-0000-7000-8000-00000000c001",
        "0190f3a0-0000-7000-8000-00000000c002",
    },
    Content = new PostContent
    {
        Text = "Our spring catalogue is out. Read it at https://example.com/spring",
    },
    When = new PostTiming(new PostTiming.Now(new PostTimingNow())),
});
```

```rust Rust
// NewPost has no field for the key: it goes in the request's headers.
let post = peal
    .posts
    .create(
        &NewPost::builder()
            .channel_ids(vec![
                "0190f3a0-0000-7000-8000-00000000c001".to_string(),
                "0190f3a0-0000-7000-8000-00000000c002".to_string(),
            ])
            .content(
                PostContent::builder()
                    .text("Our spring catalogue is out. Read it at https://example.com/spring")
                    .media(vec![])
                    .overrides(vec![])
                    .build()?,
            )
            .when(PostTiming::now())
            .wait("30")
            .build()?,
        Some(RequestOptions::new().additional_header(
            "Idempotency-Key",
            "5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90",
        )),
    )
    .await?;
```

```bash curl
curl -X POST "https://api.example.com/api/v1/posts?wait=30" \
  -H "Authorization: Bearer $PEAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90" \
  -d '{
    "channelIds": [
      "0190f3a0-0000-7000-8000-00000000c001",
      "0190f3a0-0000-7000-8000-00000000c002"
    ],
    "content": {
      "text": "Our spring catalogue is out. Read it at https://example.com/spring",
      "media": [],
      "overrides": []
    },
    "when": { "_tag": "now" }
  }'
```

```sh CLI
peal post "Our spring catalogue is out. Read it at https://example.com/spring" \
  --channels 0190f3a0-0000-7000-8000-00000000c001,0190f3a0-0000-7000-8000-00000000c002 \
  --now --wait 30 \
  --idempotency-key 5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90
```

```json MCP (create_post)
{
  "channelIds": [
    "0190f3a0-0000-7000-8000-00000000c001",
    "0190f3a0-0000-7000-8000-00000000c002"
  ],
  "content": {
    "text": "Our spring catalogue is out. Read it at https://example.com/spring",
    "media": [],
    "overrides": []
  },
  "when": { "_tag": "now" },
  "idempotencyKey": "5f0c2b7e-3d1a-4e58-9a6b-2c4d8e1f7a90",
  "waitSeconds": 30
}
```

```json
{
  "id": "0190f3a0-0000-7000-8000-00000000b001",
  "status": "finished",
  "outcome": "partiallyPublished",
  "targets": [
    {
      "id": "0190f3a0-0000-7000-8000-00000000d001",
      "channelId": "0190f3a0-0000-7000-8000-00000000c001",
      "status": "published",
      "publishedAt": "2026-11-16T08:00:02.000Z",
      "permalink": "https://social.example/@peal_example/115512345678901234",
      "failureReason": null
    },
    {
      "id": "0190f3a0-0000-7000-8000-00000000d002",
      "channelId": "0190f3a0-0000-7000-8000-00000000c002",
      "status": "failed",
      "publishedAt": null,
      "permalink": null,
      "failureReason": "tokenExpired"
    }
  ]
}
```

The answer is 201 either way, because the post was made. What it holds depends on the wait:

- When every channel finishes in time, the post's `status` is `finished`, with its `outcome`. Each target is `published`, with its `permalink`, or `failed`, with its `failureReason`.
- When the time runs out first, you get the post as it stands, with some targets still `pending` or `publishing`. It goes on publishing.

A [thread](/guides/posts#threads) has its result on a channel once every part went out there, or one failed. Between two parts, its target stays `publishing`, and `parts.live` lists the parts that are out. If the thread waits longer between parts than `wait`, the time runs out first.

### Wait for the rest [#outcome]

`GET …/posts/{postId}/outcome` takes the same `wait`. It answers once every channel has its result, or with the post as it stands when the time runs out, and then you ask again.

```ts Node.js
const outcome = await peal.posts.outcome({
  postId: "0190f3a0-0000-7000-8000-00000000b001",
  wait: "30",
});
```

```python Python
outcome = peal.posts.outcome(
    post_id="0190f3a0-0000-7000-8000-00000000b001",
    wait="30",
)
```

```go Go
outcome, err := client.Posts.Outcome(context.TODO(), &peal.OutcomePostsRequest{
	PostID: "0190f3a0-0000-7000-8000-00000000b001",
	Wait:   peal.String("30"),
})
```

```ruby Ruby
outcome = peal.posts.outcome(
  post_id: "0190f3a0-0000-7000-8000-00000000b001",
  wait: "30"
)
```

```java Java
Post outcome = peal.posts().outcome(
    "0190f3a0-0000-7000-8000-00000000b001",
    OutcomePostsRequest.builder().wait("30").build());
```

```php PHP
use Peal\Posts\Requests\OutcomePostsRequest;

$outcome = $peal->posts->outcome(
    '0190f3a0-0000-7000-8000-00000000b001',
    new OutcomePostsRequest(['wait' => '30']),
);
```

```csharp .NET
var outcome = await peal.Posts.OutcomeAsync(new OutcomePostsRequest
{
    PostId = "0190f3a0-0000-7000-8000-00000000b001",
    Wait = "30",
});
```

```rust Rust
let outcome = peal
    .posts
    .outcome(
        "0190f3a0-0000-7000-8000-00000000b001",
        &OutcomeQueryRequest::builder().wait("30").build()?,
        None,
    )
    .await?;
```

```bash curl
curl "https://api.example.com/api/v1/posts/0190f3a0-0000-7000-8000-00000000b001/outcome?wait=30" \
  -H "Authorization: Bearer $PEAL_API_KEY"
```

```sh CLI
peal posts wait 0190f3a0-0000-7000-8000-00000000b001 --seconds 30
```

```json MCP (await_post)
{ "postId": "0190f3a0-0000-7000-8000-00000000b001", "waitSeconds": 30 }
```

Without `wait`, it doesn't wait. These requests are also answered at once:

- A request for a draft, a cancelled post, or a post scheduled for later than the wait.
- A request that arrives while the server, or the workspace (10 at once), already has as many requests waiting as it allows. Ask again then.

Waiting changes nothing and holds nothing. The post publishes in its own job either way, and [webhooks](/developers/webhooks/events#events) still tell you how it went on each channel.

## Duplicate posts [#duplicates]

Peal refuses a post when another post of the workspace already sends the same content to one of its channels less than 23 hours from its time. The request answers 409 `DuplicatePost`, and nothing is made:

```json
{
  "_tag": "DuplicatePost",
  "duplicates": [
    {
      "channelId": "0190f3a0-0000-7000-8000-00000000c001",
      "postId": "0190f3a0-0000-7000-8000-00000000b001"
    }
  ]
}
```

`duplicates` names each channel that already gets the content, with the earliest post that sends it there in that window. The check follows these rules:

| Rule             | Detail                                                                                                                                                                                                             |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| The same content | The text the channel receives, and the same media in the same order.                                                                                                                                               |
| 23 hours         | The shortest day any time zone has, so a post that repeats every day at the same local time is never refused.                                                                                                      |
| What counts      | Posts that will go out or went out, including those waiting for an approval, since they go out once approved. Drafts, cancelled posts and a channel where the post failed don't count.                             |
| What is checked  | `create`, each item of `bulk`, each row of `import`, the MCP tools `create_post` and `create_posts`, and `peal post`. Scheduling an existing draft, moving a post and reposting where it failed are never refused. |
| When it's meant  | Send the request again with `allowDuplicate: true` on the post or the bulk item, or with `allow_duplicate` set to `true` on the CSV row.                                                                           |

`validate` reports the same thing beforehand, in `duplicates`.

> **This check is separate from idempotency keys**
>
> A key makes one request safe to send again. The duplicate refusal catches the
> same post requested twice.

## Media of its own on a channel [#channel-media]

A post's text on one channel, an entry of `content.overrides` or of a part's `overrides`, can also give that channel its own images and videos, in `media`. The channel then shows those instead of the post's:

| `media` on an override | What the channel shows                                                                  |
| ---------------------- | --------------------------------------------------------------------------------------- |
| Left out               | The post's images and videos. Peal only returns `media` on an override that gives some. |
| An empty list          | None.                                                                                   |
| A list                 | Those, in order, each with its alt text: 20 at most, ready media of the workspace.      |

An override always has a `text`, and it can't be empty. To give a channel its own media and nothing else, repeat the post's text there. That text then belongs to the channel, so when you change the post's text, change it there too (the web app does this for you).

```json
{
  "text": "Five pictures of the spring catalogue",
  "media": [
    {
      "mediaId": "0190f3a0-0000-7000-8000-00000000f001",
      "altText": "The cover"
    },
    { "mediaId": "0190f3a0-0000-7000-8000-00000000f002", "altText": "Page two" }
  ],
  "overrides": [
    {
      "channelId": "0190f3a0-0000-7000-8000-00000000c001",
      "text": "Five pictures of the spring catalogue",
      "media": [
        {
          "mediaId": "0190f3a0-0000-7000-8000-00000000f002",
          "altText": "Page two"
        }
      ]
    }
  ]
}
```

Media of its own changes a few other rules:

- Each channel is checked on the media it receives, by `validate` (its `media` count and its `violations`) and when the post is scheduled.
- The [duplicate check](#duplicates) compares what each channel receives.
- An approval covers every channel's media. Changing a channel's own media after the post was approved asks for an approval again.
- While a scheduled post shows a file on any channel, you can't delete that file from the library. A draft doesn't hold on to it, on any channel.

## Remove a channel from a scheduled post [#remove-target]

`DELETE …/posts/{postId}/targets/{targetId}` takes one channel off a post that's waiting for its time, scheduled or awaiting approval. The post goes out at its time on its other channels and never on this one. The target becomes `cancelled`, with `"dropped": true`. The post keeps its time and its queue slot, and once it's out, its `outcome` leaves that channel out. The request answers the post.

```ts Node.js
const post = await peal.posts.removeTarget({
  postId: "0190f3a0-0000-7000-8000-00000000b001",
  targetId: "0190f3a0-0000-7000-8000-00000000d002",
});
```

```python Python
post = peal.posts.remove_target(
    post_id="0190f3a0-0000-7000-8000-00000000b001",
    target_id="0190f3a0-0000-7000-8000-00000000d002",
)
```

```go Go
post, err := client.Posts.RemoveTarget(context.TODO(), &peal.RemoveTargetPostsRequest{
	PostID:   "0190f3a0-0000-7000-8000-00000000b001",
	TargetID: "0190f3a0-0000-7000-8000-00000000d002",
})
```

```ruby Ruby
post = peal.posts.remove_target(
  post_id: "0190f3a0-0000-7000-8000-00000000b001",
  target_id: "0190f3a0-0000-7000-8000-00000000d002"
)
```

```java Java
Post post = peal.posts().removeTarget(
    "0190f3a0-0000-7000-8000-00000000b001",
    "0190f3a0-0000-7000-8000-00000000d002");
```

```php PHP
$post = $peal->posts->removeTarget(
    '0190f3a0-0000-7000-8000-00000000b001',
    '0190f3a0-0000-7000-8000-00000000d002',
);
```

```csharp .NET
var post = await peal.Posts.RemoveTargetAsync(new RemoveTargetPostsRequest
{
    PostId = "0190f3a0-0000-7000-8000-00000000b001",
    TargetId = "0190f3a0-0000-7000-8000-00000000d002",
});
```

```rust Rust
let post = peal
    .posts
    .remove_target(
        "0190f3a0-0000-7000-8000-00000000b001",
        "0190f3a0-0000-7000-8000-00000000d002",
        None,
    )
    .await?;
```

```bash curl
curl -X DELETE "https://api.example.com/api/v1/posts/0190f3a0-0000-7000-8000-00000000b001/targets/0190f3a0-0000-7000-8000-00000000d002" \
  -H "Authorization: Bearer $PEAL_API_KEY"
```

```sh CLI
peal posts remove-target 0190f3a0-0000-7000-8000-00000000b001 0190f3a0-0000-7000-8000-00000000d002
```

The request can be refused with these errors:

| Status | Code                     | When                                                                                                              |
| ------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| 409    | `last_target_left`       | The channel is the last one the post still goes out on. Cancel the post instead (`POST …/posts/{postId}/cancel`). |
| 409    | `post_status_conflict`   | The post is publishing or done, or it's a draft, whose channels you change with an update.                        |
| 409    | `target_status_conflict` | The channel was cancelled with its post.                                                                          |

A channel that was already taken off answers the post as it is, so it's safe to send the request again after a lost answer.

Taking a channel off counts as an edit of the post:

- Where your posts need an [approval](/guides/posts/review), the approval no longer covers it. The post is answered `awaitingApproval`, and waits for one again. A post already awaiting approval keeps its request, which now covers the post as it is.
- Webhooks receive a [`post.cancelled`](/developers/webhooks/events/posts#post-cancelled) that names that channel alone, with `scope` `target`.
- A post taken back to draft (`unschedule`, changes requested, or an approval after its time) keeps the channels it still had. The removed channel leaves with its target and its overrides in every part. If you name it again in `channelIds`, it gets a new, pending target.

It needs post:schedule, or, on a post awaiting approval, permission to ask for posts to go out. An OAuth client needs the scope `workspace:publish`.

## Polls and first comments [#polls]

`content.poll` adds a poll to the post's first part, whose text is the question. It has `choices` (2 to 4), `durationMinutes`, and `multipleChoice` (false when left out). Peal only returns it on a post that has one. Send `null`, or leave it out, for none.

A platform's capabilities describe its `poll`: how many choices, their `choiceLimit`, `durationMinutes` (`null` where the platform decides how long) and `multipleChoice`. Where they describe none, a post with a poll is refused with `pollNotSupported`. Each bound the poll breaks has its own violation: `pollChoiceCount`, `pollChoiceLength`, `pollDurationOutOfRange`, `pollMultipleChoice` or `pollWithMedia`. A repeated choice is `pollChoiceRepeated`, and Peal trims the spaces around each choice.

A first comment is the post's single part after its first (`content.followUps`), on platforms whose capabilities give `followUps` of kind `comment`. It's text only, within `commentTextLimits`. The capabilities only offer it where the server reads that platform's comments, so a channel connected before then is refused with `partsNeedReconnect`. Its capabilities say so beforehand, in `account.restrictions`. Some platforms add their own rules:

- On a LinkedIn page, `commentNeeds` says the page's administrator must have connected it.
- A YouTube video made for kids takes no comment (`commentsTurnedOff`).

A comment can fail after the post went live. The post is then `partiallyPublished`, and its target still counts as live for analytics, the inbox and ads. A repost sends the comment alone. `POST …/posts/{postId}/targets/{targetId}/leave-out-rest` publishes the target as a post without it (`partsLeftOut`). The [posts guide](/guides/posts#first-comment) explains how a lost answer is settled.

## From MCP and the command line [#tools]

Each request has an MCP tool or a command, or both:

| Request                                         | MCP tool                          | Command                                          |
| ----------------------------------------------- | --------------------------------- | ------------------------------------------------ |
| `POST …/posts/validate`                         | `validate_post`                   | `peal post … --dry-run`                          |
| `POST …/posts?wait=…`                           | `create_post`, with `waitSeconds` | `peal post … --now --wait <seconds>`             |
| `GET …/posts/{postId}/outcome`                  | `await_post`                      | `peal posts wait <post-id>`                      |
| `POST …/posts/bulk`                             | `create_posts`                    |                                                  |
| `POST …/posts/import`                           |                                   | `peal posts import <file.csv>`                   |
| `GET …/posts`                                   | `list_posts`                      | `peal posts list`                                |
| `POST …/posts/{postId}/queue`                   | `queue_post`                      | `peal posts queue <post-id>`                     |
| `POST …/posts/{postId}/unpublish`               | `unpublish_post`                  | `peal posts unpublish <post-id>`                 |
| `POST …/targets/{targetId}/edit`                | `edit_published_post`             | `peal posts edit <post-id>`                      |
| `GET …/posts/{postId}/changes`                  | `list_post_changes`               | `peal posts changes <post-id>`                   |
| `DELETE …/posts/{postId}/targets/{targetId}`    | `remove_post_target`              | `peal posts remove-target <post-id> <target-id>` |
| `GET …/automations/queues/{queueId}/slots`      | `preview_queue`                   | `peal queues preview <queue>`                    |
| `POST …/automations/queues/{queueId}/reshuffle` | `reshuffle_queue`                 | `peal queues reshuffle <queue>`                  |

[Connect an MCP client](/developers/mcp/tools#tools) describes the tools, and [Command line](/developers/cli/posts#post) the commands.
