PubNio checks every post before it sends anything. A dry run returns issues for each destination it can resolve, with paths to the relevant input fields.
Every write is checked
Creating or publishing a post validates the content and every destination. If
anything is wrong, nothing is sent and the call returns 422:
{
"type": "https://pubnio.com/docs/problems/invalid-publication/",
"code": "invalid_publication",
"status": 422,
"issues": [
{
"code": "caption_too_long",
"path": ["targets", 1, "text"],
"message": "This caption contains 312 characters. The limit is 280."
},
{
"code": "media_required",
"path": ["targets", 2, "media"],
"message": "Attach media for this destination."
}
]
}Each issue has a code to branch on, a path to the field, and a message
you can show a person. Error codes lists every code and its fix.
So you do not need a separate check before a one-call publish. Send the post; if it is rejected, fix the listed fields and send it again with a new idempotency key.
Dry run a post body
Send the same body you plan to publish to POST /api/v1/posts/validate.
PubNio checks it as a direct submission without saving a draft or reserving
a queue slot. Use a key with read access to inspect issues. The report sets
canPublish to false when the caller lacks publishing permission.
const report = await workspace.posts.validateBody({
text: "Spring trail guide is live.",
accounts: [instagramId, xId],
});
const readyToSubmit = report.canPublish && !report.billing?.blocked;Issues point to fields in the submitted body. Account selection issues can
include candidates with the IDs and names of matching workspace accounts.
Remote media reachability, live provider permissions, and later changes in
queue availability can affect the actual publish.
Dry run a draft
When a person or another step reviews the post before it goes out, save it as a draft and validate it. Validation never publishes and is always free.
const draft = await workspace.posts.create({
isDraft: true,
text: "Spring trail guide is live.",
targets: [{ accountId: xId }],
});
const report = await workspace.posts.validate(draft.postId);
if (report.canPublish)
await workspace.posts.publish(draft.postId, {
expectedRevision: draft.revision,
});draft = workspace.posts.create(
is_draft=True,
text="Spring trail guide is live.",
targets=[{"accountId": x_id}],
)
report = workspace.posts.validate(draft["postId"])
if report["canPublish"]:
workspace.posts.publish(draft["postId"], expected_revision=draft["revision"])curl -X POST "https://pubnio.com/api/v1/posts/$POST_ID/validate?workspaceId=$WORKSPACE_ID" \
-H "Authorization: Bearer $PUBNIO_API_KEY"pnio posts validate --workspace "$WORKSPACE_ID" "$POST_ID"The command exits non-zero when canPublish is false, so a script can stop
before publishing.
The report covers the whole post and each destination:
| Field | What it tells you |
|---|---|
canPublish |
true when the post passes the checks and the caller can publish. |
errors |
Problems that block publishing. |
warnings |
Conditions to review, such as unverified external media. |
targets[].caption |
Caption length and the destination limit, using provider counting rules. |
targets[].canPublish |
Whether that one destination would be accepted. |
billing |
Estimated cost, publishes left in the plan, and any billing block. |
Edit and publish safely
Every draft has a revision number. Pass it as expectedRevision when you
edit or publish to guard against concurrent changes; both calls also work
without it. If someone changed the draft after you read it, the call
returns post-revision-conflict with currentRevision, so you never publish a
version nobody reviewed. Read the draft again, check it, and retry with the new
revision.
What validation cannot promise
Validation checks the post against each network’s published rules and the
account’s last known state. A network can still refuse a post later, for
example if the account owner revokes access in between. PubNio checks access
and credentials again right before it sends, and a late refusal shows up as a
failed target with an issue. See Post lifecycle.
Ads have their own dry runs: validate a boost or a campaign plan before you create it, and nothing is spent.