Skip to main content
A batch checks many messages in one job. Use it to audit a back catalog, such as last quarter’s outbound email, an export from your archive, or a CRM’s message history. You upload one file, ZeroDrift checks every message against your rule packs, and you download the results as JSONL, a spreadsheet, an audit workbook and a PDF report. Batches are for messages that have already been sent. To check a message before it goes out, use Enforce Content.
You can also start an audit without writing code, from Audits in ZeroDrift Command or by running an audit from Slack.

Before you start

  • A full-access API key. Read-only keys can follow and download batches but can’t create them.
  • A billing account with a card on file, under Settings > Billing. Without one, a batch is accepted and then fails with pricing_unavailable.
  • At least one active rule pack. A batch checks against the rule packs active for your account, as Enforce Content does by default.
Check all three in one call with Get Batch Limits:
If billing.has_account is false, set up billing before you go on.

1. Write the file

Put one message per line in a JSONL file. Each line is a JSON object:
emails.jsonl
A file holds up to 100,000 lines and 256 MB.

2. Upload the file

Ask for an upload URL with Create a Batch Upload URL, then PUT the file to it with every header in required_headers:
Send every header in required_headers exactly as given. The URL is signed with them, so a missing or changed header makes the upload fail. The URL expires at expires_at, 15 minutes after you ask for it.
For a few thousand short messages you can skip the upload. Send them inline as items on Create a Batch, up to about 5 MB in one request.

3. Check the file (optional)

Check a Batch Upload reads the whole file with the same rules a batch uses, without creating a batch or billing anything. Start the check, then poll Get a Batch Upload Check until status is done:
Fix the lines it lists, or create the batch with skip_problem_rows: true to drop them. Skipped lines are not billed.

4. Create the batch

A batch is an audit. There’s no separate endpoint to create or start an audit. Creating a batch starts one, and every batch gets an audit report (the workbook and PDF) when it ends. Audits started in Command are batches too. Set metadata.name to give the batch its name in Command’s Audits list.
Pass the upload_id to Create a Batch. Set metadata.name so the batch is easy to find in Command:
202 Accepted
To check against particular rule packs or rules rather than all your active ones, send validation_scope, as on Enforce Content.

5. Follow the batch

Poll Get a Batch until status is ended or failed. Every minute is often enough.
A batch moves through these statuses: Read progress from three fields:
  • request_counts: messages by outcome (processing, succeeded, errored, canceled, expired).
  • verdict_counts: checked messages by verdict (approved, needs_changes, do_not_send, and flagged, the last two combined). other appears only when some messages got another verdict, such as send with caution.
  • cost: estimate once the file is read, and actual, what was billed, once the batch ends.
Example: an ended batch
To stop a running batch, use Cancel a Batch. Messages already checked keep their results and are billed. The rest are not.

6. Download the results

When the batch has ended, its files hold four downloads: Each link is valid for an hour. For a fresh link, get the batch again or call Download a Batch File. Each line of the jsonl file has the message’s custom_id, its metadata if it had any, and a result:
result.type is succeeded, errored, canceled or expired. A succeeded result carries the verdict in validation, in the same shape as Get Verdict, plus what that message cost.
Download the files within 14 days. At files_deleted_at the input, results and reports are deleted and the links become null. The batch record and its counts stay until you delete the batch.

Cost

Batches bill at the Anchor 3.0 (Flagship) validation price, whatever model tier your workspace uses: $0.01 per message of up to 2,000 input tokens. There’s no batch discount and no audit fee.
  • A longer message is billed in units of 2,000 input tokens, rounded up. A 3,000-token email is 2 units, $0.02.
  • Your rate per unit is credit.rate_per_unit on Get Batch Limits.
  • A 10,000-message audit of ordinary emails costs about $100.
  • cost.estimate is set when the file is read. cost.actual is what was billed, set when the batch ends.
  • You’re billed for messages that were checked. Skipped lines, canceled and expired messages, and batches that fail are not billed.
See Pricing for the rates.

Limits

Going over your plan’s running-batch limits returns 429 batch_quota_exceeded. There is no Retry-After header: wait for a batch to end, or cancel one, then try again. Batch limits are separate from the API’s request rate limits.

When a batch fails

A failed batch has status: "failed" and a failure.reason. Nothing is billed. Requests that are refused outright never create a batch: