Skip to content

Edit a draft

PubNio API posts.update: edit a draft. Request fields, examples in five clients, errors, and idempotency.

Edit a draft with PATCH /api/v1/posts/{postId}. Requires an API key with the read scope or a signed-in workspace member.

Request

Edits a draft; a submitted post returns 409 post_submitted. Omitted fields are preserved; supplied media and target arrays replace the saved arrays. Send expectedRevision to guard against editing an older draft.

Parameter In Type Required
postId path UUID Yes
workspaceId query UUID Yes
Body field Type Required
text string No
media array of MediaInput No
scheduledAt string or null No
platforms array of one of 12 strings No
accounts array of UUID No
targets array of CreatePostTarget No
expectedRevision integer No

Response

  • HTTP 200: Post with postId, isDraft, revision, text, media, targets, scheduledAt, deliveries, status, createdAt, updatedAt.
    • status: draft, scheduled, queued, submitting, confirming, published, provider_draft, failed, unresolved, cancelled

The OpenAPI document has each field’s type.

Examples

const post = await workspace.posts.update(postId, {
  text: "Launch moved to Thursday.",
  expectedRevision: 2,
});
post = workspace.posts.update(
    post_id,
    text="Launch moved to Thursday.",
    expected_revision=2,
)
curl -X PATCH "https://pubnio.com/api/v1/posts/$POST_ID?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"Launch moved to Thursday.","expectedRevision":2}'
pnio posts update "$POST_ID" --text "Launch moved to Thursday." --revision 2
async () => {
  const postId = "<postId>";
  const response = await codemode.request({
    method: "PATCH",
    path: `/api/v1/posts/${postId}`,
    query: { workspaceId: codemode.workspaceId },
    body: { text: "Launch moved to Thursday.", expectedRevision: 2 },
  });
  return response.data;
};

Errors

It also declares the problems most operations declare.

Idempotency

No key. Send expectedRevision so a stale retry fails instead of applying twice.

Limits

Type to search…

↑↓ navigate↵ selectEsc close