After a post is published
Unpublish a post, edit it where it was published, and shorten its links.
Once a post is live, you can still delete it from its platforms or fix its text where it’s published. You can also have its links go out shortened. The samples build the client as Posting through the API explains.
Unpublish a post
Unpublishing deletes a published post from a channel’s platform, for everyone. On a thread, it deletes every part, the last one first (Unpublish a post). Three requests cover it:
| Request | What it does |
|---|---|
POST …/posts/{postId}/targets/{targetId}/unpublish |
Deletes the post from one channel’s platform. |
POST …/posts/{postId}/unpublish |
Asks for it on every channel the post is on. It answers each channel’s change (changes) next to the reasons the others couldn’t (refused), so one channel never fails the whole request. |
GET …/posts/{postId}/changes |
Lists a post’s changes, newest first, with post:read. |
Both unpublish requests need post:publish, and an OAuth client needs the scope workspace:publish.
The request is accepted (202) with the change. A job then deletes the post, one call at a time alongside the channel’s other calls. Add ?wait=<seconds> (60 at most) to wait for it to finish and get the change as it then stands.
import { PealClient } from "@peal-social/sdk";
const peal = new PealClient({ token: process.env.PEAL_API_KEY });
const change = await peal.posts.unpublishTarget({
postId: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
targetId: "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
wait: "30",
});import os
from peal import Peal
peal = Peal(token=os.environ["PEAL_API_KEY"])
change = peal.posts.unpublish_target(
post_id="019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
target_id="019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
wait="30",
)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")))
change, err := client.Posts.UnpublishTarget(context.TODO(), &peal.UnpublishTargetPostsRequest{
PostID: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
TargetID: "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
Wait: peal.String("30"),
})require "peal"
peal = Peal::Client.new(token: ENV.fetch("PEAL_API_KEY"))
change = peal.posts.unpublish_target(
post_id: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
target_id: "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
wait: "30"
)import social.peal.PealClient;
import social.peal.resources.posts.requests.*;
import social.peal.types.LivePostChange;
PealClient peal = PealClient.builder()
.token(System.getenv("PEAL_API_KEY"))
.build();
LivePostChange change = peal.posts().unpublishTarget(
"019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
UnpublishTargetPostsRequest.builder().wait("30").build());<?php
use Peal\PealClient;
use Peal\Posts\Requests\UnpublishTargetPostsRequest;
$peal = new PealClient(token: getenv('PEAL_API_KEY'));
$change = $peal->posts->unpublishTarget(
'019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01',
'019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15',
new UnpublishTargetPostsRequest(['wait' => '30']),
);using Peal;
var peal = new PealClient(Environment.GetEnvironmentVariable("PEAL_API_KEY")!);
var change = await peal.Posts.UnpublishTargetAsync(new UnpublishTargetPostsRequest
{
PostId = "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
TargetId = "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
Wait = "30",
});use peal_sdk::prelude::*;
let peal = PealClient::new(ClientConfig {
token: std::env::var("PEAL_API_KEY").ok(),
..Default::default()
})?;
let change = peal
.posts
.unpublish_target(
"019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
&UnpublishTargetQueryRequest::builder().wait("30").build()?,
None,
)
.await?;curl -X POST "https://peal.example/api/v1/posts/019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01/targets/019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15/unpublish?wait=30" \
-H "Authorization: Bearer $PEAL_API_KEY"peal posts unpublish <post-id> --channel <channel-id> --wait 30 --yes{
"id": "019a7b10-0c21-7d3e-8f41-2a6b5c4d3e10",
"kind": "unpublish",
"postId": "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"targetId": "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
"status": "done",
"partsLeft": 0,
"requestedAt": "2026-11-10T09:00:00.000Z",
"finishedAt": "2026-11-10T09:00:01.000Z",
"code": null
}
The change’s status says where the deletion stands:
status |
Meaning |
|---|---|
pending |
Some parts are left (partsLeft). |
done |
None is left. The target keeps status: published and gets removedAt. GET …/posts?removed=true lists the posts removed from at least one channel. |
failed |
Peal gave up, with a code (unavailable, rateLimited, channelUnavailable, or the platform’s own). Asking again deletes the parts that are left. |
alreadyGone: true means the platform no longer had a part.
When Peal can’t unpublish
Before calling the platform, Peal refuses a request it can’t carry out with 409 live_post_not_changeable. Its reason is one of these:
notPublished,alreadyRemovedorchangeInProgressnoPlatformId, for a post someone confirmed by handnotSupported, where the platform’s capabilities say why, inlivePostchannelUnavailableorboostRunningdeletionWindowPassed, where the platform deletes a post only for a while after it went out (48 hours on Telegram)
GET …/channels/capabilities tells you beforehand where Peal deletes posts. livePost.unpublish says whether it does, and livePost.unpublishBlockedBy (noApi, permission or unverified) says why not. Webhooks receive post.unpublished or post.unpublish_failed (Webhooks).
Edit a published post
POST …/posts/{postId}/targets/{targetId}/edit replaces the text of one part of a published post on one channel’s platform, for everyone (Edit a published post). Peal edits on Mastodon and Google Business Profile.
The body takes two fields:
| Field | What it holds |
|---|---|
text |
The new text |
part |
The part, counted from 0. Left out, it’s the post itself (part 0). |
Only the text changes, never the media, the options or the time. It needs post:publish, and an OAuth client needs the scope workspace:publish. Someone whose posts need an approval can’t edit a published post.
const change = await peal.posts.editTarget({
postId: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
targetId: "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
wait: "30",
text: "Doors open at 7 pm, not 6.",
});change = peal.posts.edit_target(
post_id="019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
target_id="019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
wait="30",
text="Doors open at 7 pm, not 6.",
)change, err := client.Posts.EditTarget(context.TODO(), &peal.LivePostEdit{
PostID: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
TargetID: "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
Wait: peal.String("30"),
Text: "Doors open at 7 pm, not 6.",
})change = peal.posts.edit_target(
post_id: "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
target_id: "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
wait: "30",
text: "Doors open at 7 pm, not 6."
)LivePostChange change = peal.posts().editTarget(
"019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
LivePostEdit.builder()
.text("Doors open at 7 pm, not 6.")
.wait("30")
.build());use Peal\Posts\Requests\LivePostEdit;
$change = $peal->posts->editTarget(
'019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01',
'019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15',
new LivePostEdit([
'wait' => '30',
'text' => 'Doors open at 7 pm, not 6.',
]),
);var change = await peal.Posts.EditTargetAsync(new LivePostEdit
{
PostId = "019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
TargetId = "019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
Wait = "30",
Text = "Doors open at 7 pm, not 6.",
});let change = peal
.posts
.edit_target(
"019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01",
"019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15",
&LivePostEdit::builder()
.text("Doors open at 7 pm, not 6.")
.wait("30")
.build()?,
None,
)
.await?;curl -X POST "https://peal.example/api/v1/posts/019a6f3e-8c2a-7b1e-9f40-3d5a1c2b4e01/targets/019a6f3e-8c2b-7d02-8a11-6e2f9b0c7d15/edit?wait=30" \
-H "Authorization: Bearer $PEAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Doors open at 7 pm, not 6."}'peal posts edit <post-id> --channel <channel-id> --text "Doors open at 7 pm, not 6." --wait 30Peal checks the text the way it checks that channel’s text when a post is scheduled, with a Mastodon content warning counted. A text the platform would refuse answers 422 post_content_invalid with every violation, and so does a text made only of spaces. An empty text answers 400 invalid_request.
The request is accepted (202) with the change (kind: "edit"). A job makes the edit, and retries it the way a deletion is retried. ?wait=<seconds> waits for it to finish. The change never holds the text.
When the edit is done or fails
Once the edit is done, the new text becomes that part’s own text on that channel (in content.overrides, or in the part’s entry of content.followUps). The other channels keep theirs, and the target gets an editedAt. Peal keeps no earlier text.
A change that failed has its code, and you can ask for it again. The code is one of these, or the platform’s own:
postGone, when the platform no longer has the postpollNotEditable, for a Mastodon post with a pollpermissionDenied, for a Mastodon channel that needs reconnecting
Before calling the platform, Peal refuses with 409 live_post_not_changeable, as for a deletion, with approvalRequired as one more reason. A part that isn’t live on that channel is noPlatformId.
Webhooks receive post.edited or post.edit_failed (Webhooks), with the part but never the text. livePost.edit and livePost.editBlockedBy in the capabilities tell you beforehand where Peal edits.
Short links
shortenLinks asks for the post’s links to go out shortened, on a server that has short links. GET …/links/status says whether it does, what a short address starts with and how long it is.
The field works the same on POST …/posts/drafts, PUT …/posts/{postId}, POST …/posts and each item of bulk:
shortenLinks |
What happens |
|---|---|
true |
The links go out shortened. |
false |
The links go out as written. |
| Left out | A new post takes the workspace’s default (byDefault in the status) when it’s made, and keeps it. A draft that changes keeps its earlier choice. |
Every post carries shortenLinks in its answer.
Elsewhere, short links work like this:
validatetakes the field, and checks the text as written, since a short address never makes it longer.- A CSV import has no column for it, so each row takes the workspace’s default.
GET …/linksreads the links and their clicks (Clicks on short links). No endpoint shortens an address outside a post.