# Check a draft before publishing

**Current behavior:** [How SyncWise works](https://github.com/bigskyai/syncwise/blob/main/docs/HOW-IT-WORKS.md).

Send draft text and your public website URL to SyncWise. The paid service compares the draft with freshly captured pages and returns exact passages that may disagree. You or your publishing agent resolve those differences before publishing through your existing tools.

Use the [draft form](/before-publish), or call the API below. Manual agent connections and native plugin development each have their own status in [Works with SyncWise](/works-with); none is an installed marketplace product yet.

## Request

First read `GET /api/pricing` (or `get_audit_pricing` over MCP). `prices.prepublish` is the fixed charge in microUSD; the examples in this guide use a $1 (1,000,000 microUSD) spending cap, not a quoted price. An absent price means the operation is unavailable. Use your owner's API key, approved draft and spend cap. Drafts and context are sent to SyncWise and its configured model provider; exclude credentials and unrelated private data.

`POST https://syncwise.io/api/prepublish/check`

Headers:

- `Authorization: Bearer <your SyncWise API key>` — load from a secret store, never a prompt or checked-in file.
- `Content-Type: application/json`
- `Idempotency-Key: <unique request ID, 8–128 letters/digits/underscores/hyphens>`

```json
{
  "url": "https://example.com/",
  "draft": "Starting December 1, our support team will answer messages seven days a week.",
  "replacesUrl": null,
  "effectiveDate": "2026-12-01",
  "audience": "All customers",
  "maxCostMicrousd": 1000000
}
```

`draft` is plain text or Markdown, maximum 32 KiB of UTF-8 text; it is never silently truncated. The three context fields are optional and can be null. `effectiveDate` uses YYYY-MM-DD. `audience` is at most 1,000 characters. For an update, `replacesUrl` must be a public URL on the supplied site's hostname. That page is excluded from comparisons so intentionally replacing its old text is not itself a conflict; other published pages may still require coordinated updates. Known requested/resolved URL matches are excluded; the service does not infer every CMS alias or canonical URL.

The crawl uses the existing public HTML reader: up to 25 page reads, up to 48,000 UTF-16 characters per captured page (lowered uniformly, never below 8,000, when the pages exceed the input bound), sitemap URLs or link discovery, one hostname with an initial root bare/www redirect allowed. Sitemap indexes are not expanded. Authentication, private-network crawling and JavaScript rendering are unavailable. Model analysis returns up to eight prioritized findings. Limits and all observed gaps are included in the result.

## Response and caller behavior

The response includes:

- `status`: `needs_review`, `no_conflicts_found_in_checked_content`, or `incomplete`.
- `coverageComplete` and `analysisComplete`: separate indicators; `needs_review` can still have incomplete coverage. Coverage complete only means no observed gaps within this bounded collection, never proof the entire site was discovered.
- `publicationAuthorized: false`: SyncWise never grants publishing permission.
- `draftFingerprint`: binds exact draft text and supplied context.
- `audit`: shared evidence contract, `target.kind: "draft_website"`, capture timestamps, source fingerprints, coverage, model analysis, and verified findings. The submitted text is represented as virtual `draft.md`, not a file written to the caller's filesystem. Each finding's first evidence is from the draft and second from a captured website page.
- `usage`: provider-reported input/output tokens and inference cost where available. Null means unavailable. This excludes crawling, infrastructure, payment overhead and failed-attempt costs; it is not the customer price.
- `billing`: operation `prepublish`, actual charge, balance after reservation, and `replayed` flag. The reservation balance is not a current-balance lookup, particularly after a refund or replay.

`potential` conflicts need owner review. `resolved_by_scope` findings explain an apparent difference; exact quotations validate provenance, not model interpretation. The service does not determine the authoritative business policy. No finding means none found in checked content. An incomplete check is never clearance.

Successful results, including incomplete reviews with captured comparison pages, incur the advertised charge. Invalid inputs, missing authorization, insufficient credit and spend-cap failures do not start analysis. No readable comparison pages, malformed analysis, provider failure or entirely unverifiable findings fail the audit and refund its reservation. A process interruption can leave a pending reservation requiring recovery rather than an immediate refund.

## Retries, revisions and publication

1. Create a request ID and retain it with the exact submitted draft/context/cap.
2. On transport failure or uncertain billing, retry that same request and ID. Do not create another charged request to recover the first.
3. The same ID returns the saved result without a second charge. `billing.replayed: true` explicitly means an earlier capture, not a fresh crawl.
4. Reusing an ID with changed draft, context or cap returns 409. A revised draft or intentionally fresh site check requires a new request ID and incurs a new charge.
5. Before publication, confirm the CMS draft/revision still matches the reviewed submission. Captured site pages may also have changed; use the owner's freshness policy and run another check when needed.
6. Resolve findings or obtain an owner-authorized override. Publish through the caller's existing CMS/repository connection. SyncWise has no CMS credentials and does not publish anything.

401 means supply a valid key; 402 means cap/credit needs attention. 409 may indicate changed input, an in-progress reservation, expired replay, or pending operator recovery: inspect `code`. A settled `audit_failed` response has 502 and a zero-charge receipt. A 503 `settlement_pending` requires recovery with the same ID. Missing analyzer or pricing configuration returns 503 without starting a new audit.

A before-publish call protects the workflow that actually calls it. A webhook sent after publication cannot block that publication. Native CMS plugins and enforced publisher/CI gates are separate future work.

## Decisions, export and free recheck

Passage A is the draft and passage B is one published page. The owner can record the same decision as a website review: passage A is correct (update B), passage B is correct (update A), a custom replacement for one side, a legitimate difference, or a decision still needed. The browser keeps those decisions for the site's draft reviews and downloads `syncwise-correction-plan.md`, `syncwise-review.json`, and per-finding `syncwise-correction.md` / `syncwise-correction.json`. Exporting prepares a task for the editor or agent; it does not change the website.

`POST /api/recheck` accepts that packet with the same API key and does not deduct audit credit. Add `revisedDraft` with the full revised draft when the correction is in the draft. Omit it to re-fetch only the published page. The result is `resolved` only when the recorded replacement is present and the original passage at that location is gone, `remains` when the compared text is unchanged, or `unverifiable` when the read fails or the text changed in any other way. A recheck verifies one recorded replacement against its original snapshot; several edits in the same draft need a new draft check. Free rechecks are limited to 20 per original draft check and 60 per account in a rolling hour. See [the agent guide](/for-agents.md) for the shared recheck contract. Hosted MCP callers use `recheck_recorded_correction` with the audit permission; it does not reserve credit.
