Verification methods
Use the public endpoint or the portal’s full-envelope form for a gateway receipt, or verify its signature with a supplied public key. For account lookups by JTI, see Identifiers.
What each verifier accepts
| Entry point | Input | Checks and result |
|---|---|---|
TypeScript SDK verifyReceipt(envelope, publicKeyHex) | One object, including gateway v1, gateway v2, or a signed device envelope | Checks the P-256 signature with the supplied key. Chain links and independent witness verification are outside this call. Returns ok, kind (pass, desktop-only-pass, unverified-witness, or fail), optional reason, and witness_checked: false. |
Browser SDK device verifier and <cloakapi-verify> | A self-contained v3 or legacy cloak-device-receipt, a v3 countersigned entry, or a nonempty chain of device envelopes | Checks the embedded-key signature on a single envelope, and checks sequence and predecessor hashes for a chain. For a countersigned entry it can also check the gateway witness, distinct keys, and receipt-hash binding with the gateway JWKS. Produces a verdict with check details and, for a recognized countersigned entry with a valid device signature, a separate witness status. The device schema rejects gateway v2. |
| Portal receipt verifier | Full JSON for gateway v1 or v2, self-contained v3 or legacy device receipts, or a v3 countersigned entry | Sends gateway envelopes to the public endpoint and displays its verdict. The portal’s in-browser device path checks the embedded-key signature, and the two-party panel checks the gateway witness and receipt-hash binding with the JWKS. An account’s chain export has a separate chain check. |
Public POST /api/v1/receipts/verify | Gateway v1 or v2 as a bare object, a receipt object, or an encoded receipt string. JTI-only input is for campaign fixtures. | Checks schema, algorithm, freshness, gateway signature and the supplied chain block’s linkage invariant. It sees one receipt at a time and performs no independent witness check. Returns valid, reason, and checks (HTTP 200 or 422). A server-resolved fixture skips cryptography and adds mode: "prerender-fixture" and a warning. |
Go VerifyReceipt, Rust and Ruby verify_receipt, PHP and Java verifyReceipt, .NET VerifyReceipt | One signed envelope, including gateway v1, gateway v2, or a signed device envelope | Checks the P-256 signature with the supplied public key, with no chain walk or independent witness check. Returns a result with ok, kind, and reason in the language’s naming convention. A valid signature with a nonempty claims.countersignature object returns unverified-witness and witness_checked: false. The other kinds are pass, desktop-only-pass, and fail. |
The browser helper fetchReceiptByJti takes a hyphenated UUID with version 1–8 and the RFC variant. It calls the public campaign-fixture route without credentials. That route returns 401 auth_required for hyphenated UUIDs, and the helper rejects the alphanumeric IDs that campaign fixtures use. For account receipts, use the authenticated lookup.
For a two-party check, supply the full v3 entry with its receipt and countersignature. See Self-attested portal keys for what the keys establish.
The verify endpoint
POST /api/v1/receipts/verify checks a receipt envelope and returns a per-step result. It needs no API key and allows 30 requests per minute. There are three ways to submit an envelope, plus a fixture-only JTI request.
Shape A: the envelope as the body
Pass the receipt envelope as the root JSON object:
curl -X POST https://api.cloakapi.io/api/v1/receipts/verify \ -H 'Content-Type: application/json' \ -d @receipt.jsonShape B: the envelope in a receipt key
curl -X POST https://api.cloakapi.io/api/v1/receipts/verify \ -H 'Content-Type: application/json' \ -d "{\"receipt\": $(cat receipt.json)}"Shape C: the header value as a string
Pass the X-CloakAPI-Receipt-v2 header value as it arrived, without decoding it:
# $RECEIPT = the entire X-CloakAPI-Receipt-v2 header valuecurl -X POST https://api.cloakapi.io/api/v1/receipts/verify \ -H 'Content-Type: application/json' \ -d "{\"receipt\": \"$RECEIPT\"}"Shape D: a campaign fixture JTI
Send {"jti": "..."} as the entire body to check a campaign fixture by ID. The server resolves the fixture itself and skips the signature check. For a gateway account ID in its issued 32-hex or hyphenated form, this request returns 401 auth_required even if it carries an API key. Fetch the stored envelope through the authenticated detail route or submit the original v2 envelope with shapes A–C.
Response
{ "valid": true, "reason": null, "checks": [ {"label": "Schema valid (OpenReceipt v1)", "status": "ok", "detail": "0.4 ms"}, {"label": "Algorithm allow-listed", "status": "ok", "detail": "ES256"}, {"label": "Freshness (iat / nbf / exp)", "status": "ok", "detail": "iat=1748000000 within window"}, {"label": "Signature (ecdsa-p256-sha256)", "status": "ok", "detail": "8.1 ms"}, {"label": "Chain linkage (seq / prev_hash invariant)", "status": "ok", "detail": "seq 47 links prev_hash 2b9ff4ec3c87…"} ]}For a signed envelope, 200 means the checks passed. With 422 and valid: false, the checks array shows the failed step.
The endpoint returns 400 invalid_payload for an unrecognized body or a receipt string that fails to decode to a JSON object.
Decode the header yourself
The X-CloakAPI-Receipt-v2 response header is a base64-encoded JSON envelope. To send it as shape A, or to check it offline, decode it first:
HEADER_VALUE="<paste base64 from response header here>"echo "$HEADER_VALUE" | base64 -d > receipt.jsoncurl -X POST https://api.cloakapi.io/api/v1/receipts/verify \ -H 'Content-Type: application/json' \ -d @receipt.jsonThe browser verifier
Paste decoded receipt JSON into the portal receipt verifier and select Verify. Pasting a full envelope requires no login. Use the signed-in JTI lookup when you only have the identifier.
Offline against the public JWKS
A receipt is a signed JSON object, so any standard ECDSA P-256 SHA-256 implementation can check it; the verify endpoint is only a convenience. For a gateway-signed v1 or v2 envelope:
jwks = HTTP GET https://api.cloakapi.io/.well-known/openreceipt-pubkeys.jwkskey = jwks.keys.find(k => k.kid == receipt.kid)canon = json_canonicalize(receipt without "sig" and "signature")ok = ecdsa_verify(key, sha256(canon), base64url_decode(receipt.sig)) # raw r||sThe same JWKS is also at https://api.cloakapi.io/api/.well-known/cloakapi-receipt-pubkeys.jwks and https://api.cloakapi.io/api/.well-known/jwks.json. Use the entry whose kid matches. x-cloakapi-status: retired still verifies. A missing kid does not.
Client-signed v3 envelopes carry the attester public key in claims["v3-attestation"].attester_public_key, so you can check them offline without fetching the JWKS: canonicalize the envelope without sig, hash it with SHA-256 and verify against the embedded key, as §8.2 of the v3 specification describes. That key is self-attested. For a v3 portal receipt, Self-attested portal keys explains what the key establishes and how the gateway witness is checked.
Reference implementations in Rust (with a FIPS path through aws-lc-rs) and TypeScript, and a verifier CLI, are described at signedreceipts.org/source.
Reproducing hash_upstream_request
hash_upstream_request, a top-level field of the gateway’s v2 envelope, is the SHA-256 (lowercase hex) of the RFC 8785 JCS canonical form of your JSON request snapshot, taken before the gateway prepares a provider-specific payload. It commits to the request JSON you sent; on its own it does not prove the exact JSON body sent to the provider. When present, hash_provider_request is the separate hash of that prepared payload. To reproduce hash_upstream_request, canonicalize the JSON you submitted with JCS and hash the result:
import canonicalize from 'canonicalize';import { createHash } from 'node:crypto';const h = createHash('sha256').update(canonicalize(JSON.parse(sentBody))).digest('hex');// h === receipt.hash_upstream_request (receipt = the decoded v2 envelope)It is a hash of the canonical JSON, not of the raw bytes, so key order and whitespace between tokens do not matter. Whitespace inside string values does.
The cloak-receipt CLI
The release register lists the Linux and Windows x86-64 cloak-receipt 0.1.0
binaries as withdrawn. Both binary download routes return HTTP 410.
0.1.2 release pending. The candidate includes verification of complete v3 entries and RFC 8785 number formatting.
The public endpoint and the portal’s full-envelope form accept gateway v2 envelopes.
What a receipt check proves and what it does not
A valid receipt shows that the record is intact and was signed by the key it names. It does not show what was or was not detected in your text; see Known limitations.
The offline SDK methods in the table check the signed envelope against the public key you pass to the method. If the envelope contains a nonempty claims.countersignature object, these methods return kind: "unverified-witness" and witness_checked: false: the envelope signature was checked, but the method has not verified an independent witness signature, its receipt_hash binding, or that the witness key is separate from the client or portal key. The result’s reason field links to this section.
The TypeScript browser verifier and the browser portal use a full v3 entry and the gateway JWKS for the additional witness check. They verify the client receipt signature, the gateway countersignature against a published key, the signed receipt_hash against the canonical receipt, and that the gateway key differs from the client or self-attested portal key. These checks need the full entry and the JWKS; an individual envelope plus a supplied key is not the same check. See Self-attested portal keys for the key-identity limits.