---
title: "POST /v1/consistency/packets"
description: "Send one packet and read its result, limits, and errors."
---

# POST /v1/consistency/packets

Send one packet and read its result, limits, and errors.

Source URL: https://trymighty.ai/docs/api-reference/consistency-packets

Send documents together as one packet when you need to check whether they agree. The response tells you what needs review and where to find the evidence. This Preview route exists only when Consistency is on for your organization.

```mermaid
flowchart LR
  A["Packet in<br/>documents and known facts"] --> B["Compare<br/>documents and facts"] --> C["Plain answer<br/>what may disagree"] --> D["Proof<br/>where to check"]
```

## Read a result

`summary.headline` counts visible problems across the packet. Each visible finding can include `headline` and `what_to_check`. The summary does not report incomplete checks. Read `status.coverage.complete` and each document's `coverage_complete` with the findings before making a decision. The [playground guide](/docs/consistency/playground) explains the three UI result levels.

## For claims reviewers

Put the documents and the facts they should match in one request. A small packet can return a result at once. A longer run returns a job ID; [check the job](/docs/api-reference/consistency-jobs) for the result.

Read each finding with its document locations. Check `status.coverage.complete` before treating a quiet result as complete. Preview compares only documents in the same packet.

## Technical details

### Authentication

Send the same bearer key as `POST /v1/scan`: `Authorization: Bearer $MIGHTY_API_KEY`. A missing or invalid key returns `401 api_key_required`.

### Request

```http
POST /v1/consistency/packets
Authorization: Bearer $MIGHTY_API_KEY
Idempotency-Key: 7f0c2b1e-packet-0001
Content-Type: multipart/form-data; boundary=...
```

| Part or header | Required | Rules |
| --- | --- | --- |
| `Idempotency-Key` header | Yes | 1 to 255 visible ASCII characters. The same key with the same body returns the same answer. The same key with a different body returns `409`. |
| `mode` query parameter | No | Only `secure` is served. Any other value returns `400 mode_unsupported`. |
| `manifest` part | Yes | The packet manifest as JSON, at most 1 MiB. |
| One part per document | Yes | The part's name is the document's `part` field. Its `Content-Type` must equal the document's `content_type`, and its first bytes must match that type. |

Every document must have a part, and every part other than `manifest` must be a document. A request carries at most 51 parts. The body is read into memory and never written to disk.

Accepted document types: `application/pdf`, `image/png`, `image/jpeg`, `image/tiff`. A PDF counts its pages. An image counts as one page.

### Manifest

The manifest is decoded strictly. An unknown field, a duplicate field name, or a `null` where the field does not allow one returns `400 invalid_json`. Every string is at most 1,024 bytes, except provenance payloads and signatures, which have their own bounds.

Refs such as `subject_ref` and `actor_ref` are opaque. The gateway keys them before the engine sees them. Document ids, claim refs, and line ids come back in the response as you sent them and stay in the sealed evidence, so never put patient data in them.

#### Top level

| Field | Type | Required | Rules |
| --- | --- | --- | --- |
| `pack` | string | Yes | `name@version`, for example `healthcare_opnote_test@5`. A pack your organization may not run returns `400 unknown_pack`. |
| `memory` | string | No | Only `off` in Preview, and the default. `read_write` or `read_only` returns `400 memory_mode_unavailable`. |
| `client_ref` | string | No | Your label for a client or division. `_org` and `_org_all` are reserved and return `400`. |
| `case_ref` | string | No | Your opaque case or claim-file reference. Packets that share it are linked by a keyed hash. |
| `prior_packet_ref` | string | No | The job id of an earlier packet that this one resubmits or amends. It must be a UUID. |
| `scopes` | string[] | No | How far comparisons may reach: `self`, `packet`, `subject`, `actor`, `encounter`, `episode`, `submitter`, `client`, `tenant`. Omitted means every scope your key holds. |
| `facts` | object | No | What you already know about patients, doctors, and visits. See below. |
| `documents` | object[] | Yes | At least one. |
| `claims` | object[] | No | Claim lines that cite the documents. |
| `provenance` | object[] | No | Provenance payloads for documents. |

#### `facts`

Each map is keyed by your opaque ref and holds at most 1,000 entries.

| Field | Entry fields |
| --- | --- |
| `subjects` | `sex` (`F` or `M`), `birth_year` (integer) |
| `submitters` | `specialty`, `practice_ref`, `npi` |
| `actors` | `npi`, `name_norm`, `aliases` (at most 16) |
| `visits` | `modality`, `facility_ref`, `tz`, `episode_ref` |
| `billing_entities` | `kind` |

The engine uses `sex` and `birth_year` to check pronouns, sex-specific words, and age against the note. Without them those checks are skipped.

#### `documents[]`

| Field | Required | Rules |
| --- | --- | --- |
| `id` | Yes | Unique in the packet. |
| `part` | Yes | The multipart part that carries the file. |
| `content_type` | Yes | One of the four accepted types. Another value returns `415 unsupported_content_type`. |
| `declared_type` | No | The pack's heading map to read the document with, for example `operative_report`. It never implies `expected_type`. |
| `expected_type` | No | What the file should be, a `document_type.v1` value such as `invoice`, `repair_estimate`, `claim_form`, `jewelry_grading_report`, or `operative_report`. When set, `document.type_mismatch` compares it with the document-type reading of page 1. Two confusable types (an estimate and an invoice) are not flagged. |
| `subject_ref`, `subject_refs` | No | The patient, or patients for a declared multi-patient document. |
| `submitter_ref`, `actor_ref`, `encounter_ref`, `household_ref` | No | Who sent it, who wrote it, which visit. |
| `issued_at` | No | Date the document claims. |
| `documentation_tool` | No | The EHR or template tool that produced it. |
| `supersedes_document_id` | No | The document this one amends. |

#### `claims[]` and `claims[].lines[]`

| Field | Required | Rules |
| --- | --- | --- |
| `claim_ref` | Yes | Unique in the packet. |
| `original_claim_ref` | No | May be `null`. |
| `frequency_code`, `currency`, `billing_entity_ref`, `encounter_ref` | No | As on the claim. |
| `revision_seq`, `claim_generation`, `predecessor_event_id` | No | Revision order. |
| `lines` | Yes | At least one line. |
| `lines[].line_id` | Yes | Unique in the packet. |
| `lines[].code` | Yes | The billed code, for example `62323`. |
| `lines[].document_ids` | No | Packet document ids that support the line, each at most once. An unknown id returns `400 unknown_document_id`. |
| `lines[].modifiers` | No | At most 4. `LT`, `RT`, and `50` name the side. |
| `lines[].units`, `lines[].charge_cents` | No | Zero or more. |
| `lines[].subject_ref`, `lines[].actor_ref`, `lines[].place_of_service` | No | As on the line. |
| `lines[].service_date_start`, `lines[].service_date_end`, `lines[].service_start_ts`, `lines[].service_end_ts` | No | Dates and optional RFC 3339 times. |
| `lines[].measured_minutes`, `lines[].allowed_cents`, `lines[].paid_cents` | No | May be `null`. |

#### `provenance[]`

| Field | Required | Rules |
| --- | --- | --- |
| `document_id` | Yes | A packet document id. |
| `kind` | Yes | `fhir_provenance`, `fhir_auditevent`, `ehr_attribution`, or `pdf_metadata`. One payload per document and kind. |
| `issuer_id` | No | The issuer. |
| `payload` | No | Any JSON, at most 64 KiB. |
| `signature` | No | At most 16 KiB. |

### Limits

| Limit | Free key | Pro, Premier, or Enterprise key |
| --- | --- | --- |
| Documents | 4 | 50 |
| Pages | 40 | 1,000 |
| Claim lines | 20 | 500 |

A packet over a limit returns `413` with `envelope_documents`, `envelope_pages`, or `envelope_lines`. Past the section cap (40 sections on a Free key, 400 on the others) or 64,000 tokens, the engine drops the lowest-priority sections and sets `status.coverage.complete` to `false` instead of refusing.

### Sync And Async

A packet runs inside the request when sync delivery is on for the gateway and the packet has up to 4 documents and 40 pages. The answer is `200` with the response body. If the run passes the sync deadline (25 seconds by default), you get `202` and the job continues.

Any other packet is accepted for later and answered with `202`:

```json
{
  "job_id": "0b8f6a52-3c1d-4e7a-9f55-2d7c1e9a4b10",
  "state": "queued",
  "attempt": 0,
  "result_version": 0
}
```

The `202` carries `Location: /v1/consistency/jobs/{job_id}` and `Retry-After: 5`. In Preview, async packets are open to test and design-partner organizations only. Another organization gets `403 async_unavailable`.

Send the same `Idempotency-Key` with the same body to replay a request safely. A sync packet whose result exists returns the same bytes it returned the first time.

### Poll A Job

Poll a `202` job with [GET /v1/consistency/jobs/{job_id}](/docs/api-reference/consistency-jobs). That page has the job states, the result, and how to replay a request safely.

### Response

Source of truth: `pkg/consistency/contract/response.go` (`Response`, `Finding`) and `pkg/consistency/contract/location.go` (`Location`).

| Field | Type | Meaning |
| --- | --- | --- |
| `status` | object | Engine, pack, and what was compared. |
| `documents` | object[] | One row per packet document. |
| `findings` | object[] | Findings of promoted rules, in a fixed order, with ids `f1` to `fn`. |
| `cases` | object[] | Always `[]` in Preview. |
| `claims` | object[] | Always `[]` in Preview. |
| `evidence_package_ref` | string | The sealed evidence package for this decision. |
| `provenance` | object | Input hashes and the versions that produced the answer. |
| `summary` | object | Plain summary of visible findings, when available. It does not report coverage. |

### `summary`

| Field | Meaning |
| --- | --- |
| `headline` | Number of visible problems found across the packet documents. |
| `sentence` | Headline of the highest-ranked visible finding, or a message that no problems need review. |
| `counts.documents_checked` | Number of packet documents. |
| `counts.documents_with_problems` | Number of packet documents named by visible findings. |
| `counts.problems` | Number of visible findings. |

#### `status`

| Field | Meaning |
| --- | --- |
| `engine`, `engine_commit` | Engine version and build. |
| `pack`, `pack_sha256` | The pack that ran and its content hash. |
| `memory` | Always `off` in Preview. |
| `key_versions` | `{id, cmp, enc}` key versions. `0` in Preview. |
| `components` | Per-part status. `vision.sections` is `ok` or `partial`. `store` is `ok` or `not_used`. `money` is `unavailable_phase_1`. Other keys name a rule, reference, or document that stood down, with the reason. |
| `coverage.sections_total`, `coverage.sections_probed` | Sections found and sections compared. |
| `coverage.complete` | `false` when sections were dropped or a document was only partly read. |
| `coverage.candidates_verified`, `coverage.families_expanded`, `coverage.unreachable_rows`, `coverage.unreachable_families` | Memory search counters. `0` in Preview. |
| `coverage.incomplete_search`, `coverage.probe_rows_budget_hit` | Memory search flags. `false` in Preview. |
| `coverage.support_complete` | Per code family: `true` when every section that supports it was read. |

#### `documents[]`

| Field | Meaning |
| --- | --- |
| `id` | Your document id. |
| `document_ref` | A stable handle for the stored document. Empty in Preview, because nothing is stored. |
| `status` | `ok`, `ocr_failed`, or the code that refused this one document, such as `clinical_content_requires_baa`. |
| `extracted_text_sha256` | Hash of the text read from the document. |
| `pages` | Pages read. |
| `coverage_complete` | `false` when part of the document was not read or a rule stood down on it. |

#### `findings[]`

| Field | Meaning |
| --- | --- |
| `id` | `f1`, `f2`, and so on, in response order. |
| `rule` | Rule id and version, for example `reuse.identity_swap@4`. |
| `kind` | Rule kind, for example `reuse`, `pull_forward`, `duplicate_line`, `lexicon_contradiction`. |
| `tier` | `strong`, `medium`, or `weak`. |
| `action` | `review`, `warn`, or `none`. |
| `outcome` | `visible`, `permitted`, `permitted_only`, `template_candidate`, `values_repeat`, `pull_forward`, `recorded`, or `withheld`. |
| `tell`, `tell_document` | On a visible pair finding: the tell (`cross_explained` or `history`) and the document that carries it. Absent otherwise. |
| `permitted_only` | `true` when a permission would allow the repeat but its ref is not trusted. |
| `independent_evidence` | `true` for a visible local finding, a duplicate claim line, or an identity conflict. |
| `priority` | The rule's priority from the pack. |
| `confidence` | The rule's measured precision bound. `null` while the rule has none, which is every rule in Preview. |
| `scope` | How far the comparison reached, for example `submitter`. |
| `role` | The section role, for example `narrative`. |
| `subject_doc` | The document the finding is about. |
| `differs` | For a pair: `identity_tokens_only` (only names, IDs, and dates differ), `values` (`repeated`, `not_repeated`, or `absent`), and `slots_changed` (`0`, `1`, or `≥ 2`). A key with the cross-client grant would see the full `values` form; Preview keys do not have that grant. |
| `matched[]` | The other side of a pair: `disclosure` (`ref`, `boolean`, or `withheld`), `ref`, `distance` (in steps of 0.05, where 0 is identical), and `family` (`varies`, `contributors`, `contributors_complete`). A withheld match carries `disclosure` alone. |
| `locations[]` | Where the finding is on your document. |
| `matched_locations[]` | Where it is on the matched document. Each names that document by `ref`. |
| `baseline`, `money`, `family` | Absent in Preview. |
| `headline` | Plain sentence for a visible finding. |
| `what_to_check` | Review step for a visible finding. |
| `evidence` | Disclosed document or claim-field location, with a page when available. Never contains document text or dates. |

#### Locations

| `type` | Fields |
| --- | --- |
| `text_range` | `doc` (or `ref` on the matched side), `start`, `end`, `unit: "codepoint"`. The range is `[start, end)` in the extracted text. |
| `page_region` | `doc` or `ref`, `page` (from 1), `bbox` `[x0, y0, x1, y1]`, `bbox_coordinate_space: "rendered_pixel"`, `page_width`, `page_height`. |
| `structured_field` | `claim_ref`, `line_id`, `field`. A field of one of your claim lines. |
| `document` | `doc` or `ref`. The whole document. |
| `cohort` | `cohort`, `snapshot_id`. |

#### Example

A test organization in evaluation mode sends two operative notes. Y's note (`d2`) repeats X's (`d1`) and still says "he" and "left knee"; Y is female with a right-knee claim.

```json
{
  "status": {
    "engine": "phase1",
    "engine_commit": "efcabb404c1e…",
    "pack": "healthcare_opnote_test@5",
    "pack_sha256": "3b91…",
    "memory": "off",
    "key_versions": { "id": 0, "cmp": 0, "enc": 0 },
    "components": { "vision.sections": "ok", "store": "ok", "money": "unavailable_phase_1" },
    "coverage": {
      "sections_total": 14,
      "sections_probed": 14,
      "candidates_verified": 0,
      "families_expanded": 0,
      "complete": true,
      "unreachable_rows": 0,
      "unreachable_families": 0,
      "incomplete_search": false,
      "probe_rows_budget_hit": false,
      "support_complete": {}
    }
  },
  "documents": [
    { "id": "d1", "document_ref": "", "status": "ok", "extracted_text_sha256": "9c4e…", "pages": 2, "coverage_complete": true },
    { "id": "d2", "document_ref": "", "status": "ok", "extracted_text_sha256": "a71f…", "pages": 2, "coverage_complete": true }
  ],
  "findings": [
    {
      "id": "f1",
      "rule": "reuse.identity_swap@4",
      "kind": "reuse",
      "tier": "medium",
      "action": "warn",
      "outcome": "visible",
      "tell": "cross_explained",
      "tell_document": "d2",
      "permitted_only": false,
      "independent_evidence": false,
      "priority": 20,
      "confidence": null,
      "headline": "This text may name a different person.",
      "what_to_check": "Check whose name appears in the marked text.",
      "evidence": "Document location marked.",
      "scope": "submitter",
      "role": "narrative",
      "subject_doc": "d2",
      "differs": { "identity_tokens_only": true, "values": "repeated", "slots_changed": "0" },
      "matched": [
        {
          "disclosure": "ref",
          "ref": "d1",
          "distance": 0.05,
          "family": { "varies": false, "contributors": "< 3", "contributors_complete": true }
        }
      ],
      "locations": [{ "type": "text_range", "doc": "d2", "start": 412, "end": 988, "unit": "codepoint" }],
      "matched_locations": [{ "type": "text_range", "ref": "d1", "start": 400, "end": 976, "unit": "codepoint" }]
    }
  ],
  "cases": [],
  "claims": [],
  "summary": {
    "headline": "1 problem found across 2 documents.",
    "sentence": "This text may name a different person.",
    "counts": { "documents_checked": 2, "documents_with_problems": 1, "problems": 1 }
  },
  "evidence_package_ref": "5d2e9a0c…",
  "provenance": {
    "input_sha256": { "d1": "e3b0…", "d2": "4f1c…" },
    "rule_versions": { "reuse.identity_swap": 4 },
    "rulebooks": {},
    "rule_flags_snapshot_id": "",
    "baseline_snapshot_ids": [],
    "slot_map_snapshot_ids": []
  }
}
```

### Errors

Error bodies are `{"error": "<message>", "code": "<code>"}`. A refused request is not accepted, stored, or billed. `429` and `503` carry `Retry-After: 5`.

| Status | `code` | When |
| --- | --- | --- |
| `400` | `idempotency_key_required` | The `Idempotency-Key` header is missing or malformed. |
| `400` | `mode_unsupported` | `mode` is not `secure`. |
| `400` | `manifest_missing`, `invalid_manifest`, `invalid_json`, `invalid_pack_ref`, `field_too_long` | The manifest part is missing or does not decode. |
| `400` | `no_documents`, `document_id`, `duplicate_document_id`, `document_part`, `unknown_document_id`, `claim_ref`, `duplicate_claim_ref`, `claim_without_lines`, `claim_line`, `duplicate_line_id`, `sex_value`, `invalid_scope`, `reserved_client_label`, `invalid_prior_packet_ref`, `invalid_provenance_kind`, `duplicate_provenance` | A manifest field breaks a rule above. |
| `400` | `memory_mode_unavailable`, `invalid_memory_mode` | `memory` is not `off`. |
| `400` | `malformed_multipart`, `duplicate_part`, `unexpected_part`, `missing_part`, `empty_part` | The parts do not match the manifest. |
| `400` | `unknown_pack` | The pack does not exist or your organization may not run it. |
| `401` | `api_key_required` | No valid API key. |
| `403` | `attestation_required` | Your organization has not stated whether it is a HIPAA covered entity or business associate. |
| `403` | `baa_required` | Your organization is a covered entity or business associate and the BAA flag is not set. |
| `403` | `incident_stop` | Consistency processing is stopped for your organization. |
| `403` | `async_unavailable` | The packet needs async delivery, which Preview opens to test and design-partner organizations only. |
| `403` | `eval_no_shadow_refused` | The gateway runs in evaluation mode, which serves test organizations only. |
| `404` | none | Consistency is not turned on for this gateway. The route does not exist. |
| `404` | `job_not_found` | No such job for your organization. |
| `402` | none | Not returned by this route. A packet over your key's limits is refused with `413` instead. |
| `409` | `idempotency_key_reused` | The `Idempotency-Key` was used with a different request. |
| `409` | `idempotency_key_in_flight` | The first request with this `Idempotency-Key` is still running. Retry after the delay. |
| `413` | `manifest_too_large`, `manifest_limit`, `too_many_parts` | The manifest or the request is over a size bound. |
| `413` | `envelope_documents`, `envelope_pages`, `envelope_lines` | The packet is over your key's limits. |
| `415` | `multipart_required`, `unsupported_content_type`, `content_type_mismatch` | The body is not multipart, or a document's type is not accepted or does not match its bytes. |
| `429` | `queue_full` | Too many async packets are waiting. |
| `503` | `engine_unavailable`, `sectioner_unavailable`, `store_unavailable`, `org_keys_unavailable`, `queue_unavailable`, `payload_store_unavailable`, `abandoned` | A service the packet needs is not reachable. Retry after the delay. |

A document that the clinical-content check refuses does not fail the packet. Its `documents[].status` names the code, `status.components["vision.sections"]` is `partial`, and the other documents run.

### Billing

Consistency costs 6 SCU per page (an image document counts as one page). A packet is billed once, when its result is committed. For example, a 3-page PDF plus two photos is 5 pages: 5 pages x 6 SCU = 30 SCU. A refused request, a replay with the same `Idempotency-Key`, polling, and an `abandoned` job cost nothing. See [Consistency Privacy And Billing](/docs/consistency/privacy-and-billing#billing).

### Example Request

The two PDFs here are synthetic test documents. Never send real patient data to a Preview gateway.

```bash
cat > manifest.json <<'JSON'
{
  "pack": "healthcare_opnote_test@5",
  "facts": {
    "subjects": {
      "subj-x": { "sex": "M", "birth_year": 1968 },
      "subj-y": { "sex": "F", "birth_year": 1992 }
    }
  },
  "documents": [
    { "id": "d1", "part": "doc_d1", "content_type": "application/pdf", "declared_type": "operative_report",
      "subject_ref": "subj-x", "submitter_ref": "sub-1", "actor_ref": "act-1", "issued_at": "2026-03-02" },
    { "id": "d2", "part": "doc_d2", "content_type": "application/pdf", "declared_type": "operative_report",
      "subject_ref": "subj-y", "submitter_ref": "sub-1", "actor_ref": "act-2", "issued_at": "2026-03-23" }
  ],
  "claims": [
    { "claim_ref": "c1", "currency": "USD",
      "lines": [{ "line_id": "l1", "document_ids": ["d1"], "subject_ref": "subj-x", "code": "27447",
                  "modifiers": ["LT"], "units": 1, "service_date_start": "2026-03-02",
                  "service_date_end": "2026-03-02", "charge_cents": 185000 }] },
    { "claim_ref": "c2", "currency": "USD",
      "lines": [{ "line_id": "l2", "document_ids": ["d2"], "subject_ref": "subj-y", "code": "27447",
                  "modifiers": ["RT"], "units": 1, "service_date_start": "2026-03-23",
                  "service_date_end": "2026-03-23", "charge_cents": 185000 }] }
  ]
}
JSON

curl -X POST https://gateway.trymighty.ai/v1/consistency/packets \
  -H "Authorization: Bearer $MIGHTY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F "manifest=<manifest.json;type=application/json" \
  -F "doc_d1=@./synthetic_opnote_x.pdf;type=application/pdf" \
  -F "doc_d2=@./synthetic_opnote_y.pdf;type=application/pdf"
```

A `200` holds the response. A `202` holds a `job_id`. Poll it:

```bash
curl https://gateway.trymighty.ai/v1/consistency/jobs/0b8f6a52-3c1d-4e7a-9f55-2d7c1e9a4b10 \
  -H "Authorization: Bearer $MIGHTY_API_KEY"
```

### AI-Agent Prompt

### Call the consistency packets API

```text
Integrate POST /v1/consistency/packets (Preview) into this service.

Request:
- multipart/form-data with a "manifest" part (JSON) and one part per document.
- Each documents[].part names its multipart part; the part's Content-Type equals documents[].content_type.
- Accepted types: application/pdf, image/png, image/jpeg, image/tiff.
- Send an Idempotency-Key header (1 to 255 visible ASCII characters). Reuse it only to retry the same request.
- manifest.pack is "name@version". manifest.memory is "off" or omitted.
- Never put patient data in document ids, claim refs, or line ids. Use opaque refs.

Response handling:
- 200: the response body. Route each finding by its action: review, warn, or none.
- 202: store job_id, then GET /v1/consistency/jobs/{job_id} after Retry-After seconds until "result" is present or state is delivered, partial, or abandoned.
- 4xx: do not retry, except 429. Log the code.
- 429 and 503: retry after Retry-After seconds with the same Idempotency-Key.
- The response has no verdict. Do not map findings to BLOCK.

Acceptance criteria:
- Tests cover 200 with findings, 200 with an empty findings list, 202 then poll, 403 baa_required, 404 route missing, 413 envelope_pages, and 429 queue_full.
```
