{
    "openapi": "3.0.3",
    "info": {
        "title": "Partner Statistics API",
        "version": "current",
        "description": "The partner statistics API gives your tracker or your own tools the reports you see in the partner portal: your visits, players and earnings, as the program lets you see them.\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- 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- A parameter a report doesn't define is refused with `422`, so a misspelt filter never widens a report.\n\n## Tokens and addresses\n\nEvery request carries one of your statistic tokens:\n\n```\nAuthorization: Bearer afq_stat_live_…\n```\n\n- Create a token in the partner portal under **Account → API Tokens**, once the program has switched on your API access. It is shown once: keep it in your tracker's secret store.\n- Each token lists the IP addresses it may be used from. Requests come only from those: a request from any other address is refused, by the firewall before it reaches Affiliqo, or by Affiliqo with `403` and `address_not_allowed`. A new token's addresses reach the API about a minute after you save them, and a revoked token's stop within about a minute.\n- You have at most 3 working tokens. A token stops working when you revoke it, when its user leaves your team, when your account is blocked, or when the program switches off your API access.\n\n## Limits\n\nEach token may send 60 requests a minute. Past that, the answer is `429` with `Retry-After`, the seconds to wait. An address that sends 30 requests with a wrong token in a minute gets `429` too, until the minute ends.\n\nWhen reports are briefly busy or a report takes too long, the answer is `503` with `Retry-After`; ask again after it, or for a shorter span.\n\n## What the reports hold\n\n- Money is in minor units of the answer's `currency`: cents for USD. A currency with many decimal places, such as USDT, gives integers past JavaScript's safe integers, so parse amounts as big integers.\n- Every amount is in one currency: the program's unless you ask for another with `currency`, converted at the rates of `rates_on`.\n- A report counts days, weeks and months in `timezone`, yours unless you ask for another.\n- Players show by their masked id, country and sign-up date, and a player key, which tells two players with the same masked id apart and stays the same from month to month. Filter by players with `player_ids` and their keys. When the program rotates its keys, every player gets a new key.\n- Frozen activity is left out of every report, as your bills leave it out: what a player brought while the casino had closed, blocked or self-excluded them, or the program had frozen them.\n- What your bills paid (payable NGR, partner income and each reward kind) shows by brand, deal, deal strategy, campaign, promo, country and date, never by player, sign-up date, first-deposit date or tag.\n\n`GET /stats/reports/attributes` lists exactly what you may ask of each report you get.\n\n## Pages\n\nA report gives 100 rows a page unless you ask for up to 1,000 with `limit`. When there are more, `next_cursor` is set: send it as `cursor` with exactly the same parameters for the next page, until it is null. Each page reads the report as it is when you ask for it, so rows can move between pages while the casino sends new activity. When the pages must add up, ask one page of up to 1,000 rows, or a span that has ended.\n\n## Errors\n\nEvery error is a problem document with a stable `code`, such as `invalid_token` or `address_not_allowed`, and a `trace_id` to quote when you ask the program about a request. An error from the firewall, before the request reached Affiliqo, has the same fields as `application/json`, without a trace id.\n"
    },
    "servers": [
        {
            "url": "https://api.affiliqo.com",
            "description": "Production"
        }
    ],
    "security": [
        {
            "Token": []
        }
    ],
    "paths": {
        "/stats/reports/statistics": {
            "get": {
                "operationId": "getStatisticsReport",
                "summary": "Read your statistics report",
                "description": "What your links' visits and your players brought: visits, registrations, first deposits, deposits, cashouts, NGR and, when the program shows them to you, GGR, real NGR and the admin fee; and what your bills paid: payable NGR, partner income and each reward kind, counted on the first day of their period, with the current period's estimate until its bill is issued. Frozen activity, what a player brought while the casino had closed, blocked or self-excluded them or the program had frozen them, is left out, as your bills leave it out. Bill figures show by brand, deal, deal strategy, campaign, promo, country and date, never by player.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/From"
                    },
                    {
                        "$ref": "#/components/parameters/To"
                    },
                    {
                        "$ref": "#/components/parameters/Timezone"
                    },
                    {
                        "$ref": "#/components/parameters/GroupBy"
                    },
                    {
                        "$ref": "#/components/parameters/DateGrain"
                    },
                    {
                        "$ref": "#/components/parameters/Tag"
                    },
                    {
                        "$ref": "#/components/parameters/Columns"
                    },
                    {
                        "$ref": "#/components/parameters/Currency"
                    },
                    {
                        "$ref": "#/components/parameters/RatesOn"
                    },
                    {
                        "$ref": "#/components/parameters/Bots"
                    },
                    {
                        "$ref": "#/components/parameters/Sort"
                    },
                    {
                        "$ref": "#/components/parameters/Direction"
                    },
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/BrandIds"
                    },
                    {
                        "$ref": "#/components/parameters/DealIds"
                    },
                    {
                        "$ref": "#/components/parameters/Strategies"
                    },
                    {
                        "$ref": "#/components/parameters/CampaignIds"
                    },
                    {
                        "$ref": "#/components/parameters/PromoIds"
                    },
                    {
                        "$ref": "#/components/parameters/PlayerIds"
                    },
                    {
                        "$ref": "#/components/parameters/PlayerCountries"
                    },
                    {
                        "$ref": "#/components/parameters/TagValues"
                    },
                    {
                        "$ref": "#/components/parameters/BillId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The report, or one page of it.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ReportAnswer"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidReportCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "409": {
                        "$ref": "#/components/responses/RateMissing"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidReport"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/ReportsUnavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads your statistics report for September, by campaign. The token comes from your secret store.\n$query = http_build_query(['from' => '2026-09-01T00:00:00Z', 'to' => '2026-10-01T00:00:00Z', 'group_by' => 'campaign', 'columns' => 'registrations,casino_ngr_amount']);\n$curl = curl_init('https://api.affiliqo.com/stats/reports/statistics'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo count($answer['rows']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads your statistics report for September, by campaign. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({ from: '2026-09-01T00:00:00Z', to: '2026-10-01T00:00:00Z', group_by: 'campaign', columns: 'registrations,casino_ngr_amount' }).toString();\nconst url = 'https://api.affiliqo.com/stats/reports/statistics' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status === 200) {\n  console.log(answer.rows.length);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads your statistics report for September, by campaign. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({\"from\": \"2026-09-01T00:00:00Z\", \"to\": \"2026-10-01T00:00:00Z\", \"group_by\": \"campaign\", \"columns\": \"registrations,casino_ngr_amount\"})\nurl = \"https://api.affiliqo.com/stats/reports/statistics\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(url, headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]})\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(len(answer[\"rows\"]))\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Reads your statistics report for September, by campaign. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\tquery.Set(\"from\", \"2026-09-01T00:00:00Z\")\n\tquery.Set(\"to\", \"2026-10-01T00:00:00Z\")\n\tquery.Set(\"group_by\", \"campaign\")\n\tquery.Set(\"columns\", \"registrations,casino_ngr_amount\")\n\ttarget := \"https://api.affiliqo.com/stats/reports/statistics\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(http.MethodGet, target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\titems, _ := answer[\"rows\"].([]any)\n\t\tfmt.Println(len(items))\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/reports/traffic": {
            "get": {
                "operationId": "getTrafficReport",
                "summary": "Read your traffic report",
                "description": "Your links' visits, unique and bot visits, and the players they brought, by landing page, device, browser, operating system, visit country, referring site, traffic source, campaign, promo, date or a dynamic tag, with the conversion rates between them.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/From"
                    },
                    {
                        "$ref": "#/components/parameters/To"
                    },
                    {
                        "$ref": "#/components/parameters/Timezone"
                    },
                    {
                        "$ref": "#/components/parameters/GroupBy"
                    },
                    {
                        "$ref": "#/components/parameters/DateGrain"
                    },
                    {
                        "$ref": "#/components/parameters/Tag"
                    },
                    {
                        "$ref": "#/components/parameters/Columns"
                    },
                    {
                        "$ref": "#/components/parameters/Currency"
                    },
                    {
                        "$ref": "#/components/parameters/RatesOn"
                    },
                    {
                        "$ref": "#/components/parameters/Bots"
                    },
                    {
                        "$ref": "#/components/parameters/Sort"
                    },
                    {
                        "$ref": "#/components/parameters/Direction"
                    },
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/Stag"
                    },
                    {
                        "$ref": "#/components/parameters/BrandIds"
                    },
                    {
                        "$ref": "#/components/parameters/CampaignIds"
                    },
                    {
                        "$ref": "#/components/parameters/PromoIds"
                    },
                    {
                        "$ref": "#/components/parameters/PlayerIds"
                    },
                    {
                        "$ref": "#/components/parameters/LandingIds"
                    },
                    {
                        "$ref": "#/components/parameters/Devices"
                    },
                    {
                        "$ref": "#/components/parameters/BrowserFamilies"
                    },
                    {
                        "$ref": "#/components/parameters/OsFamilies"
                    },
                    {
                        "$ref": "#/components/parameters/VisitCountries"
                    },
                    {
                        "$ref": "#/components/parameters/Referrers"
                    },
                    {
                        "$ref": "#/components/parameters/TrafficSourceIds"
                    },
                    {
                        "$ref": "#/components/parameters/TagValues"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The report, or one page of it.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ReportAnswer"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidReportCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/RateMissing"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidReport"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/ReportsUnavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads your traffic report for September, by landing page. The token comes from your secret store.\n$query = http_build_query(['from' => '2026-09-01T00:00:00Z', 'to' => '2026-10-01T00:00:00Z', 'group_by' => 'landing', 'columns' => 'visits,registrations']);\n$curl = curl_init('https://api.affiliqo.com/stats/reports/traffic'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo count($answer['rows']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads your traffic report for September, by landing page. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({ from: '2026-09-01T00:00:00Z', to: '2026-10-01T00:00:00Z', group_by: 'landing', columns: 'visits,registrations' }).toString();\nconst url = 'https://api.affiliqo.com/stats/reports/traffic' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status === 200) {\n  console.log(answer.rows.length);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads your traffic report for September, by landing page. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({\"from\": \"2026-09-01T00:00:00Z\", \"to\": \"2026-10-01T00:00:00Z\", \"group_by\": \"landing\", \"columns\": \"visits,registrations\"})\nurl = \"https://api.affiliqo.com/stats/reports/traffic\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(url, headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]})\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(len(answer[\"rows\"]))\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Reads your traffic report for September, by landing page. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\tquery.Set(\"from\", \"2026-09-01T00:00:00Z\")\n\tquery.Set(\"to\", \"2026-10-01T00:00:00Z\")\n\tquery.Set(\"group_by\", \"landing\")\n\tquery.Set(\"columns\", \"visits,registrations\")\n\ttarget := \"https://api.affiliqo.com/stats/reports/traffic\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(http.MethodGet, target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\titems, _ := answer[\"rows\"].([]any)\n\t\tfmt.Println(len(items))\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/reports/cohorts": {
            "get": {
                "operationId": "getCohortReport",
                "summary": "Read your cohort report",
                "description": "Your players grouped by the day, week or month they signed up, first deposited or deposited, and one figure of theirs in each period from the cohort's own.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/From"
                    },
                    {
                        "$ref": "#/components/parameters/To"
                    },
                    {
                        "$ref": "#/components/parameters/Timezone"
                    },
                    {
                        "$ref": "#/components/parameters/Currency"
                    },
                    {
                        "$ref": "#/components/parameters/RatesOn"
                    },
                    {
                        "$ref": "#/components/parameters/CohortType"
                    },
                    {
                        "$ref": "#/components/parameters/CohortGrain"
                    },
                    {
                        "$ref": "#/components/parameters/Figure"
                    },
                    {
                        "$ref": "#/components/parameters/Periods"
                    },
                    {
                        "$ref": "#/components/parameters/BrandIds"
                    },
                    {
                        "$ref": "#/components/parameters/CampaignIds"
                    },
                    {
                        "$ref": "#/components/parameters/PlayerCountries"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The report, or one page of it.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/CohortAnswer"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/RateMissing"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidReport"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/ReportsUnavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads your monthly sign-up cohorts' deposits this year. The token comes from your secret store.\n$query = http_build_query(['from' => '2026-01-01T00:00:00Z', 'to' => '2026-10-01T00:00:00Z', 'figure' => 'deposits_amount', 'cohort_grain' => 'month']);\n$curl = curl_init('https://api.affiliqo.com/stats/reports/cohorts'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo count($answer['cohorts']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads your monthly sign-up cohorts' deposits this year. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({ from: '2026-01-01T00:00:00Z', to: '2026-10-01T00:00:00Z', figure: 'deposits_amount', cohort_grain: 'month' }).toString();\nconst url = 'https://api.affiliqo.com/stats/reports/cohorts' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status === 200) {\n  console.log(answer.cohorts.length);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads your monthly sign-up cohorts' deposits this year. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({\"from\": \"2026-01-01T00:00:00Z\", \"to\": \"2026-10-01T00:00:00Z\", \"figure\": \"deposits_amount\", \"cohort_grain\": \"month\"})\nurl = \"https://api.affiliqo.com/stats/reports/cohorts\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(url, headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]})\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(len(answer[\"cohorts\"]))\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Reads your monthly sign-up cohorts' deposits this year. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\tquery.Set(\"from\", \"2026-01-01T00:00:00Z\")\n\tquery.Set(\"to\", \"2026-10-01T00:00:00Z\")\n\tquery.Set(\"figure\", \"deposits_amount\")\n\tquery.Set(\"cohort_grain\", \"month\")\n\ttarget := \"https://api.affiliqo.com/stats/reports/cohorts\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(http.MethodGet, target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\titems, _ := answer[\"cohorts\"].([]any)\n\t\tfmt.Println(len(items))\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/reports/sub-affiliates": {
            "get": {
                "operationId": "getSubAffiliateReport",
                "summary": "Read your sub-affiliate report",
                "description": "What your direct sub-affiliates' players brought, by sub-affiliate, brand and date, while the program runs a sub-affiliate program.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/From"
                    },
                    {
                        "$ref": "#/components/parameters/To"
                    },
                    {
                        "$ref": "#/components/parameters/Timezone"
                    },
                    {
                        "$ref": "#/components/parameters/GroupBy"
                    },
                    {
                        "$ref": "#/components/parameters/DateGrain"
                    },
                    {
                        "$ref": "#/components/parameters/Tag"
                    },
                    {
                        "$ref": "#/components/parameters/Columns"
                    },
                    {
                        "$ref": "#/components/parameters/Currency"
                    },
                    {
                        "$ref": "#/components/parameters/RatesOn"
                    },
                    {
                        "$ref": "#/components/parameters/Sort"
                    },
                    {
                        "$ref": "#/components/parameters/Direction"
                    },
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/Cursor"
                    },
                    {
                        "$ref": "#/components/parameters/BrandIds"
                    },
                    {
                        "$ref": "#/components/parameters/SubAffiliateIds"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The report, or one page of it.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ReportAnswer"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidReportCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/RateMissing"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidReport"
                    },
                    "429": {
                        "$ref": "#/components/responses/TooManyRequests"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    },
                    "503": {
                        "$ref": "#/components/responses/ReportsUnavailable"
                    }
                },
                "x-codeSamples": [
                    {
                        "lang": "PHP",
                        "label": "PHP",
                        "source": "<?php\n\ndeclare(strict_types=1);\n\n// Reads your sub-affiliate report for September, by sub-affiliate. The token comes from your secret store.\n$query = http_build_query(['from' => '2026-09-01T00:00:00Z', 'to' => '2026-10-01T00:00:00Z', 'group_by' => 'child', 'columns' => 'registrations']);\n$curl = curl_init('https://api.affiliqo.com/stats/reports/sub-affiliates'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo count($answer['rows']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads your sub-affiliate report for September, by sub-affiliate. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({ from: '2026-09-01T00:00:00Z', to: '2026-10-01T00:00:00Z', group_by: 'child', columns: 'registrations' }).toString();\nconst url = 'https://api.affiliqo.com/stats/reports/sub-affiliates' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status === 200) {\n  console.log(answer.rows.length);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads your sub-affiliate report for September, by sub-affiliate. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({\"from\": \"2026-09-01T00:00:00Z\", \"to\": \"2026-10-01T00:00:00Z\", \"group_by\": \"child\", \"columns\": \"registrations\"})\nurl = \"https://api.affiliqo.com/stats/reports/sub-affiliates\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(url, headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]})\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(len(answer[\"rows\"]))\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Reads your sub-affiliate report for September, by sub-affiliate. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\tquery.Set(\"from\", \"2026-09-01T00:00:00Z\")\n\tquery.Set(\"to\", \"2026-10-01T00:00:00Z\")\n\tquery.Set(\"group_by\", \"child\")\n\tquery.Set(\"columns\", \"registrations\")\n\ttarget := \"https://api.affiliqo.com/stats/reports/sub-affiliates\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(http.MethodGet, target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\titems, _ := answer[\"rows\"].([]any)\n\t\tfmt.Println(len(items))\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/reports/attributes": {
            "get": {
                "operationId": "getReportAttributes",
                "summary": "List what you may ask of each report",
                "description": "The reports you get, each with exactly the columns, groupings and filter parameters you may use, how many groupings at once and the longest span. The program chooses them; a request for anything else is refused.",
                "responses": {
                    "200": {
                        "description": "Your reports.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ReportAttributes"
                                }
                            }
                        }
                    },
                    "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// Lists what you may ask of each report you get. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/reports/attributes'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) === 200) {\n    echo count($answer['reports']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists what you may ask of each report you get. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/reports/attributes' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status === 200) {\n  console.log(answer.reports.length);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists what you may ask of each report you get. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/reports/attributes\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(url, headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]})\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(len(answer[\"reports\"]))\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists what you may ask of each report you get. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/reports/attributes\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(http.MethodGet, target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode == http.StatusOK {\n\t\titems, _ := answer[\"reports\"].([]any)\n\t\tfmt.Println(len(items))\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/bills": {
            "get": {
                "operationId": "listBills",
                "summary": "List your bills",
                "description": "Your bills, 100 a page unless you ask for up to 1,000, in the order they were made. Follow `next_cursor` until it is null.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/PageCursor"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BillPage"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidListCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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// Lists your bills, the oldest first. The token comes from your secret store.\n$query = http_build_query(['limit' => '100']);\n$curl = curl_init('https://api.affiliqo.com/stats/bills'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['bills']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists your bills, the oldest first. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({ limit: '100' }).toString();\nconst url = 'https://api.affiliqo.com/stats/bills' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.bills);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists your bills, the oldest first. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({\"limit\": \"100\"})\nurl = \"https://api.affiliqo.com/stats/bills\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"bills\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists your bills, the oldest first. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\tquery.Set(\"limit\", \"100\")\n\ttarget := \"https://api.affiliqo.com/stats/bills\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"bills\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/bills/{id}": {
            "get": {
                "operationId": "getBill",
                "summary": "Read one of your bills",
                "description": "One of your bills as it was issued, with everything its statement holds. Another partner's bill is not found.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "The bill's id.",
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The bill's statement.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BillStatement"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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 one of your bills with its statement. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/bills/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['total_amount']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Reads one of your bills with its statement. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/bills/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.total_amount);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Reads one of your bills with its statement. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/bills/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"total_amount\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Reads one of your bills with its statement. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/bills/0192f6b1-9e2a-7c3d-8e4f-0a1b2c3d4e5f\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"total_amount\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/deals": {
            "get": {
                "operationId": "listDeals",
                "summary": "List your deals",
                "description": "Your deal assignments, past, current and scheduled, each with its deal's terms.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/PageCursor"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/DealPage"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidListCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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// Lists your deals. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/deals'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['deals']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists your deals. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/deals' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.deals);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists your deals. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/deals\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"deals\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists your deals. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/deals\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"deals\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/brands": {
            "get": {
                "operationId": "listBrands",
                "summary": "List the brands you can make links for",
                "description": "The brands you can make links for, with their products and currencies.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/PageCursor"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BrandPage"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidListCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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// Lists the brands you can make links for. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/brands'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['brands']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists the brands you can make links for. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/brands' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.brands);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists the brands you can make links for. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/brands\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"brands\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists the brands you can make links for. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/brands\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"brands\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/landings": {
            "get": {
                "operationId": "listLandings",
                "summary": "List the landing pages you may use",
                "description": "The landing pages you may send players to, on the brands you can make links for.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/PageCursor"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/LandingPage"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidListCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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// Lists the landing pages you may use. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/landings'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['landings']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists the landing pages you may use. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/landings' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.landings);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists the landing pages you may use. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/landings\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"landings\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists the landing pages you may use. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/landings\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"landings\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/campaigns": {
            "get": {
                "operationId": "listCampaigns",
                "summary": "List your campaigns",
                "description": "Your campaigns that aren't archived, or the archived ones or all of them when you ask, each with its promos that aren't archived.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/PageCursor"
                    },
                    {
                        "$ref": "#/components/parameters/State"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/CampaignPage"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidListCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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// Lists your campaigns. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/campaigns'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['campaigns']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists your campaigns. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/campaigns' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.campaigns);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists your campaigns. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/campaigns\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"campaigns\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists your campaigns. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/campaigns\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"campaigns\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            },
            "post": {
                "operationId": "createCampaign",
                "summary": "Start a campaign",
                "description": "Starts a campaign on one of the brands you can make links for, as the link builder does, when the program has let you create campaigns and promos through the API. On a brand with deals on offer to you, it takes your pick of them.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/NewCampaign"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Made; 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/Campaign"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/WriteBadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/WriteForbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/WriteConflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/WriteTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidWrite"
                    },
                    "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// Starts a campaign. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\n$idempotencyKey = $argv[1] ?? throw new InvalidArgumentException('Pass the write\\'s Idempotency-Key.');\n$body = json_encode(['brand_id' => '0192f6a8-1111-7aaa-8bbb-000000000001', 'name' => 'Spring reviews'], JSON_THROW_ON_ERROR);\n$curl = curl_init('https://api.affiliqo.com/stats/campaigns');\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Idempotency-Key: '.$idempotencyKey, 'Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_CUSTOMREQUEST => 'POST',\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_USERAGENT => 'your-tracker/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) < 300) {\n    echo json_encode($answer['id']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Starts a campaign. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\nconst idempotencyKey = process.argv[2];\nif (!idempotencyKey) {\n  throw new Error(\"Pass the write's Idempotency-Key.\");\n}\n\nconst response = await fetch('https://api.affiliqo.com/stats/campaigns', {\n  method: 'POST',\n  body: JSON.stringify({ brand_id: '0192f6a8-1111-7aaa-8bbb-000000000001', name: 'Spring reviews' }),\n  headers: { 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey, Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst answer = await response.json();\n\nif (response.status < 300) {\n  console.log(answer.id);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Starts a campaign. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\nimport json\nimport os\nimport sys\nimport urllib.error\nimport urllib.request\n\nidempotency_key = sys.argv[1]\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com/stats/campaigns\",\n    data=json.dumps({\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\", \"name\": \"Spring reviews\"}).encode(),\n    method=\"POST\",\n    headers={\"Content-Type\": \"application/json\", \"Idempotency-Key\": idempotency_key, \"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"id\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Starts a campaign. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"time\"\n)\n\nfunc main() {\n\tif len(os.Args) < 2 {\n\t\tpanic(\"pass the write's Idempotency-Key\")\n\t}\n\n\trequest, err := http.NewRequest(\"POST\", \"https://api.affiliqo.com/stats/campaigns\", strings.NewReader(`{\"brand_id\": \"0192f6a8-1111-7aaa-8bbb-000000000001\", \"name\": \"Spring reviews\"}`))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\trequest.Header.Set(\"Idempotency-Key\", os.Args[1])\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.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 < 300 {\n\t\tfmt.Println(answer[\"id\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        },
        "/stats/promos": {
            "get": {
                "operationId": "listPromos",
                "summary": "List your promos and their links",
                "description": "Your promos that aren't archived, in campaigns that aren't archived, or the archived ones or all of them when you ask, each with its links on the brand's tracking domains.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/Limit"
                    },
                    {
                        "$ref": "#/components/parameters/PageCursor"
                    },
                    {
                        "$ref": "#/components/parameters/State"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "A page.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/PromoPage"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/InvalidListCursor"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidListQuery"
                    },
                    "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// Lists your promos and their links. The token comes from your secret store.\n$query = http_build_query([]);\n$curl = curl_init('https://api.affiliqo.com/stats/promos'.($query === '' ? '' : '?'.$query));\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_USERAGENT => 'your-tracker/1.0',\n    CURLOPT_RETURNTRANSFER => true,\n    CURLOPT_TIMEOUT => 30,\n]);\n// Amounts can pass PHP's integers in a currency with many decimals, so they are read as strings.\n$answer = json_decode((string) curl_exec($curl), true, flags: JSON_BIGINT_AS_STRING);\n\nif (curl_getinfo($curl, CURLINFO_RESPONSE_CODE) < 300) {\n    echo json_encode($answer['promos']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Lists your promos and their links. The token comes from your secret store. Amounts can pass\n// JavaScript's safe integers, so integers are parsed as BigInt.\nconst query = new URLSearchParams({  }).toString();\nconst url = 'https://api.affiliqo.com/stats/promos' + (query === '' ? '' : '?' + query);\nconst response = await fetch(url, {\n  headers: { Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst text = await response.text();\nconst answer = JSON.parse(text, (key, value, context) =>\n  Number.isInteger(value) && !Number.isSafeInteger(value) ? BigInt(context.source) : value,\n);\n\nif (response.status < 300) {\n  console.log(answer.promos);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Lists your promos and their links. The token comes from your secret store.\nimport json\nimport os\nimport urllib.error\nimport urllib.parse\nimport urllib.request\n\nquery = urllib.parse.urlencode({})\nurl = \"https://api.affiliqo.com/stats/promos\" + (\"?\" + query if query else \"\")\nrequest = urllib.request.Request(\n    url,\n    data=None,\n    method=\"GET\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"promos\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Lists your promos and their links. The token comes from your secret store.\npackage 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\nfunc main() {\n\tquery := url.Values{}\n\ttarget := \"https://api.affiliqo.com/stats/promos\"\n\tif encoded := query.Encode(); encoded != \"\" {\n\t\ttarget += \"?\" + encoded\n\t}\n\n\trequest, err := http.NewRequest(\"GET\", target, nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer response.Body.Close()\n\n\t// Amounts can pass the integers JSON numbers decode to, so they are kept as json.Number.\n\tdecoder := json.NewDecoder(response.Body)\n\tdecoder.UseNumber()\n\tvar answer map[string]any\n\tif err := decoder.Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif response.StatusCode < 300 {\n\t\tfmt.Println(answer[\"promos\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            },
            "post": {
                "operationId": "createPromo",
                "summary": "Make a promo",
                "description": "Makes a promo in one of your campaigns, to a landing page you may use, as the link builder does, when the program has let you create campaigns and promos through the API. The answer gives its links.",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/NewPromo"
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Made; 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/Promo"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/WriteBadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "402": {
                        "$ref": "#/components/responses/CapabilityOff"
                    },
                    "403": {
                        "$ref": "#/components/responses/WriteForbidden"
                    },
                    "409": {
                        "$ref": "#/components/responses/WriteConflict"
                    },
                    "413": {
                        "$ref": "#/components/responses/WriteTooLarge"
                    },
                    "422": {
                        "$ref": "#/components/responses/InvalidWrite"
                    },
                    "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// Makes a promo and prints its links. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\n$idempotencyKey = $argv[1] ?? throw new InvalidArgumentException('Pass the write\\'s Idempotency-Key.');\n$body = json_encode(['campaign_id' => '0192f6a8-2222-7aaa-8bbb-000000000002', 'landing_id' => '0192f6a8-3333-7aaa-8bbb-000000000003'], JSON_THROW_ON_ERROR);\n$curl = curl_init('https://api.affiliqo.com/stats/promos');\ncurl_setopt_array($curl, [\n    CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Idempotency-Key: '.$idempotencyKey, 'Authorization: Bearer '.getenv('AFFILIQO_STATISTIC_TOKEN')],\n    CURLOPT_CUSTOMREQUEST => 'POST',\n    CURLOPT_POSTFIELDS => $body,\n    CURLOPT_USERAGENT => 'your-tracker/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) < 300) {\n    echo json_encode($answer['links']), PHP_EOL;\n} else {\n    // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    fwrite(STDERR, ($answer['code'] ?? 'no answer').' '.($answer['trace_id'] ?? '').PHP_EOL);\n}\n"
                    },
                    {
                        "lang": "JavaScript",
                        "label": "Node.js",
                        "source": "// Makes a promo and prints its links. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\nconst idempotencyKey = process.argv[2];\nif (!idempotencyKey) {\n  throw new Error(\"Pass the write's Idempotency-Key.\");\n}\n\nconst response = await fetch('https://api.affiliqo.com/stats/promos', {\n  method: 'POST',\n  body: JSON.stringify({ campaign_id: '0192f6a8-2222-7aaa-8bbb-000000000002', landing_id: '0192f6a8-3333-7aaa-8bbb-000000000003' }),\n  headers: { 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey, Authorization: 'Bearer ' + process.env.AFFILIQO_STATISTIC_TOKEN },\n});\nconst answer = await response.json();\n\nif (response.status < 300) {\n  console.log(answer.links);\n} else {\n  // A problem document: act on its code, and quote its trace_id when you ask the program about it.\n  console.error(answer.code, answer.trace_id);\n}\n"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "# Makes a promo and prints its links. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\nimport json\nimport os\nimport sys\nimport urllib.error\nimport urllib.request\n\nidempotency_key = sys.argv[1]\nrequest = urllib.request.Request(\n    \"https://api.affiliqo.com/stats/promos\",\n    data=json.dumps({\"campaign_id\": \"0192f6a8-2222-7aaa-8bbb-000000000002\", \"landing_id\": \"0192f6a8-3333-7aaa-8bbb-000000000003\"}).encode(),\n    method=\"POST\",\n    headers={\"Content-Type\": \"application/json\", \"Idempotency-Key\": idempotency_key, \"Authorization\": \"Bearer \" + os.environ[\"AFFILIQO_STATISTIC_TOKEN\"]},\n)\n\ntry:\n    with urllib.request.urlopen(request, timeout=30) as response:\n        answer = json.load(response)\n        print(answer[\"links\"])\nexcept urllib.error.HTTPError as error:\n    # A problem document: act on its code, and quote its trace_id when you ask the program about it.\n    problem = json.load(error)\n    print(problem.get(\"code\"), problem.get(\"trace_id\"))\n"
                    },
                    {
                        "lang": "Go",
                        "label": "Go",
                        "source": "// Makes a promo and prints its links. Pass a key of your own for this write, such as one made from your own record's id, and send any retry after a timeout with the same key: it gets the first answer again instead of a second link. The token comes from your secret store.\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"strings\"\n\t\"time\"\n)\n\nfunc main() {\n\tif len(os.Args) < 2 {\n\t\tpanic(\"pass the write's Idempotency-Key\")\n\t}\n\n\trequest, err := http.NewRequest(\"POST\", \"https://api.affiliqo.com/stats/promos\", strings.NewReader(`{\"campaign_id\": \"0192f6a8-2222-7aaa-8bbb-000000000002\", \"landing_id\": \"0192f6a8-3333-7aaa-8bbb-000000000003\"}`))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\trequest.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"AFFILIQO_STATISTIC_TOKEN\"))\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\trequest.Header.Set(\"Idempotency-Key\", os.Args[1])\n\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresponse, err := client.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 < 300 {\n\t\tfmt.Println(answer[\"links\"])\n\t} else {\n\t\t// A problem document: act on its code, and quote its trace_id when you ask the program about it.\n\t\tfmt.Fprintln(os.Stderr, answer[\"code\"], answer[\"trace_id\"])\n\t}\n}\n"
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "Token": {
                "type": "http",
                "scheme": "bearer",
                "description": "Every request carries one of your statistic tokens: `Authorization: Bearer afq_stat_live_…`."
            }
        },
        "parameters": {
            "From": {
                "name": "from",
                "in": "query",
                "required": false,
                "description": "The span's start, as ISO 8601 with its UTC offset, such as `2026-08-31T22:00:00Z`. Required, except with `bill_id`, whose period the report then counts.",
                "schema": {
                    "type": "string",
                    "format": "date-time"
                }
            },
            "To": {
                "name": "to",
                "in": "query",
                "required": false,
                "description": "The span's end, not included, after `from`, as ISO 8601 with its UTC offset. Required, except with `bill_id`.",
                "schema": {
                    "type": "string",
                    "format": "date-time"
                }
            },
            "Timezone": {
                "name": "timezone",
                "in": "query",
                "required": false,
                "description": "The IANA timezone the report counts its days, weeks and months in, such as `Europe/Malta`. Your user's timezone unless given.",
                "schema": {
                    "type": "string"
                }
            },
            "GroupBy": {
                "name": "group_by",
                "in": "query",
                "required": false,
                "description": "Up to three groupings, comma separated, such as `campaign,date`. `/stats/reports/attributes` lists those you may use.",
                "schema": {
                    "type": "string"
                }
            },
            "DateGrain": {
                "name": "date_grain",
                "in": "query",
                "required": false,
                "description": "How a date grouping buckets its days.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "day",
                        "week",
                        "month",
                        "year"
                    ]
                }
            },
            "Tag": {
                "name": "tag",
                "in": "query",
                "required": false,
                "description": "The name of the dynamic tag the `dynamic_tag` grouping and `tag_values` filter read, such as `subid`.",
                "schema": {
                    "type": "string"
                }
            },
            "Columns": {
                "name": "columns",
                "in": "query",
                "required": false,
                "description": "The columns, comma separated. Every column you get unless given.",
                "schema": {
                    "type": "string"
                }
            },
            "Currency": {
                "name": "currency",
                "in": "query",
                "required": false,
                "description": "The currency of every amount: the program's unless given. A currency Affiliqo keeps no rates for is refused.",
                "schema": {
                    "type": "string"
                }
            },
            "RatesOn": {
                "name": "rates_on",
                "in": "query",
                "required": false,
                "description": "The date of the exchange rates other currencies convert at: the span's last day, or today, unless given.",
                "schema": {
                    "type": "string",
                    "format": "date"
                }
            },
            "Bots": {
                "name": "bots",
                "in": "query",
                "required": false,
                "description": "Whether bot visits count: left out unless given.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "include",
                        "exclude",
                        "only"
                    ]
                }
            },
            "Sort": {
                "name": "sort",
                "in": "query",
                "required": false,
                "description": "A column to sort by; the groupings otherwise.",
                "schema": {
                    "type": "string"
                }
            },
            "Direction": {
                "name": "direction",
                "in": "query",
                "required": false,
                "description": "The sort's direction, descending unless given.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "asc",
                        "desc"
                    ]
                }
            },
            "Limit": {
                "name": "limit",
                "in": "query",
                "required": false,
                "description": "Rows a page, 100 unless given, at most 1,000.",
                "schema": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                }
            },
            "Cursor": {
                "name": "cursor",
                "in": "query",
                "required": false,
                "description": "The `next_cursor` of the page before, with the same parameters. Leave it out for the first page.",
                "schema": {
                    "type": "string"
                }
            },
            "BrandIds": {
                "name": "brand_ids",
                "in": "query",
                "required": false,
                "description": "Only these brands, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "DealIds": {
                "name": "deal_ids",
                "in": "query",
                "required": false,
                "description": "Only these deals, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "Strategies": {
                "name": "strategies",
                "in": "query",
                "required": false,
                "description": "Only deals of these strategies, comma separated.",
                "schema": {
                    "type": "string"
                }
            },
            "CampaignIds": {
                "name": "campaign_ids",
                "in": "query",
                "required": false,
                "description": "Only these campaigns, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "PromoIds": {
                "name": "promo_ids",
                "in": "query",
                "required": false,
                "description": "Only these promos, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "PlayerIds": {
                "name": "player_ids",
                "in": "query",
                "required": false,
                "description": "Only these players, by their player keys, comma separated.",
                "schema": {
                    "type": "string"
                }
            },
            "PlayerCountries": {
                "name": "player_countries",
                "in": "query",
                "required": false,
                "description": "Only players of these countries, comma separated ISO 3166-1 alpha-2 codes.",
                "schema": {
                    "type": "string"
                }
            },
            "TagValues": {
                "name": "tag_values",
                "in": "query",
                "required": false,
                "description": "Only these values of the dynamic tag `tag` names, comma separated.",
                "schema": {
                    "type": "string"
                }
            },
            "BillId": {
                "name": "bill_id",
                "in": "query",
                "required": false,
                "description": "The report of one of your bills: its period, currency, rates and players, as it counted them.",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "Stag": {
                "name": "stag",
                "in": "query",
                "required": false,
                "description": "Only the visit, promo or bonus code of this stag, such as `1042_5531877`.",
                "schema": {
                    "type": "string"
                }
            },
            "LandingIds": {
                "name": "landing_ids",
                "in": "query",
                "required": false,
                "description": "Only these landing pages, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "Devices": {
                "name": "devices",
                "in": "query",
                "required": false,
                "description": "Only these devices, comma separated: `desktop`, `mobile`, `tablet`, `other`.",
                "schema": {
                    "type": "string"
                }
            },
            "BrowserFamilies": {
                "name": "browser_families",
                "in": "query",
                "required": false,
                "description": "Only these browsers, comma separated.",
                "schema": {
                    "type": "string"
                }
            },
            "OsFamilies": {
                "name": "os_families",
                "in": "query",
                "required": false,
                "description": "Only these operating systems, comma separated.",
                "schema": {
                    "type": "string"
                }
            },
            "VisitCountries": {
                "name": "visit_countries",
                "in": "query",
                "required": false,
                "description": "Only visits from these countries, comma separated ISO 3166-1 alpha-2 codes.",
                "schema": {
                    "type": "string"
                }
            },
            "Referrers": {
                "name": "referrers",
                "in": "query",
                "required": false,
                "description": "Only visits from these referring sites, comma separated.",
                "schema": {
                    "type": "string"
                }
            },
            "TrafficSourceIds": {
                "name": "traffic_source_ids",
                "in": "query",
                "required": false,
                "description": "Only these traffic sources, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "CohortType": {
                "name": "cohort_type",
                "in": "query",
                "required": false,
                "description": "What puts players in a cohort: their sign-up unless given.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "sign_up",
                        "first_deposit",
                        "deposit"
                    ]
                }
            },
            "CohortGrain": {
                "name": "cohort_grain",
                "in": "query",
                "required": false,
                "description": "A cohort's length: a month unless given.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "day",
                        "week",
                        "month"
                    ]
                }
            },
            "Figure": {
                "name": "figure",
                "in": "query",
                "required": true,
                "description": "The one figure the cells show, such as `deposits_amount`.",
                "schema": {
                    "type": "string"
                }
            },
            "Periods": {
                "name": "periods",
                "in": "query",
                "required": false,
                "description": "How many periods each cohort is followed for, 12 unless given.",
                "schema": {
                    "type": "integer",
                    "minimum": 1
                }
            },
            "SubAffiliateIds": {
                "name": "sub_affiliate_ids",
                "in": "query",
                "required": false,
                "description": "Only these sub-affiliates, comma separated ids.",
                "schema": {
                    "type": "string"
                }
            },
            "PageCursor": {
                "name": "cursor",
                "in": "query",
                "required": false,
                "description": "The `next_cursor` of the page before, as Affiliqo gave it. Leave it out for the first page.",
                "schema": {
                    "type": "string"
                }
            },
            "State": {
                "name": "state",
                "in": "query",
                "required": false,
                "description": "Which to list: `active`, those in the link builder, unless given; `archived`, those archived, whose links and codes keep working; or `all`. A promo of an archived campaign is archived with it.",
                "schema": {
                    "type": "string",
                    "enum": [
                        "active",
                        "archived",
                        "all"
                    ],
                    "default": "active"
                }
            },
            "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 writes. Send a retry of the same JSON under the same key: it gets the first answer again, within 30 days.",
                "schema": {
                    "type": "string",
                    "pattern": "^[!-~]{1,255}$"
                }
            }
        },
        "schemas": {
            "ReportGroupValue": {
                "type": "object",
                "description": "A grouping's value, such as a brand or a campaign.",
                "required": [
                    "id",
                    "name"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "nullable": true,
                        "description": "Its id, or null for \"none\", such as a partner without a tag or a player no visit brought."
                    },
                    "name": {
                        "type": "string",
                        "description": "Its name as the portal shows it."
                    }
                }
            },
            "ReportPlayer": {
                "type": "object",
                "description": "A player as a partner sees it: never the casino's id. The key tells two players with the same masked id apart and stays the same from month to month, until the program's keys are rotated.",
                "required": [
                    "masked_id",
                    "key",
                    "country",
                    "signed_up_on"
                ],
                "properties": {
                    "masked_id": {
                        "type": "string",
                        "description": "The casino's id of the player, masked, such as \"77***\"; empty for a player no longer in the program."
                    },
                    "key": {
                        "type": "string",
                        "nullable": true,
                        "description": "The player key, such as \"k1:3f9a01c2b7d4e816\"."
                    },
                    "country": {
                        "type": "string",
                        "nullable": true,
                        "description": "The player's country, as ISO 3166-1 alpha-2."
                    },
                    "signed_up_on": {
                        "type": "string",
                        "format": "date",
                        "nullable": true,
                        "description": "The day the player signed up, in UTC; null for a player no longer in the program."
                    }
                }
            },
            "DataTokenPlayer": {
                "description": "A player as a data token sees it in the operator data API: masked, or by the casino's id instead once the token has the players scope; never with a player key or the personal details of its profile.",
                "oneOf": [
                    {
                        "type": "object",
                        "description": "Without the players scope.",
                        "required": [
                            "masked_id",
                            "country",
                            "signed_up_on"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "masked_id": {
                                "type": "string",
                                "description": "The casino's id of the player, masked, such as \"77***\"; empty for a player no longer in the program."
                            },
                            "country": {
                                "type": "string",
                                "nullable": true,
                                "description": "The player's country, as ISO 3166-1 alpha-2."
                            },
                            "signed_up_on": {
                                "type": "string",
                                "format": "date",
                                "nullable": true,
                                "description": "The day the player signed up, in UTC; null for a player no longer in the program."
                            }
                        }
                    },
                    {
                        "type": "object",
                        "description": "With the players scope.",
                        "required": [
                            "casino_player_id",
                            "country",
                            "signed_up_on"
                        ],
                        "additionalProperties": false,
                        "properties": {
                            "casino_player_id": {
                                "type": "string",
                                "nullable": true,
                                "description": "The casino's id of the player; null for a player no longer in the program."
                            },
                            "country": {
                                "type": "string",
                                "nullable": true,
                                "description": "The player's country, as ISO 3166-1 alpha-2."
                            },
                            "signed_up_on": {
                                "type": "string",
                                "format": "date",
                                "nullable": true,
                                "description": "The day the player signed up, in UTC; null for a player no longer in the program."
                            }
                        }
                    }
                ]
            },
            "ReportFigures": {
                "type": "object",
                "description": "Each figure, by its column. Money is an integer in minor units, a count an integer, a rate a percentage as a decimal string; visits are null under a grouping by player, which visits have none of.",
                "additionalProperties": {
                    "anyOf": [
                        {
                            "type": "integer",
                            "nullable": true
                        },
                        {
                            "type": "string"
                        }
                    ]
                }
            },
            "ReportRow": {
                "type": "object",
                "description": "One row of a report.",
                "required": [
                    "group",
                    "figures",
                    "includes_estimate"
                ],
                "properties": {
                    "group": {
                        "type": "object",
                        "description": "Each grouping's value, by its name. A date grouping's value is its first day, or null for players without that date; a player is its masked id, country and sign-up date, with its player key for a partner, or the casino's id instead of the mask for a data token with the players scope; anything else is its id and name.",
                        "additionalProperties": {
                            "anyOf": [
                                {
                                    "type": "string",
                                    "format": "date",
                                    "nullable": true
                                },
                                {
                                    "$ref": "#/components/schemas/ReportGroupValue"
                                },
                                {
                                    "$ref": "#/components/schemas/ReportPlayer"
                                },
                                {
                                    "$ref": "#/components/schemas/DataTokenPlayer"
                                }
                            ]
                        }
                    },
                    "figures": {
                        "$ref": "#/components/schemas/ReportFigures"
                    },
                    "includes_estimate": {
                        "type": "boolean",
                        "description": "Whether the current period's estimate went into the row's bill figures."
                    }
                }
            },
            "ReportAnswer": {
                "type": "object",
                "description": "One page of a report. Money is in minor units of `currency`; a currency with many decimals gives integers past JavaScript's safe integers, so parse them as big integers. Rates are percentages as decimal strings, such as \"12.50\".",
                "required": [
                    "report",
                    "from",
                    "to",
                    "timezone",
                    "currency",
                    "rates_on",
                    "group_by",
                    "date_grain",
                    "rows",
                    "totals",
                    "next_cursor"
                ],
                "properties": {
                    "report": {
                        "type": "string",
                        "description": "The report, as its path names it.",
                        "enum": [
                            "statistics",
                            "traffic",
                            "sub-affiliates"
                        ]
                    },
                    "from": {
                        "type": "string",
                        "format": "date-time",
                        "description": "The span's start, in UTC."
                    },
                    "to": {
                        "type": "string",
                        "format": "date-time",
                        "description": "The span's end, not included, in UTC."
                    },
                    "timezone": {
                        "type": "string",
                        "description": "The timezone the report's days, weeks and months are counted in."
                    },
                    "currency": {
                        "type": "string",
                        "description": "The one currency of every amount."
                    },
                    "rates_on": {
                        "type": "string",
                        "format": "date",
                        "description": "The date of the exchange rates other currencies were converted at."
                    },
                    "group_by": {
                        "type": "array",
                        "description": "The groupings, in their order.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "date_grain": {
                        "type": "string",
                        "description": "How a date grouping buckets its days.",
                        "enum": [
                            "day",
                            "week",
                            "month",
                            "year"
                        ]
                    },
                    "rows": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ReportRow"
                        }
                    },
                    "totals": {
                        "$ref": "#/components/schemas/ReportFigures"
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true,
                        "description": "Send it as `cursor` with the same parameters for the next page; null on the last page."
                    }
                }
            },
            "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."
                    }
                }
            },
            "CohortRow": {
                "type": "object",
                "required": [
                    "cohort",
                    "players",
                    "cells",
                    "total"
                ],
                "properties": {
                    "cohort": {
                        "type": "string",
                        "format": "date",
                        "description": "The cohort's first day."
                    },
                    "players": {
                        "type": "integer",
                        "description": "The players in the cohort."
                    },
                    "cells": {
                        "type": "array",
                        "description": "The figure in each period from the cohort's own, or null for a period still to come.",
                        "items": {
                            "type": "integer",
                            "nullable": true
                        }
                    },
                    "total": {
                        "type": "integer"
                    }
                }
            },
            "CohortAnswer": {
                "type": "object",
                "description": "A cohort report: a row per cohort, each with its players and one cell per period from its own. Money is in minor units of `currency`.",
                "required": [
                    "report",
                    "from",
                    "to",
                    "timezone",
                    "currency",
                    "rates_on",
                    "cohort_type",
                    "cohort_grain",
                    "figure",
                    "periods",
                    "cohorts",
                    "period_totals",
                    "total"
                ],
                "properties": {
                    "report": {
                        "type": "string",
                        "enum": [
                            "cohorts"
                        ]
                    },
                    "from": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "to": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "timezone": {
                        "type": "string"
                    },
                    "currency": {
                        "type": "string"
                    },
                    "rates_on": {
                        "type": "string",
                        "format": "date"
                    },
                    "cohort_type": {
                        "type": "string",
                        "description": "What puts players in a cohort.",
                        "enum": [
                            "sign_up",
                            "first_deposit",
                            "deposit"
                        ]
                    },
                    "cohort_grain": {
                        "type": "string",
                        "enum": [
                            "day",
                            "week",
                            "month"
                        ]
                    },
                    "figure": {
                        "type": "string",
                        "description": "The one figure the cells show."
                    },
                    "periods": {
                        "type": "integer",
                        "description": "How many periods each cohort is followed for, its own included."
                    },
                    "cohorts": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/CohortRow"
                        }
                    },
                    "period_totals": {
                        "type": "array",
                        "description": "Each period's total, or null for a period still to come; empty for deposit cohorts, whose players sit in several cohorts.",
                        "items": {
                            "type": "integer",
                            "nullable": true
                        }
                    },
                    "total": {
                        "type": "integer",
                        "nullable": true,
                        "description": "The report's total."
                    }
                }
            },
            "ReportAttributes": {
                "type": "object",
                "required": [
                    "reports"
                ],
                "properties": {
                    "reports": {
                        "type": "array",
                        "description": "Each report you get.",
                        "items": {
                            "type": "object",
                            "required": [
                                "report",
                                "columns",
                                "group_by",
                                "filters",
                                "max_group_by",
                                "max_span_days",
                                "max_periods"
                            ],
                            "properties": {
                                "report": {
                                    "type": "string",
                                    "description": "The report, as its path names it.",
                                    "enum": [
                                        "statistics",
                                        "traffic",
                                        "cohorts",
                                        "sub-affiliates"
                                    ]
                                },
                                "columns": {
                                    "type": "array",
                                    "description": "The columns you may ask for and sort by; for the cohort report, the figures.",
                                    "items": {
                                        "type": "string"
                                    }
                                },
                                "group_by": {
                                    "type": "array",
                                    "description": "The groupings you may use.",
                                    "items": {
                                        "type": "string"
                                    }
                                },
                                "filters": {
                                    "type": "array",
                                    "description": "The filter parameters you may use.",
                                    "items": {
                                        "type": "string"
                                    }
                                },
                                "max_group_by": {
                                    "type": "integer",
                                    "description": "How many groupings at once."
                                },
                                "max_span_days": {
                                    "type": "integer",
                                    "description": "The longest span, in days."
                                },
                                "max_periods": {
                                    "type": "integer",
                                    "nullable": true,
                                    "description": "For the cohort report, the most periods; null for the others."
                                }
                            }
                        }
                    }
                }
            },
            "Reference": {
                "type": "object",
                "description": "Another record this one refers to.",
                "required": [
                    "id",
                    "name"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    }
                }
            },
            "Bill": {
                "type": "object",
                "description": "A bill. Amounts are in minor units of `currency`.",
                "required": [
                    "id",
                    "partner_id",
                    "brand",
                    "deal",
                    "period_start_date",
                    "period_end_date",
                    "currency",
                    "total_amount",
                    "status",
                    "is_carried",
                    "issued_at",
                    "expected_payment_on",
                    "payment"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "partner_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "The partner the bill pays."
                    },
                    "brand": {
                        "$ref": "#/components/schemas/Reference"
                    },
                    "deal": {
                        "$ref": "#/components/schemas/Reference"
                    },
                    "period_start_date": {
                        "type": "string",
                        "format": "date",
                        "description": "The period's first day, in the program's timezone."
                    },
                    "period_end_date": {
                        "type": "string",
                        "format": "date",
                        "description": "The period's last day."
                    },
                    "currency": {
                        "type": "string"
                    },
                    "total_amount": {
                        "type": "integer",
                        "description": "What the bill pays."
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "issued",
                            "on_hold",
                            "paid",
                            "canceled"
                        ]
                    },
                    "is_carried": {
                        "type": "boolean",
                        "description": "Whether the total moves to the partner's next bill instead of being paid on its own."
                    },
                    "issued_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "expected_payment_on": {
                        "type": "string",
                        "format": "date",
                        "nullable": true,
                        "description": "The day the program expects to pay it."
                    },
                    "payment": {
                        "type": "object",
                        "nullable": true,
                        "description": "What was paid, once the program has paid the bill.",
                        "required": [
                            "paid_on",
                            "reference",
                            "amount",
                            "currency",
                            "rate"
                        ],
                        "properties": {
                            "paid_on": {
                                "type": "string",
                                "format": "date"
                            },
                            "reference": {
                                "type": "string",
                                "nullable": true,
                                "description": "A bank reference or a transaction hash."
                            },
                            "amount": {
                                "type": "integer",
                                "nullable": true,
                                "description": "The amount paid, in minor units of its currency."
                            },
                            "currency": {
                                "type": "string",
                                "nullable": true
                            },
                            "rate": {
                                "type": "string",
                                "nullable": true,
                                "description": "The exchange rate, when the program paid in another currency."
                            }
                        }
                    }
                }
            },
            "BillPage": {
                "type": "object",
                "required": [
                    "bills",
                    "next_cursor"
                ],
                "properties": {
                    "bills": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Bill"
                        }
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true,
                        "description": "Send it as `cursor` for the next page; null on the last page."
                    }
                }
            },
            "BillStatement": {
                "type": "object",
                "description": "A bill as it was issued: its figures per product, lines, carried and forgiven amounts, adjustments, the rates it used and the players it paid a fixed amount for, masked. Amounts are in minor units of `currency`.",
                "required": [
                    "bill_id",
                    "partner_number",
                    "partner_company_name",
                    "brand_name",
                    "deal_title",
                    "deal_strategy",
                    "deal_version_number",
                    "period_start_date",
                    "period_end_date",
                    "currency",
                    "issued_at",
                    "total_amount",
                    "status",
                    "products",
                    "lines",
                    "carries",
                    "adjustments",
                    "rates",
                    "players"
                ],
                "properties": {
                    "bill_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "partner_number": {
                        "type": "integer"
                    },
                    "partner_company_name": {
                        "type": "string"
                    },
                    "brand_name": {
                        "type": "string"
                    },
                    "deal_title": {
                        "type": "string"
                    },
                    "deal_strategy": {
                        "type": "string",
                        "nullable": true
                    },
                    "deal_version_number": {
                        "type": "integer"
                    },
                    "period_start_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "period_end_date": {
                        "type": "string",
                        "format": "date"
                    },
                    "currency": {
                        "type": "string"
                    },
                    "issued_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "total_amount": {
                        "type": "integer"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "issued",
                            "on_hold",
                            "paid",
                            "canceled"
                        ]
                    },
                    "products": {
                        "type": "array",
                        "description": "Each product's real NGR, admin fee, NGR and payable NGR.",
                        "items": {
                            "type": "object",
                            "required": [
                                "product",
                                "real_ngr_amount",
                                "admin_fee_amount",
                                "ngr_amount",
                                "payable_ngr_amount"
                            ],
                            "properties": {
                                "product": {
                                    "type": "string",
                                    "enum": [
                                        "casino",
                                        "sportsbook"
                                    ]
                                },
                                "real_ngr_amount": {
                                    "type": "integer"
                                },
                                "admin_fee_amount": {
                                    "type": "integer"
                                },
                                "ngr_amount": {
                                    "type": "integer"
                                },
                                "payable_ngr_amount": {
                                    "type": "integer",
                                    "nullable": true
                                }
                            }
                        }
                    },
                    "lines": {
                        "type": "array",
                        "description": "Each reward the bill pays, with what it was worked out from.",
                        "items": {
                            "type": "object",
                            "required": [
                                "kind",
                                "reward_kind",
                                "line",
                                "base_amount",
                                "base_currency",
                                "rate_used",
                                "amount"
                            ],
                            "properties": {
                                "kind": {
                                    "type": "string"
                                },
                                "reward_kind": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "line": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "base_amount": {
                                    "type": "integer",
                                    "nullable": true
                                },
                                "base_currency": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "rate_used": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "amount": {
                                    "type": "integer"
                                }
                            }
                        }
                    },
                    "carries": {
                        "type": "array",
                        "description": "Amounts moved between your bills, and NGR carried to a later period or forgiven.",
                        "items": {
                            "type": "object",
                            "required": [
                                "kind",
                                "product",
                                "line",
                                "carry_reason",
                                "amount"
                            ],
                            "properties": {
                                "kind": {
                                    "type": "string"
                                },
                                "product": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "line": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "carry_reason": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "amount": {
                                    "type": "integer"
                                }
                            }
                        }
                    },
                    "adjustments": {
                        "type": "array",
                        "description": "Amounts the program added or took off, each with its reason.",
                        "items": {
                            "type": "object",
                            "required": [
                                "kind",
                                "reason",
                                "entered_at",
                                "amount"
                            ],
                            "properties": {
                                "kind": {
                                    "type": "string"
                                },
                                "reason": {
                                    "type": "string"
                                },
                                "entered_at": {
                                    "type": "string",
                                    "format": "date-time"
                                },
                                "amount": {
                                    "type": "integer"
                                }
                            }
                        }
                    },
                    "rates": {
                        "type": "array",
                        "description": "The exchange rates the bill used.",
                        "items": {
                            "type": "object",
                            "required": [
                                "from",
                                "from_decimals",
                                "to",
                                "to_decimals",
                                "rated_on",
                                "rate",
                                "source"
                            ],
                            "properties": {
                                "from": {
                                    "type": "string"
                                },
                                "from_decimals": {
                                    "type": "integer"
                                },
                                "to": {
                                    "type": "string"
                                },
                                "to_decimals": {
                                    "type": "integer"
                                },
                                "rated_on": {
                                    "type": "string",
                                    "format": "date"
                                },
                                "rate": {
                                    "type": "string"
                                },
                                "source": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "players": {
                        "type": "array",
                        "description": "The players the bill paid a fixed amount for, masked, with what qualified them.",
                        "items": {
                            "type": "object",
                            "required": [
                                "player",
                                "line",
                                "qualified_at",
                                "values",
                                "amount",
                                "currency"
                            ],
                            "properties": {
                                "player": {
                                    "type": "string",
                                    "description": "The player's masked id."
                                },
                                "line": {
                                    "type": "string",
                                    "nullable": true
                                },
                                "qualified_at": {
                                    "type": "string",
                                    "format": "date-time"
                                },
                                "values": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "required": [
                                            "kind",
                                            "amount",
                                            "currency",
                                            "count",
                                            "reached_at"
                                        ],
                                        "properties": {
                                            "kind": {
                                                "type": "string"
                                            },
                                            "amount": {
                                                "type": "string",
                                                "nullable": true
                                            },
                                            "currency": {
                                                "type": "string",
                                                "nullable": true
                                            },
                                            "count": {
                                                "type": "integer",
                                                "nullable": true
                                            },
                                            "reached_at": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                },
                                "amount": {
                                    "type": "integer"
                                },
                                "currency": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "Deal": {
                "type": "object",
                "description": "One of your deal assignments: the deal, its version, the brand and campaign it covers, when, and its terms, also in words. The admin fees show only when the program shows you GGR, real NGR and the admin fee.",
                "required": [
                    "id",
                    "deal",
                    "strategy",
                    "version_number",
                    "brand",
                    "campaign",
                    "currency",
                    "starts_at",
                    "ends_at",
                    "schedule",
                    "carryover_mode",
                    "casino_admin_fee_bps",
                    "sportsbook_admin_fee_bps",
                    "rules",
                    "description"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "deal": {
                        "$ref": "#/components/schemas/Reference"
                    },
                    "strategy": {
                        "type": "string",
                        "nullable": true
                    },
                    "version_number": {
                        "type": "integer"
                    },
                    "brand": {
                        "$ref": "#/components/schemas/Reference"
                    },
                    "campaign": {
                        "type": "object",
                        "nullable": true,
                        "description": "The campaign the assignment covers; null for the whole brand.",
                        "required": [
                            "id",
                            "name"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "currency": {
                        "type": "string"
                    },
                    "starts_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "ends_at": {
                        "type": "string",
                        "format": "date-time",
                        "nullable": true
                    },
                    "schedule": {
                        "type": "object",
                        "description": "When the deal's periods end, such as monthly.",
                        "additionalProperties": true
                    },
                    "carryover_mode": {
                        "type": "string",
                        "description": "What happens to negative NGR at a period's end."
                    },
                    "casino_admin_fee_bps": {
                        "type": "integer",
                        "nullable": true,
                        "description": "The casino admin fee, in basis points; 2500 is 25%."
                    },
                    "sportsbook_admin_fee_bps": {
                        "type": "integer",
                        "nullable": true
                    },
                    "rules": {
                        "type": "object",
                        "description": "The deal's reward groups and rules, as the program set them.",
                        "additionalProperties": true
                    },
                    "description": {
                        "type": "object",
                        "description": "The deal's terms and rules in plain English, as the portal's Your Deals page writes them, with times in UTC.",
                        "required": [
                            "bill_period",
                            "negative_ngr",
                            "admin_fees",
                            "cpa_hold",
                            "cpa_clawback",
                            "groups"
                        ],
                        "properties": {
                            "bill_period": {
                                "type": "string",
                                "description": "When the deal's periods start, such as \"Monthly\".",
                                "example": "Monthly"
                            },
                            "negative_ngr": {
                                "type": "string",
                                "description": "Whether negative NGR is forgiven or carried into your later periods, and how.",
                                "example": "Forgiven at the end of each period"
                            },
                            "admin_fees": {
                                "type": "string",
                                "nullable": true,
                                "description": "The casino and sportsbook admin fees; null unless the program shows you the admin fee.",
                                "example": "Casino 20%, sportsbook 15%"
                            },
                            "cpa_hold": {
                                "type": "string",
                                "nullable": true,
                                "description": "How long a CPA waits for chargebacks before it is billed; null for a deal that pays no CPA.",
                                "example": "Billed once 14 days pass after the player qualifies without a chargeback; a chargeback in that time voids it"
                            },
                            "cpa_clawback": {
                                "type": "string",
                                "nullable": true,
                                "description": "Whether a billed CPA can be taken back, and when; null for a deal that pays no CPA.",
                                "example": "Never taken back once billed"
                            },
                            "groups": {
                                "type": "array",
                                "description": "The deal's rule groups, each of which pays on its own, in order. Within a group, the first rule whose conditions hold pays.",
                                "items": {
                                    "type": "object",
                                    "required": [
                                        "rules"
                                    ],
                                    "properties": {
                                        "rules": {
                                            "type": "array",
                                            "description": "The group's rules in order, one sentence each.",
                                            "items": {
                                                "type": "string"
                                            },
                                            "example": [
                                                "If your players' casino NGR since the last bill is at least EUR 10,000.00, you earn 45% of casino NGR since the last bill.",
                                                "Otherwise, you earn 35% of casino NGR since the last bill."
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "DealPage": {
                "type": "object",
                "required": [
                    "deals",
                    "next_cursor"
                ],
                "properties": {
                    "deals": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Deal"
                        }
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "Brand": {
                "type": "object",
                "description": "A brand you can make links for.",
                "required": [
                    "id",
                    "name",
                    "products",
                    "currencies"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "products": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "enum": [
                                "casino",
                                "sportsbook"
                            ]
                        }
                    },
                    "currencies": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            },
            "BrandPage": {
                "type": "object",
                "required": [
                    "brands",
                    "next_cursor"
                ],
                "properties": {
                    "brands": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Brand"
                        }
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "Landing": {
                "type": "object",
                "description": "A landing page you may send players to.",
                "required": [
                    "id",
                    "brand_id",
                    "name",
                    "countries",
                    "language"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "brand_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "countries": {
                        "type": "array",
                        "description": "The countries it is meant for, as ISO 3166-1 alpha-2; empty for any.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "language": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "LandingPage": {
                "type": "object",
                "required": [
                    "landings",
                    "next_cursor"
                ],
                "properties": {
                    "landings": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Landing"
                        }
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "Campaign": {
                "type": "object",
                "description": "A campaign, with its promos that aren't archived, its traffic source, the deal that covers it now, its pinned domain and its state.",
                "required": [
                    "id",
                    "partner_id",
                    "brand_id",
                    "name",
                    "created_at",
                    "promos",
                    "traffic_source",
                    "deal",
                    "pinned_domain",
                    "state"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "partner_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "brand_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "promos": {
                        "type": "array",
                        "description": "Its promos that aren't archived; none for a campaign just created.",
                        "items": {
                            "type": "object",
                            "required": [
                                "id",
                                "landing_id",
                                "name",
                                "code"
                            ],
                            "properties": {
                                "id": {
                                    "type": "string",
                                    "format": "uuid"
                                },
                                "landing_id": {
                                    "type": "string",
                                    "format": "uuid"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "code": {
                                    "type": "string",
                                    "description": "The promo's code, which its links carry."
                                }
                            }
                        }
                    },
                    "traffic_source": {
                        "type": "object",
                        "nullable": true,
                        "description": "Where its visitors come from, one of the program's traffic sources; null for none. Its new promos start with it.",
                        "required": [
                            "id",
                            "name"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "deal": {
                        "type": "object",
                        "nullable": true,
                        "description": "The deal that covers its players now, by name: its own, else the partner's for the brand; null for none.",
                        "required": [
                            "id",
                            "name"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "pinned_domain": {
                        "type": "string",
                        "nullable": true,
                        "description": "The brand's tracking domain its links are shown on first; null for the brand's default."
                    },
                    "state": {
                        "type": "string",
                        "enum": [
                            "active",
                            "archived"
                        ],
                        "description": "`active` while it is in the link builder; `archived` once it left it, while its links and codes keep working."
                    }
                }
            },
            "CampaignPage": {
                "type": "object",
                "required": [
                    "campaigns",
                    "next_cursor"
                ],
                "properties": {
                    "campaigns": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Campaign"
                        }
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "NewCampaign": {
                "type": "object",
                "additionalProperties": false,
                "description": "A campaign to start.",
                "required": [
                    "brand_id",
                    "name"
                ],
                "properties": {
                    "brand_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "One of the brands you can make links for."
                    },
                    "name": {
                        "type": "string",
                        "maxLength": 100
                    },
                    "traffic_source_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true,
                        "description": "Where its traffic comes from, one of the program's traffic sources."
                    },
                    "deal_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true,
                        "description": "Your pick of the deals the program offers you on the brand, whose latest version then pays for the campaign's players. Leave it out to keep your deal for the brand; on a brand with deals on offer where you have none, a pick is required."
                    }
                }
            },
            "Promo": {
                "type": "object",
                "description": "One of your promos, with its links on the brand's tracking domains, the campaign's own first, its traffic source and its state.",
                "required": [
                    "id",
                    "campaign_id",
                    "brand_id",
                    "landing_id",
                    "name",
                    "code",
                    "links",
                    "traffic_source",
                    "state"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "campaign_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "brand_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "landing_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true
                    },
                    "name": {
                        "type": "string"
                    },
                    "code": {
                        "type": "string",
                        "description": "The promo's code, the last part of its links."
                    },
                    "links": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "format": "uri"
                        }
                    },
                    "traffic_source": {
                        "type": "object",
                        "nullable": true,
                        "description": "Where its visitors come from, one of the program's traffic sources; null when it uses its campaign's.",
                        "required": [
                            "id",
                            "name"
                        ],
                        "properties": {
                            "id": {
                                "type": "string",
                                "format": "uuid"
                            },
                            "name": {
                                "type": "string"
                            }
                        }
                    },
                    "state": {
                        "type": "string",
                        "enum": [
                            "active",
                            "archived"
                        ],
                        "description": "`active` while it is in the link builder; `archived` once it or its campaign was archived, while its link and code keep working."
                    }
                }
            },
            "PromoPage": {
                "type": "object",
                "required": [
                    "promos",
                    "next_cursor"
                ],
                "properties": {
                    "promos": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Promo"
                        }
                    },
                    "next_cursor": {
                        "type": "string",
                        "nullable": true
                    }
                }
            },
            "NewPromo": {
                "type": "object",
                "additionalProperties": false,
                "description": "A promo to make, in one of your campaigns.",
                "required": [
                    "campaign_id",
                    "landing_id"
                ],
                "properties": {
                    "campaign_id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "landing_id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "One of the landing pages you may use, on the campaign's brand."
                    },
                    "name": {
                        "type": "string",
                        "maxLength": 100,
                        "nullable": true,
                        "description": "Its name, the landing page's unless given."
                    },
                    "traffic_source_id": {
                        "type": "string",
                        "format": "uuid",
                        "nullable": true,
                        "description": "Where its traffic comes from, one of the program's traffic sources; its campaign's unless given."
                    }
                }
            }
        },
        "responses": {
            "InvalidReportCursor": {
                "description": "`invalid_cursor`: the cursor isn't one Affiliqo gave for this request. Send the `next_cursor` of the page before exactly as it came, with the same parameters, 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"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "Unauthorized": {
                "description": "The request carries no working statistic token, as `invalid_token`: the `Authorization` header is missing or isn't `Bearer <token>`, or the token is unknown, revoked, of a removed user, of a partner that isn't approved, or of a partner whose API access is off.",
                "headers": {
                    "WWW-Authenticate": {
                        "description": "The scheme to send tokens with.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "Bearer"
                            ]
                        }
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_token"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "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"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "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"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "RateMissing": {
                "description": "The report needs an exchange rate Affiliqo doesn't have for the rates date, as `exchange_rate_missing`: ask in the program's currency, or for an earlier `rates_on`.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "exchange_rate_missing"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidReport": {
                "description": "The request asks for something the report doesn't take or you may not use, as `invalid_input`: a parameter the report doesn't define, an unknown timezone or currency, a name the report doesn't know, or a grouping, column, filter or sort you don't get. Each error points at the parameter. `figure_too_large`: a figure passed what an amount can hold; ask for a shorter span.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_input",
                                                "figure_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"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "ReportsUnavailable": {
                "description": "Reports are briefly unavailable or busy, or the report took too long, as `unavailable`. Retry after the seconds in `Retry-After`; for a report that took too long, ask for a shorter span.",
                "headers": {
                    "Retry-After": {
                        "description": "The seconds to wait before retrying.",
                        "schema": {
                            "type": "integer",
                            "minimum": 0
                        }
                    }
                },
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "unavailable"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "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"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidListCursor": {
                "description": "`invalid_cursor`: the cursor isn't one Affiliqo gave. Send the `next_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"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidListQuery": {
                "description": "The request asks for something the list doesn't take, as `invalid_input`: a parameter it doesn't define, or a `limit` outside 1 to 1,000. Each error points at the parameter.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_input"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "WriteBadRequest": {
                "description": "Nothing was made. `idempotency_key_required`: the write has no `Idempotency-Key` of 1 to 255 printable characters without spaces; send it again with one. `unsupported_content_encoding`: the body came with a `Content-Encoding`; send it as plain JSON. `malformed_body`: the body is not a JSON object of valid UTF-8, at most 16 levels deep.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "idempotency_key_required",
                                                "unsupported_content_encoding",
                                                "malformed_body"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "WriteForbidden": {
                "description": "`forbidden`: the program hasn't let you create campaigns and promos through the API. `address_not_allowed`: the request came from an address the token doesn't list. The firewall answers an address no token lists itself, as `application/json`.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "forbidden",
                                                "address_not_allowed"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    "application/json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/FirewallRefusal"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "address_not_allowed"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "WriteConflict": {
                "description": "The `Idempotency-Key` was already used for another body or another kind of write, as `idempotency_conflict`. Nothing was made: send it under a new key. A retry of the same JSON under the same key is never a conflict.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "idempotency_conflict"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "WriteTooLarge": {
                "description": "The body is larger than 64 KB, as `payload_too_large`.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "payload_too_large"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            },
            "InvalidWrite": {
                "description": "The body isn't one the operation takes, as `invalid_input`: a field it doesn't define, or a brand, campaign or landing page you may not use. Each error points at the field.",
                "content": {
                    "application/problem+json": {
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/components/schemas/Problem"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "code": {
                                            "type": "string",
                                            "enum": [
                                                "invalid_input"
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
}
