{
    "openapi": "3.0.3",
    "info": {
        "title": "Casino API",
        "version": "current",
        "description": "The casino API is how your casino's systems send Affiliqo the players, flag changes, activity and real-time events of the players partners bring, and read what became of each delivery.\n\n## Rules every request follows\n\n- The API has one address and no version: it only grows, and a field never changes its meaning.\n- Requests come only from the addresses registered on your keys. A request from any other address is refused before it reaches Affiliqo.\n- Bodies and answers are JSON, with snake_case keys. Times are ISO 8601; answers give them in UTC with `Z`, and requests may use any UTC offset.\n\n## Signing every request\n\nEvery request carries an `Authorization` header that signs it with one of your API keys:\n\n```\nAuthorization: Affiliqo-HMAC-SHA256 key=<key id>, ts=<Unix seconds>, sig=<signature>\n```\n\n- `key` is the key's id, which the Affiliqo team gives you with the key's secret.\n- `ts` is when you sign the request, in Unix seconds. Affiliqo refuses a request signed more than 5 minutes before or after its own clock, so keep your servers' clocks in step with NTP. A retry sent later than that is signed again, with the current time.\n- `sig` is the lowercase hex HMAC-SHA256 of the five lines below, keyed with the key's whole secret, its `afq_live_` or `afq_test_` included. After the Affiliqo team rotates a key's secret, the previous secret keeps working until the overlap they chose ends, so you can switch every server in time.\n\nThe five lines are joined by newlines (`\\n`), with no newline at the end:\n\n1. `ts`, exactly as the header gives it.\n2. The method in capitals, such as `GET`.\n3. The path, and `?` and the query string when there is one, exactly as the request sends them.\n4. The request's `Idempotency-Key`, or nothing, for a request without one.\n5. The lowercase hex SHA-256 of the body exactly as sent, gzipped or not. For a request without a body, that is the SHA-256 of nothing, `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`.\n\n### A worked example\n\nCheck your own code against this example before you send anything. The key is `0192f6a8-3c5e-7b4a-9d1e-5f2a8c3b6d01` and its secret `afq_test_AQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyA`, a test value that is never issued. Reading the batch `0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f` at 2026-10-10 09:01:58 UTC, which is `ts` 1791622918, signs these five lines, the fourth of them empty:\n\n```\n1791622918\nGET\n/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f\n\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n```\n\nThe request then carries:\n\n```\nAuthorization: Affiliqo-HMAC-SHA256 key=0192f6a8-3c5e-7b4a-9d1e-5f2a8c3b6d01, ts=1791622918, sig=6d7071bd117374166f35d7fe8d3a27ed74b6d67fe7ec25c1308ab552d5e08d66\n```\n\nSending a batch also signs its `Idempotency-Key` and its body. The same key, at the same time, sending this 148-byte body to `POST /activity-batches` under the `Idempotency-Key` `activity-2026-10-10T07:00Z-1-b2e46d56`:\n\n```\n{\"brand_id\":\"0192f6a8-1111-7aaa-8bbb-000000000001\",\"currency\":\"EUR\",\"window\":{\"from\":\"2026-10-10T07:00:00Z\",\"to\":\"2026-10-10T08:00:00Z\"},\"items\":[]}\n```\n\nsigns these five lines, the last the SHA-256 of the body:\n\n```\n1791622918\nPOST\n/activity-batches\nactivity-2026-10-10T07:00Z-1-b2e46d56\nb2e46d56cbb6de8c3e11192d9cb08d758edb65885b65f7dfe33789184af84d0e\n```\n\nand carries:\n\n```\nAuthorization: Affiliqo-HMAC-SHA256 key=0192f6a8-3c5e-7b4a-9d1e-5f2a8c3b6d01, ts=1791622918, sig=caf77c21b594b59b636601cdbba99da977db941f18feed0833119700b667ce8b\n```\n\nA gzipped body is signed as the gzip bytes you send, never as the JSON inside.\n\n### The signing helper\n\nEvery operation's code samples sign their request with this helper. Copy the one for your language.\n\nPHP:\n\n```php\n<?php\n\ndeclare(strict_types=1);\n\n/**\n * The Authorization header that signs one request to the Affiliqo casino API.\n *\n * @param  string  $target  the path, and the query string when there is one, exactly as the request sends them\n * @param  string  $idempotencyKey  the request's Idempotency-Key, or '' for a request without one\n * @param  string  $body  the body exactly as the request sends it, gzipped or not; '' for a request without one\n */\nfunction affiliqoAuthorization(string $keyId, string $secret, int $timestamp, string $method, string $target, string $idempotencyKey, string $body): string\n{\n    $lines = implode(\"\\n\", [\n        (string) $timestamp,\n        strtoupper($method),\n        $target,\n        $idempotencyKey,\n        hash('sha256', $body),\n    ]);\n\n    return sprintf('Affiliqo-HMAC-SHA256 key=%s, ts=%d, sig=%s', $keyId, $timestamp, hash_hmac('sha256', $lines, $secret));\n}\n```\n\nNode.js:\n\n```js\nimport { createHash, createHmac } from 'node:crypto';\n\n/**\n * The Authorization header that signs one request to the Affiliqo casino API.\n *\n * @param {string} keyId\n * @param {string} secret\n * @param {number} timestamp Unix seconds\n * @param {string} method\n * @param {string} target the path, and the query string when there is one, exactly as the request sends them\n * @param {string} idempotencyKey the request's Idempotency-Key, or '' for a request without one\n * @param {Buffer|string} body the body exactly as the request sends it, gzipped or not; '' for a request without one\n * @returns {string}\n */\nexport function affiliqoAuthorization(keyId, secret, timestamp, method, target, idempotencyKey, body) {\n  const lines = [\n    String(timestamp),\n    method.toUpperCase(),\n    target,\n    idempotencyKey,\n    createHash('sha256').update(body).digest('hex'),\n  ].join('\\n');\n  const signature = createHmac('sha256', secret).update(lines).digest('hex');\n\n  return `Affiliqo-HMAC-SHA256 key=${keyId}, ts=${timestamp}, sig=${signature}`;\n}\n```\n\nPython:\n\n```python\nimport hashlib\nimport hmac\n\n\ndef affiliqo_authorization(key_id: str, secret: str, timestamp: int, method: str, target: str, idempotency_key: str, body: bytes) -> str:\n    \"\"\"The Authorization header that signs one request to the Affiliqo casino API.\n\n    target is the path, and the query string when there is one, exactly as the request sends them; idempotency_key is\n    the request's Idempotency-Key, or \"\" for a request without one; body is the body exactly as the request sends it,\n    gzipped or not, and b\"\" for a request without one.\n    \"\"\"\n    lines = \"\\n\".join([\n        str(timestamp),\n        method.upper(),\n        target,\n        idempotency_key,\n        hashlib.sha256(body).hexdigest(),\n    ])\n    signature = hmac.new(secret.encode(), lines.encode(), hashlib.sha256).hexdigest()\n\n    return f\"Affiliqo-HMAC-SHA256 key={key_id}, ts={timestamp}, sig={signature}\"\n```\n\nGo:\n\n```go\npackage main\n\nimport (\n\t\"crypto/hmac\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"strings\"\n)\n\n// affiliqoAuthorization is the Authorization header that signs one request to the Affiliqo casino API. target is the\n// path, and the query string when there is one, exactly as the request sends them; idempotencyKey is the request's\n// Idempotency-Key, or \"\" for a request without one; body is the body exactly as the request sends it, gzipped or not,\n// and nil for a request without one.\nfunc affiliqoAuthorization(keyID, secret string, timestamp int64, method, target, idempotencyKey string, body []byte) string {\n\tbodyHash := sha256.Sum256(body)\n\tlines := strings.Join([]string{\n\t\tstrconv.FormatInt(timestamp, 10),\n\t\tstrings.ToUpper(method),\n\t\ttarget,\n\t\tidempotencyKey,\n\t\thex.EncodeToString(bodyHash[:]),\n\t}, \"\\n\")\n\tmac := hmac.New(sha256.New, []byte(secret))\n\tmac.Write([]byte(lines))\n\n\treturn fmt.Sprintf(\"Affiliqo-HMAC-SHA256 key=%s, ts=%d, sig=%s\", keyID, timestamp, hex.EncodeToString(mac.Sum(nil)))\n}\n```\n\n## Sending batches\n\n- Gzip every batch and send `Content-Encoding: gzip`. A body may be up to 5 MB as sent and once inflated.\n- One brand a batch, and for activity one currency and one window: on whole minutes, sent once it has ended, within one day of your program's timezone. An activity batch holds up to 5,000 items, and may hold none, to say you had nothing to send; a player batch up to 1,000 players, and a flag batch up to 5,000 changes.\n- A new player comes with exactly one attribution: the stag, the bonus code or the promo code it signed up with. An update of a player Affiliqo already has may leave it out. Player and flag batches are stored encrypted.\n- A flag change names the player, one to five of its flags, set or unset, and the time it happened, which may be in the past. A player, flag and time appear at most once in a batch.\n- Amounts and counts are JSON integers in minor units, never decimals or text, and only the fields this reference defines: anything else gets 422, so a misspelt figure is never read as 0.\n- Send a window split over several batches one or two at a time.\n- Affiliqo answers 202 with the batch's id and control sums before it processes anything. Compare the sums with your own, and read the batch's status later with its id.\n\n## Sending sign-ups\n\n- Send each new player to `POST /sign-ups` the moment they sign up, with the stag, bonus code or promo code they came with. Affiliqo answers at once with the partner, campaign, promo and stag, or the reason it attributed nobody, and stores the player only when it attributed them, unless it had already accepted an attribution for the player.\n- Keep the stag the answer gives with the player. For a bonus code or promo code it is always the code's own stag. Keep a visitor's stag for at least 90 days, and send the same attribution in the player batches that follow.\n- A code the player typed comes before a stag in your cookie, and a newer stag replaces an older one: send the one that applies.\n- A player's attribution is set by the first one Affiliqo accepts, at the sign-up call or in a player batch; a later one is ignored.\n- The same call sent again under the same `Idempotency-Key` gets the same answer. A 503 `attribution_unavailable` means Affiliqo can't tell yet whether it holds the stag's visit: send the same call again after the seconds `Retry-After` gives.\n\n## Looking up stags and codes\n\n- `GET /attributions` resolves a stag, a bonus code or a promo code as the sign-up call would now, with a key that has the `lookup` scope, and answers in the sign-up answer's form. It stores nothing and issues no stag, and counts as a read.\n\n## Sending events\n\n- Send deposits, first deposits, cashouts and verified identities to `POST /events` as they happen, up to 100 in a request, with a key that has the `events` scope. Registrations go through the sign-up call.\n- Each event has your own id, which Affiliqo records once for the brand, so sending one again changes nothing. A deposit and a first deposit name the deposit, with the id your activity batches list it with.\n- Affiliqo records each event within seconds; events never wait behind batches. They never change figures: deposits, flags and money come only from batches, and cashouts and verified identities are recorded only.\n- An event for a player Affiliqo hasn't received yet waits for them, and is recorded as soon as you send the player.\n- A request of events is answered like a batch, with the kind `events`. Read its status and outcomes as a batch's, with a key that has the `ingest` scope.\n\n## Your profile and health\n\n- `GET /merchant` gives your timezone, each brand's id, products, currencies and sending rhythm, and your capabilities; `GET /health` each brand's ingest health, measured every minute. Any of your keys can read them, and each counts as a read.\n- A brand is `late` when no activity batch, an empty one included, came within its rhythm plus 15 minutes, and `backlogged` when a batch has waited more than 5 minutes. While your ingest is paused, a brand is never late.\n\n## Retries and the Idempotency-Key\n\nEvery write carries an `Idempotency-Key`: your own name for that write, 1 to 255 printable characters without spaces, unique among your casino's writes. Build it from the kind, the window, the chunk and the first 8 hex characters of the JSON's SHA-256, as in `activity-2026-10-10T07:00Z-1-b2e46d56`.\n\n- A retry of the same JSON under the same key gets the first answer again, marked `Idempotent-Replayed: true`, and nothing is stored twice. The JSON may be gzipped anew, for 30 days: after that, a gzipped batch's retry must carry the very bytes sent first, or it is a conflict.\n- The same key with other JSON, or for another kind of write, gets 409 `idempotency_conflict`, and nothing is stored. A corrected window is a new write, under a new key.\n- A request refused before it was stored, such as a 400, 422 or 5xx, keeps nothing, so you can fix it and send it again under the same key.\n- Sign every retry again with the current time: a signature is good for 5 minutes.\n\n## Limits\n\n- Each key may make 120 writes and 600 reads a minute, and send 600 requests of events and 600 sign-up calls a minute on top of them. Past any of these, they get 429 until the minute ends.\n- A request Affiliqo refuses for its `Authorization` header, its time or its key counts toward the address it came from, and one refused for its signature toward that address with that key. After 30 in a minute, further refused requests get 429 until the minute ends.\n- A correctly signed request is never held back by refused ones, so one misconfigured server doesn't stop the others behind the same address.\n\nA 429 from Affiliqo says in `Retry-After` how many seconds to wait.\n\n## Errors\n\nEvery error is a problem document (RFC 9457) with a stable `code`, which your code can rely on, and a `title` and `detail` for people. Affiliqo's own answers are `application/problem+json` and carry the request's `trace_id`, which is also in the `X-Trace-Id` header; a 429 from Affiliqo says in `Retry-After` how many seconds to wait.\n\nAffiliqo refuses a request it can't trust with one of these codes. A 401 also names the scheme to sign with, in `WWW-Authenticate: Affiliqo-HMAC-SHA256`.\n\n| Status | `code` | What to do |\n|---|---|---|\n| 401 | `unauthenticated` | Send the `Authorization` header in the form above. |\n| 401 | `stale_timestamp` | Sign the request again with the current time. The detail gives your time and Affiliqo's; keep your clocks in step with NTP. |\n| 401 | `invalid_key` | The key is unknown, revoked or no longer works. Check the key id, or ask the Affiliqo team for a new key. |\n| 401 | `invalid_signature` | Check the five lines, and that you sign with the key's current secret. |\n| 403 | `address_not_allowed` | The key doesn't list the address the request came from. Ask the Affiliqo team to add it to the key. |\n| 403 | `scope_missing` | The key may not be used for this operation. Ask the Affiliqo team for a key with its scope. |\n\nThe firewall in front of the API refuses two kinds of request itself, before they reach Affiliqo. Its answers have the same `title`, `status`, `code` and `detail`, as `application/json`, without a trace id or `Retry-After`:\n\n| Status | `code` | When |\n|---|---|---|\n| 403 | `address_not_allowed` | The request came from an address no active key lists. Ask the Affiliqo team to add the address to your key. |\n| 429 | `too_many_requests` | Too many requests came from one address. Wait a few minutes, then retry. |\n"
    },
    "servers": [
        {
            "url": "https://api.affiliqo.com",
            "description": "Production"
        },
        {
            "url": "https://api.staging.affiliqo.com",
            "description": "Staging, where your integration is tested first"
        }
    ],
    "security": [
        {
            "Signature": []
        }
    ],
    "paths": {
        "/activity-batches": {
            "post": {
                "operationId": "sendActivityBatch",
                "summary": "Send a window's activity",
                "description": "Sends the activity of one brand's players in one window and one currency: their casino and sportsbook play, their deposits and their cashouts. Affiliqo checks the batch, stores it and answers with its id and control sums before processing anything; compare the sums with your own, and ask for the batch's status later. Send gzipped bodies, a split window's batches one or two at a time, and each window once it has ended. A retry of the same JSON under the same `Idempotency-Key` gets the first answer again, with `Idempotent-Replayed: true`, and is never stored twice.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    },
                    {
                        "$ref": "#/components/parameters/ContentEncoding"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ActivityBatch"
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "The batch is stored and will be processed; or, for a retry under the same key, its first answer again.",
                        "headers": {
                            "Idempotent-Replayed": {
                                "description": "`true` when this is the first answer to an earlier request under the same key, sent again.",
                                "schema": {
                                    "type": "string",
                                    "enum": [
                                        "true"
                                    ]
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Batch"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/PayloadTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidBatch"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Sends one window's activity, gzipped. signature.php is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nrequire __DIR__.'/signature.php';\n\n$json = (string) json_encode([\n    'brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001',\n    'currency' => 'EUR',\n    'window' => ['from' => '2026-10-10T07:00:00Z', 'to' => '2026-10-10T08:00:00Z'],\n    'items' => [\n        ['casino_player_id' => 'player-1', 'casino' => ['bets' => 125000, 'wins' => 98000], 'deposits' => [['id' => 'deposit-1', 'amount' => 5000, 'at' => '2026-10-10T07:12:09Z']]],\n    ],\n]);\n$body = (string) gzencode($json);\n// The kind, the window, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\n$idempotencyKey = 'activity-2026-10-10T07:00Z-1-'.substr(hash('sha256', $json), 0, 8);\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'POST', '/activity-batches', $idempotencyKey, $body);\n\n$curl = curl_init('https://api.affiliqo.com/activity-batches');\ncurl_setopt_array($curl, [\n    CURLOPT_POST => true,\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_HTTPHEADER => [\n        'Authorization: '.$authorization,\n        'Content-Type: application/json',\n        'Content-Encoding: gzip',\n        'Idempotency-Key: '.$idempotencyKey,\n    ],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 202) {\n    // Compare the control sums with your own, and keep the id to ask for the batch's status.\n    echo $answer['id'], ' ', $answer['status'], ' ', $answer['control_sums']['items'], PHP_EOL;\n} else {\n    // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Sends one window's activity, gzipped. signature.mjs is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nimport { createHash } from 'node:crypto';\nimport { gzipSync } from 'node:zlib';\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst json = JSON.stringify({\n  brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001',\n  currency: 'EUR',\n  window: { from: '2026-10-10T07:00:00Z', to: '2026-10-10T08:00:00Z' },\n  items: [\n    { casino_player_id: 'player-1', casino: { bets: 125000, wins: 98000 }, deposits: [{ id: 'deposit-1', amount: 5000, at: '2026-10-10T07:12:09Z' }] },\n  ],\n});\nconst body = gzipSync(json);\n// The kind, the window, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\nconst idempotencyKey = `activity-2026-10-10T07:00Z-1-${createHash('sha256').update(json).digest('hex').slice(0, 8)}`;\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch('https://api.affiliqo.com/activity-batches', {\n  method: 'POST',\n  body,\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'POST', '/activity-batches', idempotencyKey, body),\n    'Content-Type': 'application/json',\n    'Content-Encoding': 'gzip',\n    'Idempotency-Key': idempotencyKey,\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(30_000),\n});\nconst answer = await response.json();\n\nif (response.status === 202) {\n  // Compare the control sums with your own, and keep the id to ask for the batch's status.\n  console.log(answer.id, answer.status, answer.control_sums.items);\n} else {\n  // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Sends one window's activity, gzipped. signature.py is the signing helper from the guide; the key's id and secret\n# come from your secret store.\nimport gzip\nimport hashlib\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\npayload = json.dumps({\n    \"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n    \"currency\": \"EUR\",\n    \"window\": {\"from\": \"2026-10-10T07:00:00Z\", \"to\": \"2026-10-10T08:00:00Z\"},\n    \"items\": [\n        {\"casino_player_id\": \"player-1\", \"casino\": {\"bets\": 125000, \"wins\": 98000}, \"deposits\": [{\"id\": \"deposit-1\", \"amount\": 5000, \"at\": \"2026-10-10T07:12:09Z\"}]},\n    ],\n}, separators=(\",\", \":\")).encode()\nbody = gzip.compress(payload)\n# The kind, the window, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\nidempotency_key = \"activity-2026-10-10T07:00Z-1-\" + hashlib.sha256(payload).hexdigest()[:8]\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"POST\", \"/activity-batches\", idempotency_key, body)\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com/activity-batches\",\n    data=body,\n    method=\"POST\",\n    headers={\n        \"Authorization\": authorization,\n        \"Content-Type\": \"application/json\",\n        \"Content-Encoding\": \"gzip\",\n        \"Idempotency-Key\": idempotency_key,\n        \"User-Agent\": \"your-casino-affiliqo-client/1.0\",\n    },\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        # Compare the control sums with your own, and keep the id to ask for the batch's status.\n        answer = json.load(response)\n        print(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"][\"items\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Sends one window's activity, gzipped. affiliqoAuthorization is the signing helper from the guide; the key's id and\n// secret come from your secret store.\nfunc main() {\n\tpayload, err := json.Marshal(map[string]any{\n\t\t\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n\t\t\"currency\": \"EUR\",\n\t\t\"window\":   map[string]string{\"from\": \"2026-10-10T07:00:00Z\", \"to\": \"2026-10-10T08:00:00Z\"},\n\t\t\"items\": []map[string]any{\n\t\t\t{\"casino_player_id\": \"player-1\", \"casino\": map[string]int64{\"bets\": 125000, \"wins\": 98000}, \"deposits\": []map[string]any{{\"id\": \"deposit-1\", \"amount\": 5000, \"at\": \"2026-10-10T07:12:09Z\"}}},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar body bytes.Buffer\n\twriter := gzip.NewWriter(&body)\n\twriter.Write(payload)\n\twriter.Close()\n\n\t// The kind, the window, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\n\thash := sha256.Sum256(payload)\n\tidempotencyKey := \"activity-2026-10-10T07:00Z-1-\" + hex.EncodeToString(hash[:])[:8]\n\n\trequest, err := http.NewRequest(http.MethodPost, \"https://api.affiliqo.com/activity-batches\", bytes.NewReader(body.Bytes()))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodPost, \"/activity-batches\", idempotencyKey, body.Bytes()))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\trequest.Header.Set(\"Content-Encoding\", \"gzip\")\n\trequest.Header.Set(\"Idempotency-Key\", idempotencyKey)\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 30 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusAccepted {\n\t\t// Compare the control sums with your own, and keep the id to ask for the batch's status.\n\t\tfmt.Println(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"])\n\t} else {\n\t\t// A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/sign-ups": {
            "post": {
                "operationId": "sendSignUp",
                "summary": "Tell Affiliqo of a new player at sign-up",
                "description": "Sends one new player the moment they sign up, with the stag, bonus code or promo code they came with, and answers at once who they belong to: the partner, campaign, promo and stag, or why nobody. Keep the stag the answer gives: for a code it is always the code's own. Send the same attribution in the player batches that follow. The same call sent again under the same `Idempotency-Key` gets the same answer, with `Idempotent-Replayed: true`. Affiliqo stores the player only when it attributed them, and for the partner of the first attribution it accepted for the player, at this call or in a player batch. A 503 `attribution_unavailable` means Affiliqo can't tell yet whether it holds the stag's visit: send the same call again after the seconds `Retry-After` gives.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    },
                    {
                        "$ref": "#/components/parameters/ContentEncoding"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SignUp"
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "The sign-up is stored and answered; or, for a retry under the same key, its first answer again.",
                        "headers": {
                            "Idempotent-Replayed": {
                                "description": "`true` when this is the first answer to an earlier request under the same key, sent again.",
                                "schema": {
                                    "type": "string",
                                    "enum": [
                                        "true"
                                    ]
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SignUpAccepted"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/PayloadTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidBatch"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/SignUpUnavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Tells Affiliqo of a new player the moment they sign up, and reads who they belong to. signature.php is the signing\n// helper from the guide; the key's id and secret come from your secret store.\nrequire __DIR__.'/signature.php';\n\n$body = (string) json_encode([\n    'brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001',\n    'player' => [\n        'casino_player_id' => 'player-1',\n        'signed_up_at' => '2026-10-10T07:12:09Z',\n        'email_hash' => hash('sha256', strtolower('Jane@example.com')),\n        'attribution' => ['stag' => '1042_10000614'],\n    ],\n]);\n// One key per sign-up: a retry keeps it, so it gets the same answer.\n$idempotencyKey = 'sign-up-player-1';\n\nfor ($attempt = 1; $attempt <= 3; $attempt++) {\n    $authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'POST', '/sign-ups', $idempotencyKey, $body);\n    $curl = curl_init('https://api.affiliqo.com/sign-ups');\n    curl_setopt_array($curl, [\n        CURLOPT_POST => true,\n        CURLOPT_POSTFIELDS => $body,\n        CURLOPT_HTTPHEADER => [\n            'Authorization: '.$authorization,\n            'Content-Type: application/json',\n            'Idempotency-Key: '.$idempotencyKey,\n        ],\n        CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n        CURLOPT_RETURNTRANSFER => true,\n        CURLOPT_TIMEOUT => 10,\n    ]);\n    $answer = json_decode((string) curl_exec($curl), true);\n    $status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);\n\n    if ($status === 202) {\n        // Keep the stag with the player: for a code it is the code's own.\n        echo $answer['attribution']['result'], ' ', $answer['attribution']['stag'] ?? $answer['attribution']['reason'], PHP_EOL;\n\n        break;\n    }\n\n    if ($status !== 503) {\n        // A problem document: act on its code.\n        fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n\n        break;\n    }\n\n    // Affiliqo can't tell yet whether it holds the stag's visit: send the same call again shortly.\n    sleep(5);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Tells Affiliqo of a new player the moment they sign up, and reads who they belong to. signature.mjs is the signing\n// helper from the guide; the key's id and secret come from your secret store.\nimport { createHash } from 'node:crypto';\nimport { setTimeout as sleep } from 'node:timers/promises';\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst body = JSON.stringify({\n  brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001',\n  player: {\n    casino_player_id: 'player-1',\n    signed_up_at: '2026-10-10T07:12:09Z',\n    email_hash: createHash('sha256').update('Jane@example.com'.toLowerCase()).digest('hex'),\n    attribution: { stag: '1042_10000614' },\n  },\n});\n// One key per sign-up: a retry keeps it, so it gets the same answer.\nconst idempotencyKey = 'sign-up-player-1';\n\nfor (let attempt = 1; attempt <= 3; attempt++) {\n  const timestamp = Math.floor(Date.now() / 1000);\n  const response = await fetch('https://api.affiliqo.com/sign-ups', {\n    method: 'POST',\n    body,\n    headers: {\n      Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'POST', '/sign-ups', idempotencyKey, body),\n      'Content-Type': 'application/json',\n      'Idempotency-Key': idempotencyKey,\n      'User-Agent': 'your-casino-affiliqo-client/1.0',\n    },\n    signal: AbortSignal.timeout(10_000),\n  });\n  const answer = await response.json();\n\n  if (response.status === 202) {\n    // Keep the stag with the player: for a code it is the code's own.\n    console.log(answer.attribution.result, answer.attribution.stag ?? answer.attribution.reason);\n    break;\n  }\n\n  if (response.status !== 503) {\n    // A problem document: act on its code.\n    console.error(answer.code, answer.trace_id);\n    break;\n  }\n\n  // Affiliqo can't tell yet whether it holds the stag's visit: send the same call again shortly.\n  await sleep(5_000);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Tells Affiliqo of a new player the moment they sign up, and reads who they belong to. signature.py is the signing\n# helper from the guide; the key's id and secret come from your secret store.\nimport hashlib\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\nbody = json.dumps({\n    \"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n    \"player\": {\n        \"casino_player_id\": \"player-1\",\n        \"signed_up_at\": \"2026-10-10T07:12:09Z\",\n        \"email_hash\": hashlib.sha256(\"Jane@example.com\".lower().encode()).hexdigest(),\n        \"attribution\": {\"stag\": \"1042_10000614\"},\n    },\n}, separators=(\",\", \":\")).encode()\n# One key per sign-up: a retry keeps it, so it gets the same answer.\nidempotency_key = \"sign-up-player-1\"\n\nfor attempt in range(3):\n    authorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"POST\", \"/sign-ups\", idempotency_key, body)\n    request = urllib.request.Request(\n        \"https://api.affiliqo.com/sign-ups\",\n        data=body,\n        method=\"POST\",\n        headers={\n            \"Authorization\": authorization,\n            \"Content-Type\": \"application/json\",\n            \"Idempotency-Key\": idempotency_key,\n            \"User-Agent\": \"your-casino-affiliqo-client/1.0\",\n        },\n    )\n\n    try:\n        with urllib.request.urlopen(request, timeout=10) as response:\n            # Keep the stag with the player: for a code it is the code's own.\n            attribution = json.load(response)[\"attribution\"]\n            print(attribution[\"result\"], attribution[\"stag\"] or attribution[\"reason\"])\n            break\n    except urllib.error.HTTPError as error:\n        answer = json.load(error)\n\n        if error.code != 503:\n            # A problem document: act on its code.\n            print(answer.get(\"code\"), answer.get(\"trace_id\"))\n            break\n\n        # Affiliqo can't tell yet whether it holds the stag's visit: send the same call again shortly.\n        time.sleep(5)\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"bytes\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"time\"\n)\n\n// Tells Affiliqo of a new player the moment they sign up, and reads who they belong to. affiliqoAuthorization is the\n// signing helper from the guide; the key's id and secret come from your secret store.\nfunc main() {\n\temailHash := sha256.Sum256([]byte(strings.ToLower(\"Jane@example.com\")))\n\tbody, err := json.Marshal(map[string]any{\n\t\t\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n\t\t\"player\": map[string]any{\n\t\t\t\"casino_player_id\": \"player-1\",\n\t\t\t\"signed_up_at\":     \"2026-10-10T07:12:09Z\",\n\t\t\t\"email_hash\":       hex.EncodeToString(emailHash[:]),\n\t\t\t\"attribution\":      map[string]string{\"stag\": \"1042_10000614\"},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// One key per sign-up: a retry keeps it, so it gets the same answer.\n\tidempotencyKey := \"sign-up-player-1\"\n\n\tfor attempt := 1; attempt <= 3; attempt++ {\n\t\trequest, err := http.NewRequest(http.MethodPost, \"https://api.affiliqo.com/sign-ups\", bytes.NewReader(body))\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodPost, \"/sign-ups\", idempotencyKey, body))\n\t\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\t\trequest.Header.Set(\"Idempotency-Key\", idempotencyKey)\n\t\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\t\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tvar answer map[string]any\n\t\terr = json.NewDecoder(response.Body).Decode(&answer)\n\t\tresponse.Body.Close()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif response.StatusCode == http.StatusAccepted {\n\t\t\t// Keep the stag with the player: for a code it is the code's own.\n\t\t\tfmt.Println(answer[\"attribution\"])\n\n\t\t\treturn\n\t\t}\n\n\t\tif response.StatusCode != http.StatusServiceUnavailable {\n\t\t\t// A problem document: act on its code.\n\t\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\n\t\t\treturn\n\t\t}\n\n\t\t// Affiliqo can't tell yet whether it holds the stag's visit: send the same call again shortly.\n\t\ttime.Sleep(5 * time.Second)\n\t}\n}\n"
                    }
                ]
            }
        },
        "/player-batches": {
            "post": {
                "operationId": "sendPlayerBatch",
                "summary": "Send new and changed players",
                "description": "Sends up to 1,000 new or changed players of one brand: hourly, or as a full resync. A new player comes with its attribution; an update may leave it out. Affiliqo checks the batch, stores it encrypted and answers with its id and control sums before processing anything; ask for the batch's status later. Send gzipped bodies. A retry of the same JSON under the same `Idempotency-Key` gets the first answer again, with `Idempotent-Replayed: true`, and is never stored twice.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    },
                    {
                        "$ref": "#/components/parameters/ContentEncoding"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/PlayerBatch"
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "The batch is stored and will be processed; or, for a retry under the same key, its first answer again.",
                        "headers": {
                            "Idempotent-Replayed": {
                                "description": "`true` when this is the first answer to an earlier request under the same key, sent again.",
                                "schema": {
                                    "type": "string",
                                    "enum": [
                                        "true"
                                    ]
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Batch"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/PayloadTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidBatch"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Sends new and changed players, gzipped. signature.php is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nrequire __DIR__.'/signature.php';\n\n$json = (string) json_encode([\n    'brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001',\n    'items' => [\n        [\n            'casino_player_id' => 'player-1',\n            'signed_up_at' => '2026-10-10T07:12:09Z',\n            'email_hash' => hash('sha256', strtolower('Jane@example.com')),\n            'attribution' => ['stag' => '1042_7'],\n            'country' => 'MT',\n        ],\n        [\n            // A player who deposited before you started sending activity, with when they first deposited.\n            'casino_player_id' => 'player-2',\n            'signed_up_at' => '2026-03-02T18:40:00Z',\n            'first_deposit_at' => '2026-03-02T19:05:13Z',\n            'email_hash' => hash('sha256', strtolower('John@example.com')),\n            'attribution' => ['bonus_code' => 'WELCOME'],\n        ],\n    ],\n]);\n$body = (string) gzencode($json);\n// The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\n$idempotencyKey = 'players-2026-10-10T07:00Z-1-'.substr(hash('sha256', $json), 0, 8);\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'POST', '/player-batches', $idempotencyKey, $body);\n\n$curl = curl_init('https://api.affiliqo.com/player-batches');\ncurl_setopt_array($curl, [\n    CURLOPT_POST => true,\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_HTTPHEADER => [\n        'Authorization: '.$authorization,\n        'Content-Type: application/json',\n        'Content-Encoding: gzip',\n        'Idempotency-Key: '.$idempotencyKey,\n    ],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 202) {\n    // Compare the control sums with your own, and keep the id to ask for the batch's status.\n    echo $answer['id'], ' ', $answer['status'], ' ', $answer['control_sums']['items'], PHP_EOL;\n} else {\n    // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Sends new and changed players, gzipped. signature.mjs is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nimport { createHash } from 'node:crypto';\nimport { gzipSync } from 'node:zlib';\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst json = JSON.stringify({\n  brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001',\n  items: [\n    {\n      casino_player_id: 'player-1',\n      signed_up_at: '2026-10-10T07:12:09Z',\n      email_hash: createHash('sha256').update('Jane@example.com'.toLowerCase()).digest('hex'),\n      attribution: { stag: '1042_7' },\n      country: 'MT',\n    },\n    {\n      // A player who deposited before you started sending activity, with when they first deposited.\n      casino_player_id: 'player-2',\n      signed_up_at: '2026-03-02T18:40:00Z',\n      first_deposit_at: '2026-03-02T19:05:13Z',\n      email_hash: createHash('sha256').update('John@example.com'.toLowerCase()).digest('hex'),\n      attribution: { bonus_code: 'WELCOME' },\n    },\n  ],\n});\nconst body = gzipSync(json);\n// The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\nconst idempotencyKey = `players-2026-10-10T07:00Z-1-${createHash('sha256').update(json).digest('hex').slice(0, 8)}`;\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch('https://api.affiliqo.com/player-batches', {\n  method: 'POST',\n  body,\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'POST', '/player-batches', idempotencyKey, body),\n    'Content-Type': 'application/json',\n    'Content-Encoding': 'gzip',\n    'Idempotency-Key': idempotencyKey,\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(30_000),\n});\nconst answer = await response.json();\n\nif (response.status === 202) {\n  // Compare the control sums with your own, and keep the id to ask for the batch's status.\n  console.log(answer.id, answer.status, answer.control_sums.items);\n} else {\n  // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Sends new and changed players, gzipped. signature.py is the signing helper from the guide; the key's id and secret\n# come from your secret store.\nimport gzip\nimport hashlib\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\npayload = json.dumps({\n    \"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n    \"items\": [\n        {\n            \"casino_player_id\": \"player-1\",\n            \"signed_up_at\": \"2026-10-10T07:12:09Z\",\n            \"email_hash\": hashlib.sha256(\"Jane@example.com\".lower().encode()).hexdigest(),\n            \"attribution\": {\"stag\": \"1042_7\"},\n            \"country\": \"MT\",\n        },\n        {\n            # A player who deposited before you started sending activity, with when they first deposited.\n            \"casino_player_id\": \"player-2\",\n            \"signed_up_at\": \"2026-03-02T18:40:00Z\",\n            \"first_deposit_at\": \"2026-03-02T19:05:13Z\",\n            \"email_hash\": hashlib.sha256(\"John@example.com\".lower().encode()).hexdigest(),\n            \"attribution\": {\"bonus_code\": \"WELCOME\"},\n        },\n    ],\n}, separators=(\",\", \":\")).encode()\nbody = gzip.compress(payload)\n# The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\nidempotency_key = \"players-2026-10-10T07:00Z-1-\" + hashlib.sha256(payload).hexdigest()[:8]\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"POST\", \"/player-batches\", idempotency_key, body)\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com/player-batches\",\n    data=body,\n    method=\"POST\",\n    headers={\n        \"Authorization\": authorization,\n        \"Content-Type\": \"application/json\",\n        \"Content-Encoding\": \"gzip\",\n        \"Idempotency-Key\": idempotency_key,\n        \"User-Agent\": \"your-casino-affiliqo-client/1.0\",\n    },\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        # Compare the control sums with your own, and keep the id to ask for the batch's status.\n        answer = json.load(response)\n        print(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"][\"items\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"time\"\n)\n\n// Sends new and changed players, gzipped. affiliqoAuthorization is the signing helper from the guide; the key's id and\n// secret come from your secret store.\nfunc main() {\n\tpayload, err := json.Marshal(map[string]any{\n\t\t\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n\t\t\"items\": []map[string]any{\n\t\t\t{\n\t\t\t\t\"casino_player_id\": \"player-1\",\n\t\t\t\t\"signed_up_at\":     \"2026-10-10T07:12:09Z\",\n\t\t\t\t\"email_hash\":       emailHash(\"Jane@example.com\"),\n\t\t\t\t\"attribution\":      map[string]string{\"stag\": \"1042_7\"},\n\t\t\t\t\"country\":          \"MT\",\n\t\t\t},\n\t\t\t{\n\t\t\t\t// A player who deposited before you started sending activity, with when they first deposited.\n\t\t\t\t\"casino_player_id\": \"player-2\",\n\t\t\t\t\"signed_up_at\":     \"2026-03-02T18:40:00Z\",\n\t\t\t\t\"first_deposit_at\": \"2026-03-02T19:05:13Z\",\n\t\t\t\t\"email_hash\":       emailHash(\"John@example.com\"),\n\t\t\t\t\"attribution\":      map[string]string{\"bonus_code\": \"WELCOME\"},\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar body bytes.Buffer\n\twriter := gzip.NewWriter(&body)\n\twriter.Write(payload)\n\twriter.Close()\n\n\t// The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\n\thash := sha256.Sum256(payload)\n\tidempotencyKey := \"players-2026-10-10T07:00Z-1-\" + hex.EncodeToString(hash[:])[:8]\n\n\trequest, err := http.NewRequest(http.MethodPost, \"https://api.affiliqo.com/player-batches\", bytes.NewReader(body.Bytes()))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodPost, \"/player-batches\", idempotencyKey, body.Bytes()))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\trequest.Header.Set(\"Content-Encoding\", \"gzip\")\n\trequest.Header.Set(\"Idempotency-Key\", idempotencyKey)\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 30 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusAccepted {\n\t\t// Compare the control sums with your own, and keep the id to ask for the batch's status.\n\t\tfmt.Println(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"])\n\t} else {\n\t\t// A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n\n// emailHash is the lowercase hex SHA-256 of the lowercased email, as the API takes it.\nfunc emailHash(email string) string {\n\tsum := sha256.Sum256([]byte(strings.ToLower(email)))\n\n\treturn hex.EncodeToString(sum[:])\n}\n"
                    }
                ]
            }
        },
        "/flag-batches": {
            "post": {
                "operationId": "sendFlagBatch",
                "summary": "Send changes of players' flags",
                "description": "Sends up to 5,000 changes of one brand's players' flags: disabled, self-excluded, duplicate, verified and frozen, each with the time it happened and an optional reason. A change dated in the past applies from that time. Affiliqo checks the batch, stores it encrypted and answers with its id and control sums before processing anything. Send gzipped bodies. A retry of the same JSON under the same `Idempotency-Key` gets the first answer again, with `Idempotent-Replayed: true`, and is never stored twice.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    },
                    {
                        "$ref": "#/components/parameters/ContentEncoding"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/FlagBatch"
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "The batch is stored and will be processed; or, for a retry under the same key, its first answer again.",
                        "headers": {
                            "Idempotent-Replayed": {
                                "description": "`true` when this is the first answer to an earlier request under the same key, sent again.",
                                "schema": {
                                    "type": "string",
                                    "enum": [
                                        "true"
                                    ]
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Batch"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/PayloadTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidBatch"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Sends changes of players' flags, gzipped. signature.php is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nrequire __DIR__.'/signature.php';\n\n$json = (string) json_encode([\n    'brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001',\n    'items' => [\n        ['casino_player_id' => 'player-1', 'flags' => ['self_excluded' => true], 'at' => '2026-10-10T07:41:30Z', 'reason' => 'Asked to be excluded for 6 months'],\n        ['casino_player_id' => 'player-2', 'flags' => ['verified' => true], 'at' => '2026-10-10T07:55:02Z'],\n    ],\n]);\n$body = (string) gzencode($json);\n// The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\n$idempotencyKey = 'flags-2026-10-10T07:00Z-1-'.substr(hash('sha256', $json), 0, 8);\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'POST', '/flag-batches', $idempotencyKey, $body);\n\n$curl = curl_init('https://api.affiliqo.com/flag-batches');\ncurl_setopt_array($curl, [\n    CURLOPT_POST => true,\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_HTTPHEADER => [\n        'Authorization: '.$authorization,\n        'Content-Type: application/json',\n        'Content-Encoding: gzip',\n        'Idempotency-Key: '.$idempotencyKey,\n    ],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 202) {\n    // Compare the control sums with your own, and keep the id to ask for the batch's status.\n    echo $answer['id'], ' ', $answer['status'], ' ', $answer['control_sums']['items'], PHP_EOL;\n} else {\n    // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Sends changes of players' flags, gzipped. signature.mjs is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nimport { createHash } from 'node:crypto';\nimport { gzipSync } from 'node:zlib';\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst json = JSON.stringify({\n  brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001',\n  items: [\n    { casino_player_id: 'player-1', flags: { self_excluded: true }, at: '2026-10-10T07:41:30Z', reason: 'Asked to be excluded for 6 months' },\n    { casino_player_id: 'player-2', flags: { verified: true }, at: '2026-10-10T07:55:02Z' },\n  ],\n});\nconst body = gzipSync(json);\n// The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\nconst idempotencyKey = `flags-2026-10-10T07:00Z-1-${createHash('sha256').update(json).digest('hex').slice(0, 8)}`;\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch('https://api.affiliqo.com/flag-batches', {\n  method: 'POST',\n  body,\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'POST', '/flag-batches', idempotencyKey, body),\n    'Content-Type': 'application/json',\n    'Content-Encoding': 'gzip',\n    'Idempotency-Key': idempotencyKey,\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(30_000),\n});\nconst answer = await response.json();\n\nif (response.status === 202) {\n  // Compare the control sums with your own, and keep the id to ask for the batch's status.\n  console.log(answer.id, answer.status, answer.control_sums.items);\n} else {\n  // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Sends changes of players' flags, gzipped. signature.py is the signing helper from the guide; the key's id and secret\n# come from your secret store.\nimport gzip\nimport hashlib\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\npayload = json.dumps({\n    \"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n    \"items\": [\n        {\"casino_player_id\": \"player-1\", \"flags\": {\"self_excluded\": True}, \"at\": \"2026-10-10T07:41:30Z\", \"reason\": \"Asked to be excluded for 6 months\"},\n        {\"casino_player_id\": \"player-2\", \"flags\": {\"verified\": True}, \"at\": \"2026-10-10T07:55:02Z\"},\n    ],\n}, separators=(\",\", \":\")).encode()\nbody = gzip.compress(payload)\n# The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\nidempotency_key = \"flags-2026-10-10T07:00Z-1-\" + hashlib.sha256(payload).hexdigest()[:8]\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"POST\", \"/flag-batches\", idempotency_key, body)\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com/flag-batches\",\n    data=body,\n    method=\"POST\",\n    headers={\n        \"Authorization\": authorization,\n        \"Content-Type\": \"application/json\",\n        \"Content-Encoding\": \"gzip\",\n        \"Idempotency-Key\": idempotency_key,\n        \"User-Agent\": \"your-casino-affiliqo-client/1.0\",\n    },\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        # Compare the control sums with your own, and keep the id to ask for the batch's status.\n        answer = json.load(response)\n        print(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"][\"items\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Sends changes of players' flags, gzipped. affiliqoAuthorization is the signing helper from the guide; the key's id and\n// secret come from your secret store.\nfunc main() {\n\tpayload, err := json.Marshal(map[string]any{\n\t\t\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n\t\t\"items\": []map[string]any{\n\t\t\t{\"casino_player_id\": \"player-1\", \"flags\": map[string]bool{\"self_excluded\": true}, \"at\": \"2026-10-10T07:41:30Z\", \"reason\": \"Asked to be excluded for 6 months\"},\n\t\t\t{\"casino_player_id\": \"player-2\", \"flags\": map[string]bool{\"verified\": true}, \"at\": \"2026-10-10T07:55:02Z\"},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar body bytes.Buffer\n\twriter := gzip.NewWriter(&body)\n\twriter.Write(payload)\n\twriter.Close()\n\n\t// The kind, the hour, the chunk and a short hash of the JSON: a retry keeps the key, a correction gets a new one.\n\thash := sha256.Sum256(payload)\n\tidempotencyKey := \"flags-2026-10-10T07:00Z-1-\" + hex.EncodeToString(hash[:])[:8]\n\n\trequest, err := http.NewRequest(http.MethodPost, \"https://api.affiliqo.com/flag-batches\", bytes.NewReader(body.Bytes()))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodPost, \"/flag-batches\", idempotencyKey, body.Bytes()))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\trequest.Header.Set(\"Content-Encoding\", \"gzip\")\n\trequest.Header.Set(\"Idempotency-Key\", idempotencyKey)\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 30 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusAccepted {\n\t\t// Compare the control sums with your own, and keep the id to ask for the batch's status.\n\t\tfmt.Println(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"])\n\t} else {\n\t\t// A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/events": {
            "post": {
                "operationId": "sendEvents",
                "summary": "Send events as they happen",
                "description": "Sends up to 100 events of one brand's players as they happen: deposits, first deposits, cashouts and verified identities, each with its own id, which Affiliqo records once for the brand, within seconds; events never wait behind batches, and never change figures, which come only from batches. Registrations go through the sign-up call. Use a key with the `events` scope. Requests of events count toward their own limit of 600 a minute per key. Affiliqo checks the events, stores them and answers with their id and control sums before processing anything; the answer is a batch's: read its status with `GET /batches/{id}`, and each refused or waiting event with `GET /batches/{id}/outcomes`, using a key with the `ingest` scope. A retry of the same JSON under the same `Idempotency-Key` gets the first answer again, with `Idempotent-Replayed: true`, and is never stored twice.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    },
                    {
                        "$ref": "#/components/parameters/ContentEncoding"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/EventBatch"
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "The events are stored and will be processed; or, for a retry under the same key, the first answer again.",
                        "headers": {
                            "Idempotent-Replayed": {
                                "description": "`true` when this is the first answer to an earlier request under the same key, sent again.",
                                "schema": {
                                    "type": "string",
                                    "enum": [
                                        "true"
                                    ]
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Batch"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/Conflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/PayloadTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidBatch"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Sends events as they happen. signature.php is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nrequire __DIR__.'/signature.php';\n\n$json = (string) json_encode([\n    'brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001',\n    'events' => [\n        ['id' => 'dep-55120', 'kind' => 'deposit', 'at' => '2026-10-10T09:20:41Z', 'casino_player_id' => 'player-1', 'deposit' => ['id' => '55120', 'amount' => 5000, 'currency' => 'EUR']],\n        ['id' => 'kyc-player-2', 'kind' => 'kyc_verified', 'at' => '2026-10-10T09:20:43Z', 'casino_player_id' => 'player-2'],\n    ],\n]);\n$body = $json;\n// The events' ids name the request: a retry keeps the key.\n$idempotencyKey = 'events-'.substr(hash('sha256', $json), 0, 16);\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'POST', '/events', $idempotencyKey, $body);\n\n$curl = curl_init('https://api.affiliqo.com/events');\ncurl_setopt_array($curl, [\n    CURLOPT_POST => true,\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_HTTPHEADER => [\n        'Authorization: '.$authorization,\n        'Content-Type: application/json',\n        'Idempotency-Key: '.$idempotencyKey,\n    ],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 10,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 202) {\n    // Keep the id to ask what became of each event.\n    echo $answer['id'], ' ', $answer['status'], ' ', $answer['control_sums']['items'], PHP_EOL;\n} else {\n    // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Sends events as they happen. signature.mjs is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nimport { createHash } from 'node:crypto';\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst json = JSON.stringify({\n  brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001',\n  events: [\n    { id: 'dep-55120', kind: 'deposit', at: '2026-10-10T09:20:41Z', casino_player_id: 'player-1', deposit: { id: '55120', amount: 5000, currency: 'EUR' } },\n    { id: 'kyc-player-2', kind: 'kyc_verified', at: '2026-10-10T09:20:43Z', casino_player_id: 'player-2' },\n  ],\n});\nconst body = Buffer.from(json);\n// The events' ids name the request: a retry keeps the key.\nconst idempotencyKey = `events-${createHash('sha256').update(json).digest('hex').slice(0, 16)}`;\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch('https://api.affiliqo.com/events', {\n  method: 'POST',\n  body,\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'POST', '/events', idempotencyKey, body),\n    'Content-Type': 'application/json',\n    'Idempotency-Key': idempotencyKey,\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(10_000),\n});\nconst answer = await response.json();\n\nif (response.status === 202) {\n  // Keep the id to ask what became of each event.\n  console.log(answer.id, answer.status, answer.control_sums.items);\n} else {\n  // A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Sends events as they happen. signature.py is the signing helper from the guide; the key's id and secret\n# come from your secret store.\nimport hashlib\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\npayload = json.dumps({\n    \"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n    \"events\": [\n        {\"id\": \"dep-55120\", \"kind\": \"deposit\", \"at\": \"2026-10-10T09:20:41Z\", \"casino_player_id\": \"player-1\", \"deposit\": {\"id\": \"55120\", \"amount\": 5000, \"currency\": \"EUR\"}},\n        {\"id\": \"kyc-player-2\", \"kind\": \"kyc_verified\", \"at\": \"2026-10-10T09:20:43Z\", \"casino_player_id\": \"player-2\"},\n    ],\n}, separators=(\",\", \":\")).encode()\nbody = payload\n# The events' ids name the request: a retry keeps the key.\nidempotency_key = \"events-\" + hashlib.sha256(payload).hexdigest()[:16]\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"POST\", \"/events\", idempotency_key, body)\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com/events\",\n    data=body,\n    method=\"POST\",\n    headers={\n        \"Authorization\": authorization,\n        \"Content-Type\": \"application/json\",\n        \"Idempotency-Key\": idempotency_key,\n        \"User-Agent\": \"your-casino-affiliqo-client/1.0\",\n    },\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=10) as response:\n        # Keep the id to ask what became of each event.\n        answer = json.load(response)\n        print(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"][\"items\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"bytes\"\n\t\"crypto/sha256\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Sends events as they happen. affiliqoAuthorization is the signing helper from the guide; the key's id and\n// secret come from your secret store.\nfunc main() {\n\tpayload, err := json.Marshal(map[string]any{\n\t\t\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\",\n\t\t\"events\": []map[string]any{\n\t\t\t{\"id\": \"dep-55120\", \"kind\": \"deposit\", \"at\": \"2026-10-10T09:20:41Z\", \"casino_player_id\": \"player-1\", \"deposit\": map[string]any{\"id\": \"55120\", \"amount\": 5000, \"currency\": \"EUR\"}},\n\t\t\t{\"id\": \"kyc-player-2\", \"kind\": \"kyc_verified\", \"at\": \"2026-10-10T09:20:43Z\", \"casino_player_id\": \"player-2\"},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// The events' ids name the request: a retry keeps the key.\n\thash := sha256.Sum256(payload)\n\tidempotencyKey := \"events-\" + hex.EncodeToString(hash[:])[:16]\n\n\trequest, err := http.NewRequest(http.MethodPost, \"https://api.affiliqo.com/events\", bytes.NewReader(payload))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodPost, \"/events\", idempotencyKey, payload))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\trequest.Header.Set(\"Idempotency-Key\", idempotencyKey)\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusAccepted {\n\t\t// Keep the id to ask what became of each event.\n\t\tfmt.Println(answer[\"id\"], answer[\"status\"], answer[\"control_sums\"])\n\t} else {\n\t\t// A problem document: act on its code. A 5xx or no answer is retried with the same body and key, signed again.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/batches/{id}": {
            "get": {
                "operationId": "getBatch",
                "summary": "Read a batch's status",
                "description": "What became of one of your batches, by the id its acknowledgement gave. Any of your casino's keys with the `ingest` scope can read any of its batches; another casino's batch is not found. A casino whose ingest is in quarantine can still read its batches.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/BatchId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The batch, and what became of it.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BatchResult"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads what became of a batch. signature.php is the signing helper from the guide; the key's id and secret come from\n// your secret store.\nrequire __DIR__.'/signature.php';\n\n$target = '/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f';\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'GET', $target, '', '');\n\n$curl = curl_init('https://api.affiliqo.com'.$target);\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: '.$authorization],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 10,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo $answer['status'], PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads what became of a batch. signature.mjs is the signing helper from the guide; the key's id and secret come from\n// your secret store.\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst target = '/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f';\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch(`https://api.affiliqo.com${target}`, {\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'GET', target, '', ''),\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(10_000),\n});\nconst answer = await response.json();\n\nif (response.ok) {\n  console.log(answer.status);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads what became of a batch. signature.py is the signing helper from the guide; the key's id and secret come from\n# your secret store.\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\ntarget = \"/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f\"\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"GET\", target, \"\", b\"\")\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com\" + target,\n    headers={\"Authorization\": authorization, \"User-Agent\": \"your-casino-affiliqo-client/1.0\"},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=10) as response:\n        print(json.load(response)[\"status\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Reads what became of a batch. affiliqoAuthorization is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nfunc main() {\n\ttarget := \"/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f\"\n\trequest, err := http.NewRequest(http.MethodGet, \"https://api.affiliqo.com\"+target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodGet, target, \"\", nil))\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\tfmt.Println(answer[\"status\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/batches/{id}/outcomes": {
            "get": {
                "operationId": "listBatchOutcomes",
                "summary": "List a batch's rejected and parked items",
                "description": "The rejected and parked items of one of your batches, 100 at a time, in their order in the batch, after the first 100 its status answer lists. Follow `next_outcomes_cursor` until it is null. Any of your casino's keys with the `ingest` scope can read any of its batches; another casino's batch is not found.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/BatchId"
                    },
                    {
                        "$ref": "#/components/parameters/OutcomesCursor"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page of the batch's rejected and parked items.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BatchOutcomes"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads every rejected and parked item of a batch, page by page. signature.php is the signing helper from the guide;\n// the key's id and secret come from your secret store.\nrequire __DIR__.'/signature.php';\n\n$cursor = null;\n\ndo {\n    // The query string is part of what the request signs.\n    $target = '/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f/outcomes'.($cursor === null ? '' : '?cursor='.rawurlencode($cursor));\n    $authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'GET', $target, '', '');\n\n    $curl = curl_init('https://api.affiliqo.com'.$target);\n    curl_setopt_array($curl, [\n        CURLOPT_HTTPHEADER => ['Authorization: '.$authorization],\n        CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n        CURLOPT_RETURNTRANSFER => true,\n        CURLOPT_TIMEOUT => 10,\n    ]);\n    $answer = json_decode((string) curl_exec($curl), true);\n\n    if (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) !== 200) {\n        // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n        fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n\n        break;\n    }\n\n    foreach ($answer['outcomes'] as $outcome) {\n        echo $outcome['pointer'], ' ', $outcome['casino_player_id'], ' ', $outcome['problem'] ?? $outcome['refusal'], PHP_EOL;\n    }\n\n    $cursor = $answer['next_outcomes_cursor'];\n} while ($cursor !== null);\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads every rejected and parked item of a batch, page by page. signature.mjs is the signing helper from the guide;\n// the key's id and secret come from your secret store.\nimport { affiliqoAuthorization } from './signature.mjs';\n\nlet cursor = null;\n\ndo {\n  // The query string is part of what the request signs.\n  const target = `/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f/outcomes${cursor === null ? '' : `?cursor=${encodeURIComponent(cursor)}`}`;\n  const timestamp = Math.floor(Date.now() / 1000);\n\n  const response = await fetch(`https://api.affiliqo.com${target}`, {\n    headers: {\n      Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'GET', target, '', ''),\n      'User-Agent': 'your-casino-affiliqo-client/1.0',\n    },\n    signal: AbortSignal.timeout(10_000),\n  });\n  const answer = await response.json();\n\n  if (!response.ok) {\n    // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    console.error(answer.code, answer.trace_id);\n    break;\n  }\n\n  for (const outcome of answer.outcomes) {\n    console.log(outcome.pointer, outcome.casino_player_id, outcome.problem ?? outcome.refusal);\n  }\n\n  cursor = answer.next_outcomes_cursor;\n} while (cursor !== null);\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads every rejected and parked item of a batch, page by page. signature.py is the signing helper from the guide;\n# the key's id and secret come from your secret store.\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\ncursor = None\n\nwhile True:\n    # The query string is part of what the request signs.\n    target = \"/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f/outcomes\"\n    if cursor is not None:\n        target += \"?cursor=\" + urllib.parse.quote(cursor, safe=\"\")\n    authorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"GET\", target, \"\", b\"\")\n    request = urllib.request.Request(\n        \"https://api.affiliqo.com\" + target,\n        headers={\"Authorization\": authorization, \"User-Agent\": \"your-casino-affiliqo-client/1.0\"},\n    )\n\n    try:\n        with urllib.request.urlopen(request, timeout=10) as response:\n            answer = json.load(response)\n    except urllib.error.HTTPError as error:\n        # A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n        problem = json.load(error)\n        print(problem.get(\"code\"), problem.get(\"trace_id\"))\n        break\n\n    for outcome in answer[\"outcomes\"]:\n        print(outcome[\"pointer\"], outcome[\"casino_player_id\"], outcome.get(\"problem\") or outcome.get(\"refusal\"))\n\n    cursor = answer[\"next_outcomes_cursor\"]\n    if cursor is None:\n        break\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"time\"\n)\n\n// Reads every rejected and parked item of a batch, page by page. affiliqoAuthorization is the signing helper from the\n// guide; the key's id and secret come from your secret store.\nfunc main() {\n\tcursor := \"\"\n\n\tfor {\n\t\t// The query string is part of what the request signs.\n\t\ttarget := \"/batches/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f/outcomes\"\n\t\tif cursor != \"\" {\n\t\t\ttarget += \"?cursor=\" + url.QueryEscape(cursor)\n\t\t}\n\n\t\trequest, err := http.NewRequest(http.MethodGet, \"https://api.affiliqo.com\"+target, nil)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodGet, target, \"\", nil))\n\t\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\t\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tvar answer struct {\n\t\t\tCode               string  `json:\"code\"`\n\t\t\tTraceID            string  `json:\"trace_id\"`\n\t\t\tNextOutcomesCursor *string `json:\"next_outcomes_cursor\"`\n\t\t\tOutcomes           []struct {\n\t\t\t\tPointer        string `json:\"pointer\"`\n\t\t\t\tCasinoPlayerID string `json:\"casino_player_id\"`\n\t\t\t\tProblem        string `json:\"problem\"`\n\t\t\t\tRefusal        string `json:\"refusal\"`\n\t\t\t} `json:\"outcomes\"`\n\t\t}\n\t\terr = json.NewDecoder(response.Body).Decode(&answer)\n\t\tresponse.Body.Close()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif response.StatusCode != http.StatusOK {\n\t\t\t// A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n\t\t\tfmt.Fprintln(os.Stderr, answer.Code, answer.TraceID)\n\t\t\treturn\n\t\t}\n\n\t\tfor _, outcome := range answer.Outcomes {\n\t\t\tfmt.Println(outcome.Pointer, outcome.CasinoPlayerID, outcome.Problem+outcome.Refusal)\n\t\t}\n\n\t\tif answer.NextOutcomesCursor == nil {\n\t\t\treturn\n\t\t}\n\t\tcursor = *answer.NextOutcomesCursor\n\t}\n}\n"
                    }
                ]
            }
        },
        "/merchant": {
            "get": {
                "operationId": "getMerchantProfile",
                "summary": "Read your merchant profile",
                "description": "Your casino's profile as Affiliqo holds it: your program's timezone and default currency, each brand with its products, currencies and the rhythm at which you send its activity, and whether each capability is on, and how it behaves while off. Any of your casino's keys can read it, whatever its scopes.",
                "responses": {
                    "200": {
                        "description": "Your merchant profile.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/MerchantProfile"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads your merchant profile. signature.php is the signing helper from the guide; the key's id and secret come from\n// your secret store.\nrequire __DIR__.'/signature.php';\n\n$target = '/merchant';\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'GET', $target, '', '');\n\n$curl = curl_init('https://api.affiliqo.com'.$target);\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: '.$authorization],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 10,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo $answer['timezone'], ' ', count($answer['brands']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads your merchant profile. signature.mjs is the signing helper from the guide; the key's id and secret come from\n// your secret store.\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst target = '/merchant';\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch(`https://api.affiliqo.com${target}`, {\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'GET', target, '', ''),\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(10_000),\n});\nconst answer = await response.json();\n\nif (response.ok) {\n  console.log(answer.timezone, answer.brands.length);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads your merchant profile. signature.py is the signing helper from the guide; the key's id and secret come from\n# your secret store.\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\ntarget = \"/merchant\"\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"GET\", target, \"\", b\"\")\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com\" + target,\n    headers={\"Authorization\": authorization, \"User-Agent\": \"your-casino-affiliqo-client/1.0\"},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=10) as response:\n        print(json.load(response)[\"timezone\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Reads your merchant profile. affiliqoAuthorization is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nfunc main() {\n\ttarget := \"/merchant\"\n\trequest, err := http.NewRequest(http.MethodGet, \"https://api.affiliqo.com\"+target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodGet, target, \"\", nil))\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\tfmt.Println(answer[\"timezone\"], answer[\"brands\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/health": {
            "get": {
                "operationId": "getIngestHealth",
                "summary": "Read your ingest health",
                "description": "How Affiliqo's processing of your data stands for each brand, measured at most a minute ago: when each kind of batch was last accepted, up to when activity in each currency has been processed, how long the oldest waiting batch has waited, waiting, quarantined and failed batches, items waiting for their player, and a status. A brand is `backlogged` when a batch has waited more than 5 minutes; otherwise `late` when no activity batch, an empty one included, came within its rhythm plus 15 minutes; otherwise `ok`. Your casino stands as its worst brand. Any of your casino's keys can read it, whatever its scopes.",
                "responses": {
                    "200": {
                        "description": "Your ingest health, as last measured.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/IngestHealth"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/Unavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads your ingest health. signature.php is the signing helper from the guide; the key's id and secret come from\n// your secret store.\nrequire __DIR__.'/signature.php';\n\n$target = '/health';\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'GET', $target, '', '');\n\n$curl = curl_init('https://api.affiliqo.com'.$target);\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: '.$authorization],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 10,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo $answer['status'], ' ', $answer['measured_at'], PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads your ingest health. signature.mjs is the signing helper from the guide; the key's id and secret come from\n// your secret store.\nimport { affiliqoAuthorization } from './signature.mjs';\n\nconst target = '/health';\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch(`https://api.affiliqo.com${target}`, {\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'GET', target, '', ''),\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(10_000),\n});\nconst answer = await response.json();\n\nif (response.ok) {\n  console.log(answer.status, answer.measured_at);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads your ingest health. signature.py is the signing helper from the guide; the key's id and secret come from\n# your secret store.\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\ntarget = \"/health\"\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"GET\", target, \"\", b\"\")\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com\" + target,\n    headers={\"Authorization\": authorization, \"User-Agent\": \"your-casino-affiliqo-client/1.0\"},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=10) as response:\n        print(json.load(response)[\"status\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n)\n\n// Reads your ingest health. affiliqoAuthorization is the signing helper from the guide; the key's id and secret\n// come from your secret store.\nfunc main() {\n\ttarget := \"/health\"\n\trequest, err := http.NewRequest(http.MethodGet, \"https://api.affiliqo.com\"+target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodGet, target, \"\", nil))\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\tfmt.Println(answer[\"status\"], answer[\"measured_at\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the Affiliqo team about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/attributions": {
            "get": {
                "operationId": "lookUpAttribution",
                "summary": "Look up a stag or a code",
                "description": "Resolves a stag, a bonus code or a promo code as the sign-up call would for a player who signed up now, and answers in the sign-up answer's form: the partner, campaign, promo and stag, or the reason nobody would be attributed, still with 200. A lookup stores nothing and never issues a stag: a code whose stag isn't issued yet answers with `stag` null, and the sign-up call issues it. It needs a key with the `lookup` scope, and counts as a read. A 503 `attribution_unavailable` means Affiliqo can't tell yet whether it holds the stag's visit: ask again after the seconds `Retry-After` gives.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/LookupBrand"
                    },
                    {
                        "$ref": "#/components/parameters/LookupStag"
                    },
                    {
                        "$ref": "#/components/parameters/LookupBonusCode"
                    },
                    {
                        "$ref": "#/components/parameters/LookupPromoCode"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Who the player would belong to, or why nobody.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AttributionLookup"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidLookup"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/LookupUnavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Looks up who a bonus code belongs to. signature.php is the signing helper from the guide; the key's id and secret\n// come from your secret store, and the key needs the lookup scope.\nrequire __DIR__.'/signature.php';\n\n// The query string is part of what the request signs.\n$target = '/attributions?'.http_build_query(['brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001', 'bonus_code' => 'WELCOME100'], encoding_type: PHP_QUERY_RFC3986);\n$authorization = affiliqoAuthorization((string) getenv('AFFILIQO_KEY_ID'), (string) getenv('AFFILIQO_SECRET'), time(), 'GET', $target, '', '');\n\n$curl = curl_init('https://api.affiliqo.com'.$target);\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: '.$authorization],\n    CURLOPT_USERAGENT => 'your-casino-affiliqo-client/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 10,\n]);\n$answer = json_decode((string) curl_exec($curl), true);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    $attribution = $answer['attribution'];\n    echo $attribution['result'] === 'attributed' ? $attribution['partner_id'].' '.$attribution['stag'] : $attribution['reason'], PHP_EOL;\n} else {\n    // A problem document: after a 503, ask again once Retry-After has passed. Quote the trace_id when you ask the Affiliqo\n    // team about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Looks up who a bonus code belongs to. signature.mjs is the signing helper from the guide; the key's id and secret\n// come from your secret store, and the key needs the lookup scope.\nimport { affiliqoAuthorization } from './signature.mjs';\n\n// The query string is part of what the request signs.\nconst query = new URLSearchParams({ brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001', bonus_code: 'WELCOME100' });\nconst target = `/attributions?${query}`;\nconst timestamp = Math.floor(Date.now() / 1000);\n\nconst response = await fetch(`https://api.affiliqo.com${target}`, {\n  headers: {\n    Authorization: affiliqoAuthorization(process.env.AFFILIQO_KEY_ID, process.env.AFFILIQO_SECRET, timestamp, 'GET', target, '', ''),\n    'User-Agent': 'your-casino-affiliqo-client/1.0',\n  },\n  signal: AbortSignal.timeout(10_000),\n});\nconst answer = await response.json();\n\nif (response.ok) {\n  const { attribution } = answer;\n  console.log(attribution.result === 'attributed' ? `${attribution.partner_id} ${attribution.stag}` : attribution.reason);\n} else {\n  // A problem document: after a 503, ask again once Retry-After has passed. Quote the trace_id when you ask the Affiliqo\n  // team about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Looks up who a bonus code belongs to. signature.py is the signing helper from the guide; the key's id and secret\n# come from your secret store, and the key needs the lookup scope.\nimport json\nimport os\nimport time\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nfrom signature import affiliqo_authorization\n\n# The query string is part of what the request signs.\ntarget = \"/attributions?\" + urllib.parse.urlencode({\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\", \"bonus_code\": \"WELCOME100\"})\nauthorization = affiliqo_authorization(os.environ[\"AFFILIQO_KEY_ID\"], os.environ[\"AFFILIQO_SECRET\"], int(time.time()), \"GET\", target, \"\", b\"\")\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com\" + target,\n    headers={\"Authorization\": authorization, \"User-Agent\": \"your-casino-affiliqo-client/1.0\"},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=10) as response:\n        attribution = json.load(response)[\"attribution\"]\n        if attribution[\"result\"] == \"attributed\":\n            print(attribution[\"partner_id\"], attribution[\"stag\"])\n        else:\n            print(attribution[\"reason\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: after a 503, ask again once Retry-After has passed. Quote the trace_id when you ask the Affiliqo\n    # team about it.\n    answer = json.load(error)\n    print(answer.get(\"code\"), answer.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "package main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"time\"\n)\n\n// Looks up who a bonus code belongs to. affiliqoAuthorization is the signing helper from the guide; the key's id and\n// secret come from your secret store, and the key needs the lookup scope.\nfunc main() {\n\t// The query string is part of what the request signs.\n\tquery := url.Values{\"brand_id\": {\"0192f6a8-1111-7aaa-8bbb-000000000001\"}, \"bonus_code\": {\"WELCOME100\"}}\n\ttarget := \"/attributions?\" + query.Encode()\n\trequest, err := http.NewRequest(http.MethodGet, \"https://api.affiliqo.com\"+target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", affiliqoAuthorization(os.Getenv(\"AFFILIQO_KEY_ID\"), os.Getenv(\"AFFILIQO_SECRET\"), time.Now().Unix(), http.MethodGet, target, \"\", nil))\n\trequest.Header.Set(\"User-Agent\", \"your-casino-affiliqo-client/1.0\")\n\n\tresponse, err := (&http.Client{Timeout: 10 * time.Second}).Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(response.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\tattribution := answer[\"attribution\"].(map[string]any)\n\t\tif attribution[\"result\"] == \"attributed\" {\n\t\t\tfmt.Println(attribution[\"partner_id\"], attribution[\"stag\"])\n\t\t} else {\n\t\t\tfmt.Println(attribution[\"reason\"])\n\t\t}\n\t} else {\n\t\t// A problem document: after a 503, ask again once Retry-After has passed. Quote the trace_id when you ask\n\t\t// the Affiliqo team about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "Signature": {
                "type": "apiKey",
                "in": "header",
                "name": "Authorization",
                "description": "Every request is signed with its key: `Affiliqo-HMAC-SHA256 key=<key id>, ts=<Unix seconds>, sig=<signature>`."
            }
        },
        "parameters": {
            "IdempotencyKey": {
                "name": "Idempotency-Key",
                "in": "header",
                "required": true,
                "description": "Your own name for this write, 1 to 255 printable characters without spaces, unique among your casino's writes. Send a retry of the same JSON under the same key: it gets the first answer again. Build it from the kind, the window, the chunk and a short hash of the JSON, such as `activity-2026-10-10T07:00Z-1-b2e46d56`, so a corrected window gets a new key. The key is part of the signature.",
                "schema": {
                    "type": "string",
                    "pattern": "^[!-~]{1,255}$"
                }
            },
            "ContentEncoding": {
                "name": "Content-Encoding",
                "in": "header",
                "required": false,
                "description": "`gzip` for a gzipped body, which is how batches should be sent; leave it out for plain JSON.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "gzip",
                        "identity"
                    ]
                }
            },
            "BatchId": {
                "name": "id",
                "in": "path",
                "required": true,
                "description": "The batch's id, from the answer that acknowledged it.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "OutcomesCursor": {
                "name": "cursor",
                "in": "query",
                "required": false,
                "description": "The `next_outcomes_cursor` of the batch's status answer or of the page before, as Affiliqo gave it. Leave it out for the first page.",
                "schema": {
                    "type": "string",
                    "maxLength": 32
                }
            },
            "LookupBrand": {
                "name": "brand_id",
                "in": "query",
                "required": true,
                "description": "The brand the player signs up with, as the Affiliqo team gave it to you.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "LookupStag": {
                "name": "stag",
                "in": "query",
                "required": false,
                "description": "A stag as the partner's link gave it, such as `893_10000614`. Send exactly one of `stag`, `bonus_code` and `promo_code`.",
                "schema": {
                    "type": "string",
                    "maxLength": 255
                }
            },
            "LookupBonusCode": {
                "name": "bonus_code",
                "in": "query",
                "required": false,
                "description": "A bonus code as the player typed it; capitals don't matter. Send exactly one of `stag`, `bonus_code` and `promo_code`.",
                "schema": {
                    "type": "string",
                    "maxLength": 255
                }
            },
            "LookupPromoCode": {
                "name": "promo_code",
                "in": "query",
                "required": false,
                "description": "A promo's code, with its capitals as they are; spaces around it are ignored. Send exactly one of `stag`, `bonus_code` and `promo_code`.",
                "schema": {
                    "type": "string",
                    "maxLength": 255
                }
            }
        },
        "schemas": {
            "Window": {
                "type": "object",
                "additionalProperties": false,
                "description": "The span the activity covers, on whole minutes, sent once it has ended. It lies within one day of your program's timezone, and may end at its midnight but not after it.",
                "required": [
                    "from",
                    "to"
                ],
                "properties": {
                    "from": {
                        "type": "string",
                        "format": "date-time",
                        "description": "The window's start, with its UTC offset, such as `2026-10-10T07:00:00Z`."
                    },
                    "to": {
                        "type": "string",
                        "format": "date-time",
                        "description": "The window's end, after its start and not in the future."
                    }
                }
            },
            "CasinoFigures": {
                "type": "object",
                "additionalProperties": false,
                "description": "The player's casino play in the window, in minor units of the batch's currency, or as counts. A figure you leave out isn't sent, which is not the same as 0. Turnover and counts are 0 or more; a deduction can be negative, for a reversed bonus or a refunded fee.",
                "properties": {
                    "bets": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "wins": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "bets_count": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "rounds_count": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "wager": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "bet_rollbacks": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "win_rollbacks": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "bonuses": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "chargebacks": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "provider_fees": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "payment_fees": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "jackpot_fees": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "taxes": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "other_deductions": {
                        "type": "integer",
                        "format": "int64"
                    }
                }
            },
            "SportsbookFigures": {
                "type": "object",
                "additionalProperties": false,
                "description": "The player's sportsbook play in the window, in minor units of the batch's currency. A figure you leave out isn't sent. Turnover is 0 or more; a deduction or correction can be negative.",
                "properties": {
                    "bets": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "settled_bets": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "wins": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "win_rollbacks": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "cancelled": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "rejected": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "bonuses": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "balance_corrections": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "gifts": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "third_party_fees": {
                        "type": "integer",
                        "format": "int64"
                    },
                    "taxes": {
                        "type": "integer",
                        "format": "int64"
                    }
                }
            },
            "Deposit": {
                "type": "object",
                "additionalProperties": false,
                "description": "One deposit the player made in the window.",
                "required": [
                    "id",
                    "amount",
                    "at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your casino's own id of the deposit, unique in the batch."
                    },
                    "amount": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 1,
                        "description": "The amount, in minor units of the batch's currency."
                    },
                    "at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the deposit was made, with its UTC offset."
                    }
                }
            },
            "CashoutFigures": {
                "type": "object",
                "additionalProperties": false,
                "description": "The player's cashouts in the window, in minor units of the batch's currency, and how many there were.",
                "properties": {
                    "amount": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    },
                    "count": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 0
                    }
                }
            },
            "ActivityItem": {
                "type": "object",
                "additionalProperties": false,
                "description": "One player's activity in the window.",
                "required": [
                    "casino_player_id"
                ],
                "properties": {
                    "casino_player_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your casino's own id of the player, unique in the batch."
                    },
                    "casino": {
                        "$ref": "#/components/schemas/CasinoFigures"
                    },
                    "sportsbook": {
                        "$ref": "#/components/schemas/SportsbookFigures"
                    },
                    "deposits": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Deposit"
                        }
                    },
                    "cashouts": {
                        "$ref": "#/components/schemas/CashoutFigures"
                    }
                }
            },
            "ActivityBatch": {
                "type": "object",
                "additionalProperties": false,
                "description": "The activity of one brand's players in one window and one currency. A batch with no items says you had nothing to send for that window. Send amounts as JSON integers, never as decimals or text, and only the fields this reference defines: anything else is refused with 422, so a misspelt figure is never read as 0.",
                "required": [
                    "brand_id",
                    "currency",
                    "window",
                    "items"
                ],
                "properties": {
                    "brand_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The brand the activity belongs to, as the Affiliqo team gave it to you."
                    },
                    "currency": {
                        "type": "string",
                        "description": "The currency of every amount in the batch, one of the brand's, such as `EUR`."
                    },
                    "window": {
                        "$ref": "#/components/schemas/Window"
                    },
                    "items": {
                        "type": "array",
                        "maxItems": 5000,
                        "items": {
                            "$ref": "#/components/schemas/ActivityItem"
                        }
                    }
                }
            },
            "ControlSums": {
                "type": "object",
                "description": "What Affiliqo counted in the batch as it accepted it. Compare these sums with your own: a difference means the batch Affiliqo stored is not the one you meant to send. An activity batch also has the total of every figure, 0 where no item sent it, and the count and total of its deposits. A player batch counts its players by the attribution they came with, a flag batch how often it set and unset each flag, and a request of events how many events of each kind it holds.",
                "required": [
                    "items"
                ],
                "properties": {
                    "items": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "The number of items in the batch."
                    },
                    "casino": {
                        "type": "object",
                        "description": "The total of each casino figure.",
                        "required": [
                            "bets",
                            "wins",
                            "bets_count",
                            "rounds_count",
                            "wager",
                            "bet_rollbacks",
                            "win_rollbacks",
                            "bonuses",
                            "chargebacks",
                            "provider_fees",
                            "payment_fees",
                            "jackpot_fees",
                            "taxes",
                            "other_deductions"
                        ],
                        "properties": {
                            "bets": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "wins": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "bets_count": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "rounds_count": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "wager": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "bet_rollbacks": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "win_rollbacks": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "bonuses": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "chargebacks": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "provider_fees": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "payment_fees": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "jackpot_fees": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "taxes": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "other_deductions": {
                                "type": "integer",
                                "format": "int64"
                            }
                        }
                    },
                    "sportsbook": {
                        "type": "object",
                        "description": "The total of each sportsbook figure.",
                        "required": [
                            "bets",
                            "settled_bets",
                            "wins",
                            "win_rollbacks",
                            "cancelled",
                            "rejected",
                            "bonuses",
                            "balance_corrections",
                            "gifts",
                            "third_party_fees",
                            "taxes"
                        ],
                        "properties": {
                            "bets": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "settled_bets": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "wins": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "win_rollbacks": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "cancelled": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "rejected": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "bonuses": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "balance_corrections": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "gifts": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "third_party_fees": {
                                "type": "integer",
                                "format": "int64"
                            },
                            "taxes": {
                                "type": "integer",
                                "format": "int64"
                            }
                        }
                    },
                    "deposits": {
                        "type": "object",
                        "description": "How many deposits the batch holds, and their total.",
                        "required": [
                            "count",
                            "amount"
                        ],
                        "properties": {
                            "count": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "amount": {
                                "type": "integer",
                                "format": "int64",
                                "minimum": 0
                            }
                        }
                    },
                    "cashouts": {
                        "type": "object",
                        "description": "The totals of the cashouts' amount and count.",
                        "required": [
                            "amount",
                            "count"
                        ],
                        "properties": {
                            "amount": {
                                "type": "integer",
                                "format": "int64",
                                "minimum": 0
                            },
                            "count": {
                                "type": "integer",
                                "format": "int64",
                                "minimum": 0
                            }
                        }
                    },
                    "stags": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "How many of a player batch's players came with a stag."
                    },
                    "bonus_codes": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "How many came with a bonus code."
                    },
                    "promo_codes": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "How many came with a promo code."
                    },
                    "without_attribution": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "How many came without an attribution, as updates of players Affiliqo already has."
                    },
                    "disabled": {
                        "type": "object",
                        "description": "How many times a flag batch set and unset disabled.",
                        "required": [
                            "set",
                            "unset"
                        ],
                        "properties": {
                            "set": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "unset": {
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    },
                    "self_excluded": {
                        "type": "object",
                        "description": "How many times a flag batch set and unset self-excluded.",
                        "required": [
                            "set",
                            "unset"
                        ],
                        "properties": {
                            "set": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "unset": {
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    },
                    "duplicate": {
                        "type": "object",
                        "description": "How many times a flag batch set and unset duplicate.",
                        "required": [
                            "set",
                            "unset"
                        ],
                        "properties": {
                            "set": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "unset": {
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    },
                    "verified": {
                        "type": "object",
                        "description": "How many times a flag batch set and unset verified.",
                        "required": [
                            "set",
                            "unset"
                        ],
                        "properties": {
                            "set": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "unset": {
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    },
                    "frozen": {
                        "type": "object",
                        "description": "How many times a flag batch set and unset frozen.",
                        "required": [
                            "set",
                            "unset"
                        ],
                        "properties": {
                            "set": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "unset": {
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    },
                    "events": {
                        "type": "object",
                        "description": "How many events of each kind a request of events holds.",
                        "required": [
                            "deposit",
                            "first_deposit",
                            "cashout",
                            "kyc_verified"
                        ],
                        "properties": {
                            "deposit": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "first_deposit": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "cashout": {
                                "type": "integer",
                                "minimum": 0
                            },
                            "kyc_verified": {
                                "type": "integer",
                                "minimum": 0
                            }
                        }
                    }
                }
            },
            "Batch": {
                "type": "object",
                "description": "A batch you sent, as Affiliqo acknowledged it, and what became of it.",
                "required": [
                    "id",
                    "kind",
                    "status",
                    "control_sums",
                    "accepted_at"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The batch's id. Ask for its status with it."
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "activity",
                            "players",
                            "flags",
                            "events",
                            "sign_up"
                        ],
                        "description": "What the batch holds. A request of real-time events is a batch of kind `events`, and a sign-up call a batch of kind `sign_up` with its one player."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "accepted",
                            "quarantined",
                            "imported",
                            "partially_rejected",
                            "failed"
                        ],
                        "description": "Where the batch is. `accepted`: Affiliqo stored the batch and will process it. `quarantined`: Affiliqo stored the batch while your casino's ingest is paused, or accepted it just before and hadn't processed it yet, and will process it, in the order batches arrived, once ingest is back on. `imported`: Affiliqo processed the batch, and kept every item that a batch accepted later hadn't already replaced. `partially_rejected`: Affiliqo processed the batch, and some of its items were rejected or wait for their player. `failed`: Affiliqo couldn't process the batch and kept nothing of it; the Affiliqo team is looking into it. The acknowledgement of a batch, and of the same batch sent again, is always `accepted` or `quarantined`. New statuses may be added; treat one you don't know as still on its way."
                    },
                    "control_sums": {
                        "$ref": "#/components/schemas/ControlSums"
                    },
                    "accepted_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When Affiliqo acknowledged the batch, in UTC."
                    },
                    "quarantined_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When Affiliqo stored the batch as quarantined, in UTC. Only a quarantined batch has it."
                    }
                }
            },
            "FieldError": {
                "type": "object",
                "description": "One failing field of a request.",
                "required": [
                    "pointer",
                    "code",
                    "detail"
                ],
                "properties": {
                    "pointer": {
                        "type": "string",
                        "description": "The field, as an RFC 6901 JSON pointer, such as `/items/3/casino/bets`."
                    },
                    "code": {
                        "type": "string",
                        "description": "What is wrong with the field, as a stable code, such as `must_be_integer`."
                    },
                    "detail": {
                        "type": "string",
                        "description": "The same, for people. It never quotes the value sent."
                    }
                }
            },
            "Problem": {
                "type": "object",
                "description": "An RFC 9457 problem document from Affiliqo, as `application/problem+json`. Its `code` is stable and never changes its meaning; `title` and `detail` are for people.",
                "required": [
                    "title",
                    "status",
                    "detail",
                    "code",
                    "trace_id"
                ],
                "properties": {
                    "title": {
                        "type": "string",
                        "description": "A short summary of the kind of problem, such as \"Not Found\"."
                    },
                    "status": {
                        "type": "integer",
                        "description": "The HTTP status of the answer."
                    },
                    "detail": {
                        "type": "string",
                        "description": "What went wrong with this request."
                    },
                    "code": {
                        "type": "string",
                        "description": "The problem's stable code, such as `not_found`."
                    },
                    "trace_id": {
                        "type": "string",
                        "description": "The request's trace id, also sent in the `X-Trace-Id` header. Quote it when you ask about a request."
                    },
                    "errors": {
                        "type": "array",
                        "description": "For invalid input, a pointer to each failing field.",
                        "items": {
                            "$ref": "#/components/schemas/FieldError"
                        }
                    }
                }
            },
            "FirewallRefusal": {
                "type": "object",
                "description": "A refusal from the firewall in front of the API, before the request reached Affiliqo. It has the same fields as Affiliqo's problem documents, as `application/json`, without a trace id.",
                "required": [
                    "title",
                    "status",
                    "code",
                    "detail"
                ],
                "properties": {
                    "title": {
                        "type": "string",
                        "description": "A short summary of the kind of refusal, such as \"Forbidden\"."
                    },
                    "status": {
                        "type": "integer",
                        "description": "The HTTP status of the answer."
                    },
                    "code": {
                        "type": "string",
                        "description": "The refusal's stable code."
                    },
                    "detail": {
                        "type": "string",
                        "description": "What to do about it."
                    }
                }
            },
            "Attribution": {
                "type": "object",
                "additionalProperties": false,
                "description": "How the player came to you: exactly one of the stag from the partner's link, the bonus code or the promo code the player used. A new player needs it; an update of a player Affiliqo already has may leave it out.",
                "minProperties": 1,
                "maxProperties": 1,
                "properties": {
                    "stag": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                    },
                    "bonus_code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                    },
                    "promo_code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                    }
                }
            },
            "PlayerItem": {
                "type": "object",
                "additionalProperties": false,
                "description": "One player, new or updated. Email and names are stored encrypted and never shown to partners. Flags come in their own batches, with the time each changed.",
                "required": [
                    "casino_player_id",
                    "signed_up_at",
                    "email_hash"
                ],
                "properties": {
                    "casino_player_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your casino's own id of the player, unique in the batch."
                    },
                    "signed_up_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the player signed up, with its UTC offset, not in the future."
                    },
                    "first_deposit_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the player first deposited, with its UTC offset, not in the future. Send it for a player who deposited before you started sending activity. The player's first deposit is the earliest of this time and the deposits you send."
                    },
                    "email_hash": {
                        "type": "string",
                        "pattern": "^[0-9a-f]{64}$",
                        "description": "The lowercase hex SHA-256 of the player's email, lowercased."
                    },
                    "attribution": {
                        "$ref": "#/components/schemas/Attribution"
                    },
                    "email": {
                        "type": "string",
                        "maxLength": 254
                    },
                    "first_name": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "last_name": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "nickname": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "date_of_birth": {
                        "type": "string",
                        "format": "date",
                        "description": "As YYYY-MM-DD."
                    },
                    "gender": {
                        "type": "string",
                        "enum": [
                            "male",
                            "female",
                            "other"
                        ]
                    },
                    "country": {
                        "type": "string",
                        "pattern": "^[A-Z]{2}$",
                        "description": "The ISO 3166 country code, such as `MT`."
                    },
                    "language": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9-]{1,35}$",
                        "description": "The player's language, such as `en` or `en-GB`."
                    }
                }
            },
            "SignUp": {
                "type": "object",
                "additionalProperties": false,
                "description": "One new player, the moment they sign up, with the attribution they came with. Send only the fields this reference defines: anything else is refused with 422.",
                "required": [
                    "brand_id",
                    "player"
                ],
                "properties": {
                    "brand_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The brand the player signed up with, as the Affiliqo team gave it to you."
                    },
                    "player": {
                        "$ref": "#/components/schemas/PlayerItem"
                    }
                }
            },
            "AttributionAnswer": {
                "type": "object",
                "additionalProperties": false,
                "description": "Who the player belongs to, as Affiliqo resolved it from the attribution you sent: the partner, campaign, promo and stag, or the reason nobody.",
                "required": [
                    "result",
                    "source",
                    "partner_id",
                    "campaign_id",
                    "promo_id",
                    "stag",
                    "reason"
                ],
                "properties": {
                    "result": {
                        "type": "string",
                        "enum": [
                            "attributed",
                            "not_attributed"
                        ]
                    },
                    "source": {
                        "type": "string",
                        "nullable": true,
                        "enum": [
                            "visit",
                            "stag",
                            "bonus_code",
                            "promo_code"
                        ],
                        "description": "What attributed the player: a visit Affiliqo holds; a stag from before your program moved to Affiliqo, or one whose visit Affiliqo lost, which brings the partner without a campaign; a bonus code; or a promo's code. Null when nobody is attributed."
                    },
                    "partner_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true
                    },
                    "campaign_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true,
                        "description": "Null for a player attributed without a campaign."
                    },
                    "promo_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true
                    },
                    "stag": {
                        "type": "string",
                        "nullable": true,
                        "description": "The stag to keep with the player: the visit's own, or for a code always the code's own. Null when nobody is attributed, and, rarely, for a code whose stag Affiliqo couldn't give at that moment."
                    },
                    "reason": {
                        "type": "string",
                        "nullable": true,
                        "enum": [
                            "attribution_required",
                            "malformed_stag",
                            "unknown_partner",
                            "unknown_visit",
                            "visit_of_another_partner",
                            "visit_on_another_brand",
                            "signed_up_before_visit",
                            "expired_stag",
                            "partner_not_tracked",
                            "unknown_bonus_code",
                            "archived_bonus_code",
                            "unknown_promo_code"
                        ],
                        "description": "Why nobody is attributed, as a batch's outcomes give it; null when the player is attributed."
                    }
                }
            },
            "SignUpAccepted": {
                "type": "object",
                "additionalProperties": false,
                "description": "The sign-up, stored as a batch of its one player, and who the player belongs to.",
                "required": [
                    "id",
                    "kind",
                    "status",
                    "accepted_at",
                    "attribution"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The sign-up's batch. Ask for its status with it."
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "sign_up"
                        ]
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "accepted",
                            "quarantined"
                        ],
                        "description": "`quarantined` while your ingest is paused: the sign-up is kept, answered, and stored once it is on."
                    },
                    "accepted_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "quarantined_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "attribution": {
                        "$ref": "#/components/schemas/AttributionAnswer"
                    }
                }
            },
            "PlayerBatch": {
                "type": "object",
                "additionalProperties": false,
                "description": "New and changed players of one brand, hourly or as a full resync. Send only the fields this reference defines: anything else is refused with 422.",
                "required": [
                    "brand_id",
                    "items"
                ],
                "properties": {
                    "brand_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The brand the players signed up with, as the Affiliqo team gave it to you."
                    },
                    "items": {
                        "type": "array",
                        "maxItems": 1000,
                        "items": {
                            "$ref": "#/components/schemas/PlayerItem"
                        }
                    }
                }
            },
            "FlagChanges": {
                "type": "object",
                "additionalProperties": false,
                "description": "One to five of the player's flags, each `true` when it was set and `false` when it was unset.",
                "minProperties": 1,
                "maxProperties": 5,
                "properties": {
                    "disabled": {
                        "type": "boolean"
                    },
                    "self_excluded": {
                        "type": "boolean"
                    },
                    "duplicate": {
                        "type": "boolean"
                    },
                    "verified": {
                        "type": "boolean"
                    },
                    "frozen": {
                        "type": "boolean"
                    }
                }
            },
            "FlagItem": {
                "type": "object",
                "additionalProperties": false,
                "description": "A change of one player's flags at one time. A change dated in the past applies from that time, so it affects the right windows. A player, flag and time appear at most once in a batch.",
                "required": [
                    "casino_player_id",
                    "flags",
                    "at"
                ],
                "properties": {
                    "casino_player_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your casino's own id of the player."
                    },
                    "flags": {
                        "$ref": "#/components/schemas/FlagChanges"
                    },
                    "at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When the flags changed, with its UTC offset, not in the future."
                    },
                    "reason": {
                        "type": "string",
                        "maxLength": 500,
                        "description": "Why, for your team and the Affiliqo team. It is stored encrypted."
                    }
                }
            },
            "FlagBatch": {
                "type": "object",
                "additionalProperties": false,
                "description": "Changes of one brand's players' flags. Send only the fields this reference defines: anything else is refused with 422.",
                "required": [
                    "brand_id",
                    "items"
                ],
                "properties": {
                    "brand_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The brand the players belong to, as the Affiliqo team gave it to you."
                    },
                    "items": {
                        "type": "array",
                        "maxItems": 5000,
                        "items": {
                            "$ref": "#/components/schemas/FlagItem"
                        }
                    }
                }
            },
            "EventDeposit": {
                "type": "object",
                "additionalProperties": false,
                "description": "The deposit a deposit or first-deposit event is about.",
                "required": [
                    "id",
                    "amount",
                    "currency"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your casino's own id of the deposit, the one your activity batches list it with."
                    },
                    "amount": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 1,
                        "description": "The amount, in minor units of its currency."
                    },
                    "currency": {
                        "type": "string",
                        "description": "The deposit's currency, one the brand takes."
                    }
                }
            },
            "CasinoEvent": {
                "type": "object",
                "additionalProperties": false,
                "description": "One event. A deposit and a first deposit carry `deposit`; a cashout carries `amount` and `currency`; a verified identity carries nothing more. A field another kind carries is refused.",
                "required": [
                    "id",
                    "kind",
                    "at",
                    "casino_player_id"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your own id of the event, at most once in a request. Affiliqo records an event once for the brand: an id it has recorded already is taken, and changes nothing."
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "deposit",
                            "first_deposit",
                            "cashout",
                            "kyc_verified"
                        ],
                        "description": "What happened. `deposit`: the player deposited. `first_deposit`: the player's first deposit. `cashout`: the player cashed out. `kyc_verified`: the player's identity was verified. Cashouts and verified identities are recorded only."
                    },
                    "at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When it happened, with its UTC offset, at most 300 seconds ahead of Affiliqo's clock."
                    },
                    "casino_player_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Your casino's own id of the player. An event for a player Affiliqo hasn't received yet waits for them, and is recorded as soon as they arrive."
                    },
                    "deposit": {
                        "$ref": "#/components/schemas/EventDeposit"
                    },
                    "amount": {
                        "type": "integer",
                        "format": "int64",
                        "minimum": 1,
                        "description": "A cashout's amount, in minor units of its currency."
                    },
                    "currency": {
                        "type": "string",
                        "description": "A cashout's currency, one the brand takes."
                    }
                }
            },
            "EventBatch": {
                "type": "object",
                "additionalProperties": false,
                "description": "Events of one brand's players, as they happen. Send only the fields this reference defines: anything else is refused with 422.",
                "required": [
                    "brand_id",
                    "events"
                ],
                "properties": {
                    "brand_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The brand the players belong to, as the Affiliqo team gave it to you."
                    },
                    "events": {
                        "type": "array",
                        "maxItems": 100,
                        "items": {
                            "$ref": "#/components/schemas/CasinoEvent"
                        }
                    }
                }
            },
            "BatchCounts": {
                "type": "object",
                "description": "What became of the batch's items: how many Affiliqo imported, found superseded by a batch you sent later, rejected, and parked to wait for their player. Once the batch is processed, they add up to its items; before, they are all 0.",
                "required": [
                    "imported",
                    "superseded",
                    "rejected",
                    "parked"
                ],
                "properties": {
                    "imported": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Items Affiliqo kept."
                    },
                    "superseded": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Items that changed nothing, because a batch you sent later had already given Affiliqo a newer version of the same player or window."
                    },
                    "rejected": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Items Affiliqo refused, each listed with its reason. The rest of the batch was kept."
                    },
                    "parked": {
                        "type": "integer",
                        "minimum": 0,
                        "description": "Items waiting for a player you haven't sent yet, processed as soon as the player arrives."
                    }
                }
            },
            "BatchOutcome": {
                "type": "object",
                "description": "One rejected or parked item of the batch, and why: a problem of the item itself in `problem`, or the reason Affiliqo attributed a new player to nobody in `refusal`. An item has one of the two.",
                "required": [
                    "pointer",
                    "casino_player_id",
                    "outcome",
                    "detail"
                ],
                "properties": {
                    "pointer": {
                        "type": "string",
                        "description": "Where the item is in the batch you sent, as a JSON pointer, such as `/items/12`."
                    },
                    "casino_player_id": {
                        "type": "string",
                        "description": "Your casino's id of the item's player."
                    },
                    "outcome": {
                        "type": "string",
                        "enum": [
                            "rejected",
                            "parked"
                        ],
                        "description": "`rejected`: Affiliqo refused the item. `parked`: the item waits for its player."
                    },
                    "problem": {
                        "type": "string",
                        "enum": [
                            "deposit_outside_window",
                            "unknown_player",
                            "window_overlaps",
                            "time_out_of_range",
                            "release_failed",
                            "batch_expired"
                        ],
                        "description": "What is wrong with the item. `deposit_outside_window`: a deposit's time isn't inside the batch's window, and `pointer` points at that deposit; send each deposit in the window its time falls in. `unknown_player`: Affiliqo hasn't received the player yet, so the item is parked; send the player, and the item is processed once the player arrives, and the batch becomes imported once nothing of it is rejected or parked. `window_overlaps`: the window partly overlaps one of the player's windows in the same currency that Affiliqo already has, named in `overlaps`; send that exact window again to replace it, or windows that don't overlap it. `time_out_of_range`: a time before 2000; fix it and send the item again in a new batch, under a new Idempotency-Key. `release_failed`: Affiliqo couldn't process a parked item when its player arrived; the Affiliqo team fixes the cause and processes the batch again, so don't send it again. `batch_expired`: the item's player never arrived while the program kept the batch, so the item was rejected when the batch was deleted after the program's retention period; send the player, then the item again in a new batch. New problems may be added."
                    },
                    "refusal": {
                        "type": "string",
                        "enum": [
                            "attribution_required",
                            "malformed_stag",
                            "unknown_partner",
                            "unknown_visit",
                            "visit_of_another_partner",
                            "visit_on_another_brand",
                            "signed_up_before_visit",
                            "expired_stag",
                            "partner_not_tracked",
                            "unknown_bonus_code",
                            "archived_bonus_code",
                            "unknown_promo_code"
                        ],
                        "description": "Why a new player was attributed to nobody, so Affiliqo didn't keep them. `attribution_required`: a player Affiliqo hasn't received yet needs its stag, bonus code or promo code. `malformed_stag`: the stag isn't two numbers joined by an underscore. `unknown_partner`: no partner of the program has the stag's number. `unknown_visit`: Affiliqo can't account for the stag's visit number. `visit_of_another_partner`, `visit_on_another_brand`: the stag's visit, or the code it stands for, is another partner's or on another brand. `signed_up_before_visit`: the player signed up more than 5 minutes before the visit. `expired_stag`: the player signed up after the visit's cookie lifetime. `partner_not_tracked`: the partner was blocked or rejected when it mattered. `unknown_bonus_code`, `unknown_promo_code`: no code of the brand matches. `archived_bonus_code`: the bonus code was archived before the player signed up. New reasons may be added."
                    },
                    "detail": {
                        "type": "string",
                        "description": "What the reason means, for people. It never quotes what you sent."
                    },
                    "overlaps": {
                        "type": "object",
                        "additionalProperties": false,
                        "description": "With `window_overlaps`, the player's window Affiliqo already has that the item's window partly overlaps, in UTC.",
                        "required": [
                            "from",
                            "to"
                        ],
                        "properties": {
                            "from": {
                                "type": "string",
                                "format": "date-time",
                                "description": "The window's start, such as `2026-10-10T07:30:00Z`."
                            },
                            "to": {
                                "type": "string",
                                "format": "date-time",
                                "description": "The window's end."
                            }
                        }
                    }
                }
            },
            "BatchFailure": {
                "type": "object",
                "description": "Why Affiliqo couldn't process the batch, and whether to send it again. Only a failed batch has it. Nothing of a failed batch was kept, and the Affiliqo team hears of every failure at once.",
                "required": [
                    "code",
                    "detail",
                    "send_again"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "enum": [
                            "payload_unreadable",
                            "payload_altered",
                            "payload_missing",
                            "control_sums_mismatch",
                            "processing_error"
                        ],
                        "description": "`payload_unreadable`: Affiliqo couldn't read the batch it stored. `payload_altered`: the stored batch doesn't match the one you sent. `payload_missing`: Affiliqo couldn't find the batch it archived after 30 days. `control_sums_mismatch`: processing didn't add up to the batch's control sums. `processing_error`: processing failed every time it was tried. New codes may be added."
                    },
                    "detail": {
                        "type": "string",
                        "description": "What the failure means, for people."
                    },
                    "send_again": {
                        "type": "boolean",
                        "description": "Whether to send the batch again, under a new Idempotency-Key. The Affiliqo team asks for it only when the batch Affiliqo stored is lost; otherwise they fix the cause and process the stored batch again, so sending it again isn't needed."
                    }
                }
            },
            "BatchResult": {
                "description": "A batch you sent, what became of it, and the first of its rejected and parked items.",
                "allOf": [
                    {
                        "$ref": "#/components/schemas/Batch"
                    },
                    {
                        "type": "object",
                        "required": [
                            "counts",
                            "outcomes",
                            "next_outcomes_cursor"
                        ],
                        "properties": {
                            "processed_at": {
                                "type": "string",
                                "format": "date-time",
                                "description": "When Affiliqo processed the batch, in UTC. Only a processed batch has it."
                            },
                            "counts": {
                                "$ref": "#/components/schemas/BatchCounts"
                            },
                            "outcomes": {
                                "type": "array",
                                "maxItems": 100,
                                "description": "The batch's first 100 rejected and parked items, in their order in the batch, each with its reason. Items a batch you sent later already replaced are counted as superseded, never listed. Empty until the batch is processed, and when nothing of it was refused.",
                                "items": {
                                    "$ref": "#/components/schemas/BatchOutcome"
                                }
                            },
                            "next_outcomes_cursor": {
                                "type": "string",
                                "nullable": true,
                                "description": "Pass it to `GET /batches/{id}/outcomes` to read the next 100 of these items, or null when the list above holds them all."
                            },
                            "failure": {
                                "$ref": "#/components/schemas/BatchFailure"
                            }
                        }
                    }
                ]
            },
            "BatchOutcomes": {
                "type": "object",
                "description": "A page of a batch's rejected and parked items, in their order in the batch.",
                "required": [
                    "outcomes",
                    "next_outcomes_cursor"
                ],
                "properties": {
                    "outcomes": {
                        "type": "array",
                        "maxItems": 100,
                        "description": "Up to 100 rejected and parked items, after those of the page before.",
                        "items": {
                            "$ref": "#/components/schemas/BatchOutcome"
                        }
                    },
                    "next_outcomes_cursor": {
                        "type": "string",
                        "nullable": true,
                        "description": "Pass it to read the next page, or null when this page is the last."
                    }
                }
            },
            "MerchantProfile": {
                "type": "object",
                "description": "Your casino's profile, as Affiliqo holds it.",
                "required": [
                    "id",
                    "name",
                    "timezone",
                    "default_currency",
                    "brands",
                    "capabilities"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Your casino's id at Affiliqo."
                    },
                    "name": {
                        "type": "string",
                        "description": "Your casino's name."
                    },
                    "timezone": {
                        "type": "string",
                        "description": "Your program's timezone, such as `Europe/Malta`, which activity windows and periods follow."
                    },
                    "default_currency": {
                        "type": "string",
                        "description": "Your program's default currency."
                    },
                    "brands": {
                        "type": "array",
                        "description": "Your brands, by name.",
                        "items": {
                            "type": "object",
                            "required": [
                                "id",
                                "name",
                                "products",
                                "currencies",
                                "rhythm_minutes"
                            ],
                            "properties": {
                                "id": {
                                    "type": "string",
                                    "format": "uuid",
                                    "description": "The brand's id, which every batch names."
                                },
                                "name": {
                                    "type": "string"
                                },
                                "products": {
                                    "type": "array",
                                    "items": {
                                        "type": "string",
                                        "enum": [
                                            "casino",
                                            "sportsbook"
                                        ]
                                    }
                                },
                                "currencies": {
                                    "type": "array",
                                    "description": "The currencies the brand's players use, which batches and events may name.",
                                    "items": {
                                        "type": "string"
                                    }
                                },
                                "rhythm_minutes": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 1440,
                                    "description": "How often you send the brand's activity, in minutes; 60 for hourly windows."
                                }
                            }
                        }
                    },
                    "capabilities": {
                        "type": "array",
                        "description": "Each capability of your program, whether it is on, and how it behaves while off.",
                        "items": {
                            "type": "object",
                            "required": [
                                "capability",
                                "enabled",
                                "off_mode"
                            ],
                            "properties": {
                                "capability": {
                                    "type": "string",
                                    "description": "The capability, such as `ingest`. New capabilities may be added."
                                },
                                "enabled": {
                                    "type": "boolean"
                                },
                                "off_mode": {
                                    "type": "string",
                                    "description": "What the capability does while off, such as `quarantine` for ingest. New modes may be added."
                                }
                            }
                        }
                    }
                }
            },
            "HealthStatus": {
                "type": "string",
                "enum": [
                    "ok",
                    "late",
                    "backlogged"
                ],
                "description": "`ok`; `late`, when no activity batch, an empty one included, came within the brand's rhythm plus 15 minutes; or `backlogged`, when a batch has waited more than 5 minutes to be processed. New statuses may be added."
            },
            "IngestHealth": {
                "type": "object",
                "description": "Your ingest health, as last measured.",
                "required": [
                    "status",
                    "measured_at",
                    "brands"
                ],
                "properties": {
                    "status": {
                        "$ref": "#/components/schemas/HealthStatus"
                    },
                    "measured_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "When it was measured, in UTC, at most a minute ago."
                    },
                    "brands": {
                        "type": "array",
                        "description": "Each of your brands, by name.",
                        "items": {
                            "type": "object",
                            "required": [
                                "brand_id",
                                "status",
                                "rhythm_minutes",
                                "last_accepted",
                                "activity",
                                "processing_lag_seconds",
                                "waiting_batches",
                                "quarantined_batches",
                                "failed_batches",
                                "parked_items",
                                "overdue_items"
                            ],
                            "properties": {
                                "brand_id": {
                                    "type": "string",
                                    "format": "uuid"
                                },
                                "status": {
                                    "$ref": "#/components/schemas/HealthStatus"
                                },
                                "rhythm_minutes": {
                                    "type": "integer",
                                    "description": "How often you send the brand's activity, in minutes."
                                },
                                "last_accepted": {
                                    "type": "object",
                                    "description": "When Affiliqo last accepted a batch of each kind for the brand, in UTC, or null for a kind you never sent.",
                                    "required": [
                                        "players",
                                        "flags",
                                        "activity",
                                        "events",
                                        "sign_ups"
                                    ],
                                    "properties": {
                                        "players": {
                                            "type": "string",
                                            "format": "date-time",
                                            "nullable": true
                                        },
                                        "flags": {
                                            "type": "string",
                                            "format": "date-time",
                                            "nullable": true
                                        },
                                        "activity": {
                                            "type": "string",
                                            "format": "date-time",
                                            "nullable": true
                                        },
                                        "events": {
                                            "type": "string",
                                            "format": "date-time",
                                            "nullable": true
                                        },
                                        "sign_ups": {
                                            "type": "string",
                                            "format": "date-time",
                                            "nullable": true
                                        }
                                    }
                                },
                                "activity": {
                                    "type": "array",
                                    "description": "Up to when the brand's activity in each currency has been processed.",
                                    "items": {
                                        "type": "object",
                                        "required": [
                                            "currency",
                                            "processed_until"
                                        ],
                                        "properties": {
                                            "currency": {
                                                "type": "string"
                                            },
                                            "processed_until": {
                                                "type": "string",
                                                "format": "date-time",
                                                "description": "The end of the latest window processed in the currency, in UTC."
                                            }
                                        }
                                    }
                                },
                                "processing_lag_seconds": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "How long the brand's oldest batch still waiting to be processed has waited, or 0."
                                },
                                "waiting_batches": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Batches accepted and still waiting to be processed."
                                },
                                "quarantined_batches": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Batches held while your ingest is paused, processed once it is on again."
                                },
                                "failed_batches": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Batches that failed; the Affiliqo team processes them again once the cause is fixed."
                                },
                                "parked_items": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Items waiting for a player you haven't sent yet."
                                },
                                "overdue_items": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "description": "Those of them waiting more than 30 days."
                                }
                            }
                        }
                    }
                }
            },
            "AttributionLookup": {
                "type": "object",
                "additionalProperties": false,
                "description": "Who a player who signed up now with this stag or code would belong to, as the sign-up call answers.",
                "required": [
                    "attribution"
                ],
                "properties": {
                    "attribution": {
                        "$ref": "#/components/schemas/AttributionAnswer"
                    }
                }
            }
        },
        "responses": {
            "BadRequest": {
                "description": "The request can't be read. `malformed_body`: the body is no JSON object of valid UTF-8 at most 64 levels deep, or a gzipped body isn't one complete gzip stream. `unsupported_content_encoding`: send plain JSON, or gzip with `Content-Encoding: gzip`. `idempotency_key_required`: send an `Idempotency-Key` of 1 to 255 printable characters without spaces. Nothing was stored, so you can fix the request and send it again under the same key.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "malformed_body",
                                                "unsupported_content_encoding",
                                                "idempotency_key_required"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Unauthorized": {
                "description": "The request isn't signed with a working key. `unauthenticated`: the Authorization header is missing, or isn't of the form `Affiliqo-HMAC-SHA256 key=…, ts=…, sig=…`. `stale_timestamp`: `ts` is more than 5 minutes away from Affiliqo's clock; the detail gives both times, and the `Date` header gives Affiliqo's. `invalid_key`: the key is unknown or no longer works. `invalid_signature`: `sig` doesn't match the request under the key's secret.",
                "headers": {
                    "WWW-Authenticate": {
                        "description": "The scheme to sign requests with.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "Affiliqo-HMAC-SHA256"
                            ]
                        }
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "unauthenticated",
                                                "stale_timestamp",
                                                "invalid_key",
                                                "invalid_signature"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "CapabilityOff": {
                "description": "The part of the merchant's subscription this operation belongs to is switched off, as `capability_off`. Ask the Affiliqo team about the subscription.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "capability_off"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Forbidden": {
                "description": "The credential may not do this. Affiliqo answers with `scope_missing` when the credential lacks the scope the operation needs, and with `address_not_allowed` when the request came from an address the credential doesn't list. The firewall answers an address that no active credential lists itself, as `application/json`, and so it answers an address registered only on statistic or data tokens anywhere but under `/stats/` and `/operator/`.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "scope_missing",
                                                "address_not_allowed"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    "application/json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/FirewallRefusal"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "address_not_allowed"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Conflict": {
                "description": "The `Idempotency-Key` was already used for another body or another kind of batch, as `idempotency_conflict`. This batch was not stored: send it under a new key. A retry of the same JSON under the same key is never a conflict; it gets the first answer again. After 30 days, a gzipped batch's retry must carry the very bytes sent first.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "idempotency_conflict"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "PayloadTooLarge": {
                "description": "The body is larger than 5 MB as sent or once inflated, as `payload_too_large`. Split the batch. A body far over the limit may be cut off before it reaches Affiliqo, with a plain 413.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "payload_too_large"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidBatch": {
                "description": "The batch's structure is invalid, as `invalid_input`. `errors` points at the first 100 problems, in the order of the body, and the detail says how many there were. Nothing was stored, so you can fix the batch and send it again under the same key. New field codes may be added; treat one you don't know as a problem with that field.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "required": [
                                        "errors"
                                    ],
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_input"
                                            ]
                                        },
                                        "errors": {
                                            "type": "array",
                                            "maxItems": 100,
                                            "items": {
                                                "allOf": [
                                                    {
                                                        "$ref": "#/components/schemas/FieldError"
                                                    },
                                                    {
                                                        "type": "object",
                                                        "properties": {
                                                            "code": {
                                                                "type": "string",
                                                                "enum": [
                                                                    "required",
                                                                    "must_be_object",
                                                                    "must_be_array",
                                                                    "must_be_string",
                                                                    "must_be_integer",
                                                                    "must_be_boolean",
                                                                    "must_be_non_negative",
                                                                    "must_be_positive",
                                                                    "too_long",
                                                                    "unknown_field",
                                                                    "invalid_time",
                                                                    "invalid_date",
                                                                    "not_whole_minutes",
                                                                    "window_empty",
                                                                    "window_in_future",
                                                                    "window_crosses_midnight",
                                                                    "time_in_future",
                                                                    "too_many_items",
                                                                    "unknown_brand",
                                                                    "currency_not_on_brand",
                                                                    "duplicate_item",
                                                                    "one_attribution",
                                                                    "invalid_email_hash",
                                                                    "invalid_country",
                                                                    "invalid_value",
                                                                    "total_too_large"
                                                                ]
                                                            }
                                                        }
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "TooManyRequests": {
                "description": "Too many requests. Affiliqo's answer says in `Retry-After` how many seconds to wait. The firewall's answer, for too many requests from one address, is `application/json` and has no `Retry-After`: wait a few minutes, then retry.",
                "headers": {
                    "Retry-After": {
                        "description": "The seconds to wait before retrying. Only Affiliqo's own answer has it.",
                        "schema": {
                            "type": "integer",
                            "minimum": 0
                        }
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "too_many_requests"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    "application/json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/FirewallRefusal"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "too_many_requests"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "ServerError": {
                "description": "Something went wrong on Affiliqo's side, as `server_error`. Retry later; quote the `trace_id` if it lasts.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "server_error"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Unavailable": {
                "description": "Affiliqo is briefly unavailable, as during a deploy, as `unavailable`. Retry in a minute.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "unavailable"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "SignUpUnavailable": {
                "description": "Affiliqo can't tell at the moment whether it holds the stag's visit, as `attribution_unavailable`, so it neither attributes nor refuses the player; or it is briefly unavailable, as `unavailable`. Send the same call again, under the same `Idempotency-Key`, after the seconds `Retry-After` gives.",
                "headers": {
                    "Retry-After": {
                        "description": "Seconds to wait before sending the call again.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "attribution_unavailable",
                                                "unavailable"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "NotFound": {
                "description": "Nothing exists at this address for your credential, as `not_found`.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "not_found"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidCursor": {
                "description": "`invalid_cursor`: the cursor isn't one Affiliqo gave. Send the `next_outcomes_cursor` of the page before exactly as it came, or no cursor for the first page.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_cursor"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidLookup": {
                "description": "The query is invalid, as `invalid_input`: it names none of your brands, holds no attribution or more than one, or a parameter this reference doesn't define. `errors` points at each parameter by its name, such as `/brand_id`, and at the query itself, as an empty pointer, when it holds no attribution or more than one.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "required": [
                                        "errors"
                                    ],
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_input"
                                            ]
                                        },
                                        "errors": {
                                            "type": "array",
                                            "items": {
                                                "allOf": [
                                                    {
                                                        "$ref": "#/components/schemas/FieldError"
                                                    },
                                                    {
                                                        "type": "object",
                                                        "properties": {
                                                            "code": {
                                                                "type": "string",
                                                                "enum": [
                                                                    "required",
                                                                    "must_be_string",
                                                                    "too_long",
                                                                    "unknown_field",
                                                                    "unknown_brand",
                                                                    "one_attribution"
                                                                ]
                                                            }
                                                        }
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "LookupUnavailable": {
                "description": "Affiliqo can't tell at the moment whether it holds the stag's visit, as `attribution_unavailable`; or it is briefly unavailable, as `unavailable`. Ask again after the seconds `Retry-After` gives.",
                "headers": {
                    "Retry-After": {
                        "description": "Seconds to wait before asking again.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "attribution_unavailable",
                                                "unavailable"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
}
