Skip to content
OpenPostDocs
OpenPostDocs

Jobs, conflicts, and errors

Use jobs, revisions, and typed errors to rerun SDK automation safely.

Publishing runs in durable jobs. Store the returned Publication ID and job_id so a later process can resume inspection without creating the content again.

const action = await openpost.publications.publishNow(publication.id, publication.revision);
if (action.job_id) {
  const job = await openpost.jobs.wait(action.job_id);
  console.log(job.status);
}

jobs.wait() throws operation_failed when the job reaches a failed state. It does not rerun the action that created the job.

Handle typed errors

import { OpenPostError } from "@getopenpost/sdk";

try {
  await openpost.publications.schedule(id, revision);
} catch (error) {
  if (error instanceof OpenPostError && error.code === "conflict") {
    const current = await openpost.publications.get(id);
    // Compare current with the intended change before trying again.
  }

  if (error instanceof OpenPostError && error.code === "rate_limited") {
    await new Promise((resolve) => setTimeout(resolve, error.retryAfterMs ?? 1_000));
  }
}
CodeAction
missing_configSet the token, workspace, or instance
unauthorizedReplace an invalid, expired, or revoked token
forbiddenCheck token scope, workspace binding, plan, and account state
conflictRead the Publication again and reconcile its revision
validationFix the request or provider validation issues
rate_limitedWait for retryAfterMs
operation_failedInspect the job and Publication events

The SDK retries one failed GET for 429 and server errors. It does not retry mutations because not every write operation is idempotent. Decide whether to replay a mutation only after reading the saved object.

On this page