CPAPI signatures
Candidate preview. This page describes the candidate Canonical Provider API v1 contract, candidate manifest SHA-256 c85d92a38cd495f7d8a0cf1b5d4b0c2783abdd90f3c51d4827ca24e24d11ea0e. It is non-normative: it explains the contract and does not define it.
Every CPAPI call carries an RFC 9421 HTTP message signature, and the same profile applies in both directions: your server checks our signature on every Control call, and we check yours on every Money call. The keys the cabinet issues are HMAC-SHA256 keys, one per purpose and environment.
Keys and what they sign
Section titled “Keys and what they sign”| Key | Signs | Checked by |
|---|---|---|
| Control key | Every call we make to your Control API | Your server |
| Money key | Every call your server makes to our Money API | Us |
- The secret is 32 random bytes in base64: decode it before you sign or verify.
- Certification and production have separate keys, and the key ID names both, for example
cpapi_certification_control_…orcpapi_production_money_…. A key or tag of the other environment is refused with403wrong_environment_credential; a certification key with the certification tag sent for a live session is refused as described in CPAPI calls.
Building the signature
Section titled “Building the signature”A signed request carries these headers; Content-Digest appears only on calls with a body:
Content-Digest: sha-256=:<base64 SHA-256 of the exact body bytes>:Signature-Input: sig1=<covered components and parameters>Signature: sig1=:<base64 HMAC-SHA256 of the signature base>:The label is always sig1, and the parameters follow the covered components in exactly this order:
| Parameter | Value |
|---|---|
created |
Integer Unix seconds when you sign |
expires |
Integer Unix seconds, at most 300 seconds after created |
nonce |
16 to 128 characters, new for every call |
keyid |
The key ID from the cabinet |
alg |
hmac-sha256 |
tag |
cpapi-money-certification or cpapi-money-live on your calls; cpapi-control-certification or cpapi-control-live on ours |
The signature base has one line per covered component, "<component>": <value>, and a last line "@signature-params": <params>, where <params> is the value of Signature-Input after sig1=. The lines are joined by \n, with no newline at the end, and Signature carries the HMAC-SHA256 of that base under the decoded secret. For a bet in production:
"@method": POST"@authority": api.aggregator.gg"@path": /v1/transactions/bet"content-digest": sha-256=:<base64 SHA-256 of the body>:"@signature-params": ("@method" "@authority" "@path" "content-digest");created=1760000000;expires=1760000300;nonce="<16 to 128 characters>";keyid="cpapi_production_money_…";alg="hmac-sha256";tag="cpapi-money-live"@authority is the host the call is sent to, in lowercase, with a port only when it is not 443: api.aggregator.gg on your Money calls, and the host of your registered API URL on our Control calls. @path is the path exactly as sent; CPAPI calls carry no query string.
Test vector
Section titled “Test vector”Neither certification nor the production checks send a Money call from your server, so check your signer against this worked example before you go live. It is for testing only: the key is public and burned, so never sign a real call with it, and the body is synthetic.
| Input | Value |
|---|---|
| Key ID | cpapi_production_money_00000000000000000000000000000000 |
| Test key in base64 | Y3BhcGktdGVzdC12ZWN0b3ItYnVybmVkLWtleS0wMDE=, the 32 ASCII bytes cpapi-test-vector-burned-key-001 |
| Call | POST https://api.aggregator.gg/v1/transactions/bet |
created and expires |
1760000000 and 1760000300 |
nonce |
00112233445566778899aabbccddeeff |
The body is these 288 bytes of JSON, on one line with no spaces and no newline at the end:
{"tenant_id":"tenant-test-vector","integration_id":"integration-test-vector","environment":"live","session_id":"session-test-vector-1","player_ref":"player-test-vector-1","transaction_id":"txn-test-vector-1","round_id":"round-test-vector-1","amount":{"currency":"EUR","amount_minor":100}}The signature base is:
"@method": POST"@authority": api.aggregator.gg"@path": /v1/transactions/bet"content-digest": sha-256=:ejsUVC/2gHNwM6RKYmSZkXJ+2lZKhholYcvbWwZ4lYg=:"@signature-params": ("@method" "@authority" "@path" "content-digest");created=1760000000;expires=1760000300;nonce="00112233445566778899aabbccddeeff";keyid="cpapi_production_money_00000000000000000000000000000000";alg="hmac-sha256";tag="cpapi-money-live"and the signed headers are:
Content-Digest: sha-256=:ejsUVC/2gHNwM6RKYmSZkXJ+2lZKhholYcvbWwZ4lYg=:Signature-Input: sig1=("@method" "@authority" "@path" "content-digest");created=1760000000;expires=1760000300;nonce="00112233445566778899aabbccddeeff";keyid="cpapi_production_money_00000000000000000000000000000000";alg="hmac-sha256";tag="cpapi-money-live"Signature: sig1=:R9GX6U0TLBLhlI+svFkxE1R2l3ig+ez0YEPToOzjTt0=:The call also carries Content-Type: application/json and its Idempotency-Key, neither of which is signed, so they do not change these values.
Control test vector
Section titled “Control test vector”Use this second example to test the verifier of your Control API before you start a certification run. It is how we sign a session request and a recovery lookup to a studio whose registered API URL is https://studio.example.com. The same rules apply: the key is public and burned, and the values are synthetic.
| Input | Value |
|---|---|
| Key ID | cpapi_production_control_00000000000000000000000000000000 |
| Test key in base64 | Y3BhcGktdGVzdC12ZWN0b3ItYnVybmVkLWtleS0wMDI=, the 32 ASCII bytes cpapi-test-vector-burned-key-002 |
created and expires |
1760000000 and 1760000300 |
Idempotency-Key |
00000000-0000-4000-8000-000000000001 |
Session request. POST https://studio.example.com/v1/sessions with nonce ffeeddccbbaa99887766554433221100 and this 182-byte body, compact JSON with sorted member names and no newline at the end:
{"currency":"EUR","environment":"live","game_id":"game-test-vector-1","integration_id":"integration-test-vector","player_ref":"player-test-vector-1","tenant_id":"tenant-test-vector"}The signature base is:
"@method": POST"@authority": studio.example.com"@path": /v1/sessions"content-digest": sha-256=:UAINvCRwrn7F3oT7iSyuz4U2XX3/dv8pVOS0XDzuwdg=:"idempotency-key": 00000000-0000-4000-8000-000000000001"@signature-params": ("@method" "@authority" "@path" "content-digest" "idempotency-key");created=1760000000;expires=1760000300;nonce="ffeeddccbbaa99887766554433221100";keyid="cpapi_production_control_00000000000000000000000000000000";alg="hmac-sha256";tag="cpapi-control-live"and the request carries:
Content-Type: application/jsonIdempotency-Key: 00000000-0000-4000-8000-000000000001Content-Digest: sha-256=:UAINvCRwrn7F3oT7iSyuz4U2XX3/dv8pVOS0XDzuwdg=:Signature-Input: sig1=("@method" "@authority" "@path" "content-digest" "idempotency-key");created=1760000000;expires=1760000300;nonce="ffeeddccbbaa99887766554433221100";keyid="cpapi_production_control_00000000000000000000000000000000";alg="hmac-sha256";tag="cpapi-control-live"Signature: sig1=:+TsZUnNztasgWcdzY2g1PzP+VxD7Oud2FAy8dWumgVU=:Recovery lookup. GET https://studio.example.com/v1/session-recovery with no body and nonce 0f1e2d3c4b5a69788796a5b4c3d2e1f0:
Idempotency-Key: 00000000-0000-4000-8000-000000000001Signature-Input: sig1=("@method" "@authority" "@path" "idempotency-key");created=1760000000;expires=1760000300;nonce="0f1e2d3c4b5a69788796a5b4c3d2e1f0";keyid="cpapi_production_control_00000000000000000000000000000000";alg="hmac-sha256";tag="cpapi-control-live"Signature: sig1=:FrpU3P9h1QJfBp4B8XwS2sYSZh8KIXqRQceq1Dyeda0=:In certification, the key ID and the tag name certification instead of production and live. The created time of these vectors is in the past, so a verifier that checks the clock refuses them with expired_signature. Test the signature step with the clock check turned off, then test the clock check on its own.
Covered components
Section titled “Covered components”The covered components depend on the call, never on which headers happen to be present:
| Call | Covered components |
|---|---|
POST /v1/sessions |
@method, @authority, @path, content-digest, idempotency-key |
GET /v1/session-recovery |
@method, @authority, @path, idempotency-key |
GET /v1/sessions/{session_id} |
@method, @authority, @path |
POST /v1/demo-sessions (optional demo module) |
@method, @authority, @path, content-digest, idempotency-key |
GET /v1/demo-session-recovery (optional demo module) |
@method, @authority, @path, idempotency-key |
GET /v1/demo-sessions/{demo_session_id} (optional demo module) |
@method, @authority, @path |
POST /v1/balance, POST /v1/transactions/bet, POST /v1/transactions/win, POST /v1/transactions/refund |
@method, @authority, @path, content-digest |
GET /v1/transactions/{transaction_id} |
@method, @authority, @path |
A call signed over any other set is refused. Our session and demo calls sign the exact Idempotency-Key value; on your bets, wins and refunds, send the header separately from the signature. See the refund signing vectors.
Verifying our calls
Section titled “Verifying our calls”Your server checks every Control call before it acts on it, in this order:
- Parse
Signature-Input, and refuse the call with401invalid_signatureunless it covers exactly the components listed above for the call and0 < expires - created <= 300. - Look up the
keyidamong your Control keys: a key ID you do not hold gets401unknown_keyid, and analgother thanhmac-sha256gets401invalid_signature. - Refuse the call with
401expired_signatureunlesscreated - 300 <= now <= expires + 300, wherenowis your clock in Unix seconds. - When there is a body, check
Content-Digestagainst the SHA-256 of the raw body bytes: a mismatch gets401invalid_signature. - Rebuild the signature base from the request and the
Signature-Inputvalue, compute HMAC-SHA256 with your decoded Control secret for thatkeyid, and compare the result withSignaturein constant time: a mismatch gets401invalid_signature. - Refuse a
tagorkeyidof the other environment with403wrong_environment_credential, and a Moneytagof your environment with401invalid_signature. - Only then record the nonce, and refuse a nonce you have seen before with
401replayed_nonce. Checking the signature first means a refused call does not use a nonce up.
Serve exactly the paths of the Control calls: refuse a trailing slash, repeated slashes, dot segments, backslashes or percent escapes instead of normalizing them into one of the calls.
A refused call gets an RFC 9457 problem whose code, type, status, requirement_id and retry_class match our problem registry, plus a title. Certification checks these five:
| When | Status | code |
type |
requirement_id |
retry_class |
|---|---|---|---|---|---|
| The signature does not verify | 401 | invalid_signature |
invalid-signature |
CPAPI-SEC-001 |
never |
| The signature is outside its window | 401 | expired_signature |
expired-signature |
CPAPI-SEC-003 |
never |
| The nonce was used before | 401 | replayed_nonce |
replayed-nonce |
CPAPI-SEC-003 |
never |
| The tag names the other environment | 403 | wrong_environment_credential |
wrong-environment-credential |
CPAPI-SEC-005 |
never |
| A recovery lookup names a key with no recorded session | 404 | session_invalid |
session-invalid |
CPAPI-CONF-001 |
never |
type can be the registry type shown or a URI that ends with it. CPAPI calls lists every registered problem.
Check 13 also swaps the Idempotency-Key on a correctly signed POST /v1/sessions and on a correctly signed GET /v1/session-recovery. Each swapped call must get 401 invalid_signature and leave no session behind: a recovery lookup for the swapped key must get 404 session_invalid. The original call, sent again with its original headers and nonce, must then still succeed: 201 for the session request, and 200 with the same session for the recovery lookup.
Rotation and revocation
Section titled “Rotation and revocation”One key signs at a time.
- Rotate issues a new key and keeps the previous one valid for one hour; the cabinet shows the previous key as valid until then. Rotating again ends the previous key at once.
- Revoke ends a key at once. We stop signing with a revoked Control key, and we refuse calls signed with a revoked Money key with
401revoked_key.
After a Control key rotation, our calls can still be signed with the previous key until its hour is over, so accept both until then. After a Money key rotation, sign with the new key; the previous one keeps working until its hour is over, and after that we refuse it with 401 revoked_key. After changing a certification key, run certification again, then the production checks. After changing only a production key, repeat the production checks; your certification pass stays current if nothing else affecting it has changed. A key change takes a live studio out of live; repeat the affected checks, then go live again, as CPAPI go-live explains.