---
title: After a post is published
description: Unpublish a post, edit it where it was published, and shorten its links.
sidebar:
  icon: send
---

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](/developers/posting#start) explains.

## Unpublish a post [#unpublish]

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](/guides/posts/published#unpublish)). 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`.

> **Unpublishing can't be undone**
>
> The post is deleted on the platform, for everyone.

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.

```ts Node.js
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",
});
```

```python Python
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",
)
```

```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")))

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"),
})
```

```ruby Ruby
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"
)
```

```java Java
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 PHP
<?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']),
);
```

```csharp .NET
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",
});
```

```rust Rust
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?;
```

```bash curl
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"
```

```sh CLI
peal posts unpublish <post-id> --channel <channel-id> --wait 30 --yes
```

```json
{
  "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 [#unpublish-refused]

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`, `alreadyRemoved` or `changeInProgress`
- `noPlatformId`, for a post someone confirmed by hand
- `notSupported`, where the platform's capabilities say why, in `livePost`
- `channelUnavailable` or `boostRunning`
- `deletionWindowPassed`, 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](/developers/webhooks/events/posts#post-unpublished)).

## Edit a published post [#edit-live]

`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](/guides/posts/published#edit-live)). 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](/guides/posts/review) can't edit a published post.

```ts Node.js
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.",
});
```

```python Python
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.",
)
```

```go Go
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.",
})
```

```ruby Ruby
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."
)
```

```java Java
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());
```

```php PHP
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.',
    ]),
);
```

```csharp .NET
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.",
});
```

```rust Rust
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?;
```

```bash curl
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."}'
```

```sh CLI
peal posts edit <post-id> --channel <channel-id> --text "Doors open at 7 pm, not 6." --wait 30
```

Peal 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 [#edit-result]

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 post
- `pollNotEditable`, for a Mastodon post with a poll
- `permissionDenied`, 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](/developers/webhooks/events/posts#post-edited)), with the part but never the text. `livePost.edit` and `livePost.editBlockedBy` in the capabilities tell you beforehand where Peal edits.

## Short links [#short-links]

`shortenLinks` asks for the post's links to go out [shortened](/guides/posts/published#short-links), 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.

> **Leaving the field out now means the workspace's default**
>
> It used to mean `false` for every post except those the web app made. Once a
> workspace turns the default on, its posts made through the API, MCP, the
> command line and feeds are shortened too. Send `shortenLinks: false` where a
> post's links must go out as written.

Elsewhere, short links work like this:

- `validate` takes 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 …/links` reads the links and their clicks ([Clicks on short links](/guides/engage/analytics#short-links)). No endpoint shortens an address outside a post.
