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.
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
2. Upload the file
Ask for an upload URL with Create a Batch Upload URL, thenPUT the file to it with every header in required_headers:
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 untilstatus is done:
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.upload_id to Create a Batch. Set metadata.name so the batch is easy to find in Command:
202 Accepted
validation_scope, as on Enforce Content.
5. Follow the batch
Poll Get a Batch untilstatus is ended or failed. Every minute is often enough.
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, andflagged, the last two combined).otherappears only when some messages got another verdict, such assend with caution.cost:estimateonce the file is read, andactual, what was billed, once the batch ends.
Example: an ended batch
6. Download the results
When the batch hasended, 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.
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_uniton Get Batch Limits. - A 10,000-message audit of ordinary emails costs about $100.
cost.estimateis set when the file is read.cost.actualis 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.
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 hasstatus: "failed" and a failure.reason. Nothing is billed.
Requests that are refused outright never create a batch:
Related
- Run an Audit from Slack: audit a Slack channel without code.
- Read the Results: the audit page, workbook and report in Command.
- Batches API reference.

