{
  "openapi": "3.1.1",
  "info": {
    "title": "Passkaar integration API",
    "version": "1.0.0",
    "description": "A shop's own systems — its online store, its outlets' POS — read the shop's cards, sign customers up and give or spend loyalty value. Cards are made and edited in the Passkaar portal; an integration only uses them.\n\nEvery credential belongs to one connection of one shop. Send it as `Authorization: Bearer psk_live_…` (or `psk_test_…` on a test shop). A key works only under `/integrations/v1`. Every failed check of the key, its connection, the shop or the scope answers the same `401`.\n\nErrors are RFC 9457 Problem Details (`application/problem+json`) with a stable `code`. Branch on `code`; treat a code you do not know by its HTTP status, because new codes are an additive change.\n\nWithin v1 changes are additive only: new fields, new codes, new events. Ignore what you do not know. Lists take an opaque `cursor` and a `limit` of at most 100.\n\nMoney in a request is whole rupees. Events are Standard Webhooks, signed, ids and facts only."
  },
  "servers": [
    {
      "url": "https://api.passkaar.com/integrations/v1",
      "description": "Production, and test shops on it"
    }
  ],
  "security": [
    {
      "integrationKey": []
    }
  ],
  "tags": [
    {
      "name": "Programs",
      "description": "The shop's cards and branches."
    },
    {
      "name": "Customers",
      "description": "Signing customers up and linking them."
    },
    {
      "name": "Cards",
      "description": "A customer's card and its history."
    },
    {
      "name": "Card actions",
      "description": "Giving, spending, reversing and holding value."
    },
    {
      "name": "Events",
      "description": "Webhooks and the event feed."
    },
    {
      "name": "Contract",
      "description": "This document."
    }
  ],
  "paths": {
    "/programs": {
      "get": {
        "operationId": "listPrograms",
        "tags": [
          "Programs"
        ],
        "summary": "The shop's live cards",
        "description": "Scope: `programs:read`.",
        "security": [
          {
            "integrationKey": [
              "programs:read"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "description": "`next_cursor` from the previous page. Opaque.",
              "type": "string",
              "maxLength": 200
            },
            "description": "`next_cursor` from the previous page. Opaque."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 25,
              "description": "At most 100.",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "At most 100."
          }
        ],
        "responses": {
          "200": {
            "description": "Published cards, newest first.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProgramList"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/programs/{id}": {
      "get": {
        "operationId": "getProgram",
        "tags": [
          "Programs"
        ],
        "summary": "A card's type, rules, rewards and join form",
        "description": "Scope: `programs:read`.",
        "security": [
          {
            "integrationKey": [
              "programs:read"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "The card.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Program"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/branches": {
      "get": {
        "operationId": "listBranches",
        "tags": [
          "Programs"
        ],
        "summary": "The shop's branches",
        "description": "Scope: `programs:read`.",
        "security": [
          {
            "integrationKey": [
              "programs:read"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "description": "`next_cursor` from the previous page. Opaque.",
              "type": "string",
              "maxLength": 200
            },
            "description": "`next_cursor` from the previous page. Opaque."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 25,
              "description": "At most 100.",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "At most 100."
          }
        ],
        "responses": {
          "200": {
            "description": "Every branch, open ones first.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BranchList"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/enrolments": {
      "post": {
        "operationId": "createEnrolment",
        "tags": [
          "Customers"
        ],
        "summary": "Sign a customer up",
        "description": "Only on the customer’s own tap, never in bulk. Makes the customer and the card in one step and answers a claim link for the customer to add the card to their wallet. Earning starts at once. `already_member` answers a link only for a card this connection made.\n\nScope: `customers:enrol`.",
        "security": [
          {
            "integrationKey": [
              "customers:enrol"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnrolmentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`already_member`: the customer already holds this card.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Enrolment"
                }
              }
            }
          },
          "201": {
            "description": "The customer and the card were made.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Enrolment"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "`shop_locked`: The shop cannot sign customers up while it is locked",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `external_id_taken`: That external id belongs to another customer",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `program_closed`: The card is not taking sign-ups. `customer_limit_reached`: The shop's plan has no room for a new customer. `invalid_answers`: The answers do not meet the card's form. `opening_balance_not_allowed`: This connection may not give a starting balance. `operation_not_allowed`: The card's type does not allow this",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/cards/{id}/claim-link": {
      "post": {
        "operationId": "createClaimLink",
        "tags": [
          "Customers"
        ],
        "summary": "A fresh claim link for a card never in a wallet",
        "description": "Only for a card this connection’s own sign-up made, while it has never been in a wallet. A card answered `already_member` that another connection or the join page made takes none.\n\nScope: `customers:enrol`.",
        "security": [
          {
            "integrationKey": [
              "customers:enrol"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "A new link; earlier ones stop working.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimLink"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "`shop_locked`: The shop cannot sign customers up while it is locked",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `card_in_wallet`: The card has already been in a wallet",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `operation_not_allowed`: The card's type does not allow this",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/customers/{id}/external-id": {
      "put": {
        "operationId": "setExternalId",
        "tags": [
          "Customers"
        ],
        "summary": "Attach or change the integration's customer id",
        "description": "Scope: `customers:enrol`.",
        "security": [
          {
            "integrationKey": [
              "customers:enrol"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalIdRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Linked.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerIds"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "`shop_locked`: The shop cannot sign customers up while it is locked",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`external_id_taken`: That external id belongs to another customer",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/cards/link": {
      "post": {
        "operationId": "linkCard",
        "tags": [
          "Customers"
        ],
        "summary": "Link a card made at an outlet to a store account",
        "description": "By the card ID printed on the card and the phone or email it was made with. The card is then proved to `external_id`, which may spend it (`POST /redemptions`, `POST /redemption-holds`); an id the customer already held from this connection is replaced and keeps no other proof. A mismatch answers 404, the same as a card that does not exist. Linking again answers the same.\n\nScope: `customers:enrol`.",
        "security": [
          {
            "integrationKey": [
              "customers:enrol"
            ]
          }
        ],
        "x-passkaar-phase": 53,
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardLinkRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Linked.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardLink"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "`shop_locked`: The shop cannot sign customers up while it is locked",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `external_id_taken`: That external id belongs to another customer",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/cards/lookup": {
      "post": {
        "operationId": "lookUpCards",
        "tags": [
          "Cards"
        ],
        "summary": "Find a card by serial, card ID, phone, email or external id",
        "description": "A POST so a phone or email never sits in a URL or a log line.\n\nScope: `cards:read`.",
        "security": [
          {
            "integrationKey": [
              "cards:read"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardRef"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The matching cards.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardLookup"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`ambiguous`: More than one card matches",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/cards/{id}": {
      "get": {
        "operationId": "getCard",
        "tags": [
          "Cards"
        ],
        "summary": "A card's balance, rewards, tier, dates, status and whether it is in a wallet",
        "description": "Scope: `cards:read`.",
        "security": [
          {
            "integrationKey": [
              "cards:read"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "The card.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Card"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/cards/{id}/transactions": {
      "get": {
        "operationId": "listCardTransactions",
        "tags": [
          "Cards"
        ],
        "summary": "A card's history",
        "description": "Scope: `cards:read`.",
        "security": [
          {
            "integrationKey": [
              "cards:read"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "description": "`next_cursor` from the previous page. Opaque.",
              "type": "string",
              "maxLength": 200
            },
            "description": "`next_cursor` from the previous page. Opaque."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 25,
              "description": "At most 100.",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "At most 100."
          }
        ],
        "responses": {
          "200": {
            "description": "Newest first.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardTransactionList"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/awards": {
      "post": {
        "operationId": "createAward",
        "tags": [
          "Card actions"
        ],
        "summary": "Give value for a sale",
        "description": "The same `reference` again, at any age, answers the first result with `replayed: true`. A phone or email may name the card here: earning needs no card in hand. What one connection gives a card by count in a day is held to what its largest bill buys: one full card of stamps, or the points that bill would earn. A plan’s price times its quantity is held to the largest bill.\n\nScope: `awards:write`.",
        "security": [
          {
            "integrationKey": [
              "awards:write"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AwardRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A replay of a reference already used.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Award"
                }
              }
            }
          },
          "201": {
            "description": "Given.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Award"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `ambiguous`: More than one card matches",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `reference_reused`: The reference was used for a different card. `card_not_active`: The card is not active. `operation_not_allowed`: The card's type does not allow this. `give_required`: Say what to give: this card does not earn from a bill. `daily_cap_reached`: The card's daily limit is reached. `bill_too_large`: The bill is over the connection's largest bill. `give_limit_reached`: More than this connection gives the card by count in a day. `invalid_occurred_at`: `occurred_at` is in the future",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/awards/{reference}/reverse": {
      "post": {
        "operationId": "reverseAward",
        "tags": [
          "Card actions"
        ],
        "summary": "Refund or void an award, in full or in part",
        "description": "Full and unspent: the award is undone. Partial: its proportional share. Already spent: what is there is taken, never below zero, and `refund.unresolved` is sent.\n\nScope: `awards:reverse`.",
        "security": [
          {
            "integrationKey": [
              "awards:reverse"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "in": "path",
            "name": "reference",
            "schema": {
              "description": "The award's `reference`, percent-encoded as one path segment (`encodeURIComponent`): `INV/24-25/001` is sent as `INV%2F24-25%2F001`, and `%`, `?` and `#` are encoded the same way.",
              "examples": [
                "INV/24-25/001"
              ],
              "$ref": "#/components/schemas/Reference"
            },
            "required": true,
            "description": "The award's `reference`, percent-encoded as one path segment (`encodeURIComponent`): `INV/24-25/001` is sent as `INV%2F24-25%2F001`, and `%`, `?` and `#` are encoded the same way."
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReversalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A replay.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reversal"
                }
              }
            }
          },
          "201": {
            "description": "Reversed.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reversal"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `already_reversed`: The award has already been reversed in full",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `reversal_exceeds_award`: More than is left of the award. `reference_reused`: The reference was used for a different card. `operation_not_allowed`: The card's type does not allow this. `invalid_occurred_at`: `occurred_at` is in the future",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/redemptions": {
      "post": {
        "operationId": "createRedemption",
        "tags": [
          "Card actions"
        ],
        "summary": "Spend value now",
        "description": "Only the card itself (`serial` or `card_id`), or an `external_id` linked with the card, may spend. A phone, an email, or an id linked from a phone or email alone answers `card_required`.\n\nScope: `redemptions:write`.",
        "security": [
          {
            "integrationKey": [
              "redemptions:write"
            ]
          }
        ],
        "x-passkaar-phase": 51,
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RedemptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A replay of a reference already used.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Redemption"
                }
              }
            }
          },
          "201": {
            "description": "Spent.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Redemption"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `ambiguous`: More than one card matches",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `reference_reused`: The reference was used for a different card. `card_required`: Spending needs the card itself or a store account linked with it. `card_not_active`: The card is not active. `operation_not_allowed`: The card's type does not allow this. `insufficient_balance`: The card does not hold enough. `daily_cap_reached`: The card's daily limit is reached. `invalid_occurred_at`: `occurred_at` is in the future",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/redemption-holds": {
      "post": {
        "operationId": "createHold",
        "tags": [
          "Card actions"
        ],
        "summary": "Reserve value against an online order",
        "description": "For a stamps card’s reward, a points card’s points or reward, or a prepaid card’s deduction, spent by the card itself or an `external_id` linked with it, as `POST /redemptions` is. What is held is out of reach of every other spend, the till’s included, until it is confirmed, released, or lapses 15 minutes after it was made. A hold that lapsed spends nothing.\n\nScope: `redemptions:write`.",
        "security": [
          {
            "integrationKey": [
              "redemptions:write"
            ]
          }
        ],
        "x-passkaar-phase": 53,
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A replay of a reference already used.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hold"
                }
              }
            }
          },
          "201": {
            "description": "Held.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hold"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `ambiguous`: More than one card matches",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `reference_reused`: The reference was used for a different card. `card_required`: Spending needs the card itself or a store account linked with it. `card_not_active`: The card is not active. `operation_not_allowed`: The card's type does not allow this. `insufficient_balance`: The card does not hold enough",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/redemption-holds/{id}/confirm": {
      "post": {
        "operationId": "confirmHold",
        "tags": [
          "Card actions"
        ],
        "summary": "Spend what a hold reserved",
        "description": "Writes the one redemption, under the hold’s reference. Confirming a confirmed hold answers it again with `replayed: true`; a released or lapsed one answers `hold_not_open`. Until it lapses, a card that has since lost value, to an expiry or a refund, answers `insufficient_balance`.\n\nScope: `redemptions:write`.",
        "security": [
          {
            "integrationKey": [
              "redemptions:write"
            ]
          }
        ],
        "x-passkaar-phase": 53,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldConfirmRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Confirmed; `redemption` is set.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hold"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `hold_not_open`: The hold is no longer open",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `card_not_active`: The card is not active. `insufficient_balance`: The card does not hold enough. `invalid_occurred_at`: `occurred_at` is in the future",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/redemption-holds/{id}/release": {
      "post": {
        "operationId": "releaseHold",
        "tags": [
          "Card actions"
        ],
        "summary": "Free what a hold reserved",
        "description": "Releasing a released hold answers it again with `replayed: true`; a confirmed or lapsed one answers `hold_not_open`.\n\nScope: `redemptions:write`.",
        "security": [
          {
            "integrationKey": [
              "redemptions:write"
            ]
          }
        ],
        "x-passkaar-phase": 53,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Released.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Hold"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `hold_not_open`: The hold is no longer open",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "listEvents",
        "tags": [
          "Events"
        ],
        "summary": "The event feed",
        "description": "Every event, the same envelopes the webhooks carry, oldest first from the cursor.\n\nScope: `events:read`.",
        "security": [
          {
            "integrationKey": [
              "events:read"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "description": "`next_cursor` from the previous page. Opaque.",
              "type": "string",
              "maxLength": 200
            },
            "description": "`next_cursor` from the previous page. Opaque."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 25,
              "description": "At most 100.",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "At most 100."
          },
          {
            "in": "query",
            "name": "type",
            "schema": {
              "$ref": "#/components/schemas/EventType"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints": {
      "get": {
        "operationId": "listWebhookEndpoints",
        "tags": [
          "Events"
        ],
        "summary": "This connection's webhook endpoints",
        "description": "Scope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "description": "`next_cursor` from the previous page. Opaque.",
              "type": "string",
              "maxLength": 200
            },
            "description": "`next_cursor` from the previous page. Opaque."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "default": 25,
              "description": "At most 100.",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "At most 100."
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoints.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointList"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhookEndpoint",
        "tags": [
          "Events"
        ],
        "summary": "Add a webhook endpoint",
        "description": "Scope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Made; the secret is shown this once.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointCreated"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request. `webhook_url_not_allowed`: The address cannot receive webhooks",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}": {
      "get": {
        "operationId": "getWebhookEndpoint",
        "tags": [
          "Events"
        ],
        "summary": "A webhook endpoint",
        "description": "Scope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateWebhookEndpoint",
        "tags": [
          "Events"
        ],
        "summary": "Change, switch off or switch back on a webhook endpoint",
        "description": "Scope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`webhook_url_not_allowed`: The address cannot receive webhooks",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhookEndpoint",
        "tags": [
          "Events"
        ],
        "summary": "Remove a webhook endpoint",
        "description": "Scope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "Removed; nothing more is sent to it.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}/test": {
      "post": {
        "operationId": "testWebhookEndpoint",
        "tags": [
          "Events"
        ],
        "summary": "Send a `webhook.test` event to the endpoint",
        "description": "Scope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "202": {
            "description": "Queued.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestSent"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}/roll-secret": {
      "post": {
        "operationId": "rollWebhookSecret",
        "tags": [
          "Events"
        ],
        "summary": "Roll the endpoint's signing secret",
        "description": "Both secrets sign every delivery for the next 24 hours, and the endpoint takes no other roll until they end.\n\nScope: `webhooks:manage`.",
        "security": [
          {
            "integrationKey": [
              "webhooks:manage"
            ]
          }
        ],
        "x-passkaar-phase": 52,
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "The new secret, shown this once.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSecretRolled"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`: The request is not valid",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`: Unauthorized",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "`not_found`: Not found",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "`request_in_progress`: A request with this key is still running. `previous_secret_active`: The last roll's previous secret is still signing",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "`idempotency_key_reused`: The idempotency key was used with a different request",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "`internal_error`: Something went wrong on our side",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "`unavailable`: The integration API is not available",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "tags": [
          "Contract"
        ],
        "summary": "This contract",
        "description": "Public: no key. On `check:turnstile`’s written exemption list (ADR 0210).\n\nNo key needed.",
        "security": [],
        "x-passkaar-phase": 51,
        "responses": {
          "200": {
            "description": "The OpenAPI 3.1 document.",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "429": {
            "description": "`rate_limited`: Too many requests",
            "headers": {
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "card.created": {
      "post": {
        "operationId": "event.card.created",
        "tags": [
          "Events"
        ],
        "summary": "card.created",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardCreatedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "card.claimed": {
      "post": {
        "operationId": "event.card.claimed",
        "tags": [
          "Events"
        ],
        "summary": "card.claimed",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardClaimedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "card.removed_from_wallet": {
      "post": {
        "operationId": "event.card.removed_from_wallet",
        "tags": [
          "Events"
        ],
        "summary": "card.removed_from_wallet",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardRemovedFromWalletEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "award.created": {
      "post": {
        "operationId": "event.award.created",
        "tags": [
          "Events"
        ],
        "summary": "award.created",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AwardCreatedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "award.reversed": {
      "post": {
        "operationId": "event.award.reversed",
        "tags": [
          "Events"
        ],
        "summary": "award.reversed",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AwardReversedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "reward.unlocked": {
      "post": {
        "operationId": "event.reward.unlocked",
        "tags": [
          "Events"
        ],
        "summary": "reward.unlocked",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RewardUnlockedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "redemption.created": {
      "post": {
        "operationId": "event.redemption.created",
        "tags": [
          "Events"
        ],
        "summary": "redemption.created",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RedemptionCreatedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "balance.expired": {
      "post": {
        "operationId": "event.balance.expired",
        "tags": [
          "Events"
        ],
        "summary": "balance.expired",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BalanceExpiredEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "refund.unresolved": {
      "post": {
        "operationId": "event.refund.unresolved",
        "tags": [
          "Events"
        ],
        "summary": "refund.unresolved",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundUnresolvedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "customer.erased": {
      "post": {
        "operationId": "event.customer.erased",
        "tags": [
          "Events"
        ],
        "summary": "customer.erased",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerErasedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "connection.revoked": {
      "post": {
        "operationId": "event.connection.revoked",
        "tags": [
          "Events"
        ],
        "summary": "connection.revoked",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectionRevokedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "webhook.test": {
      "post": {
        "operationId": "event.webhook.test",
        "tags": [
          "Events"
        ],
        "summary": "webhook.test",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookTestEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "hold.created": {
      "post": {
        "operationId": "event.hold.created",
        "tags": [
          "Events"
        ],
        "summary": "hold.created",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldCreatedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "hold.confirmed": {
      "post": {
        "operationId": "event.hold.confirmed",
        "tags": [
          "Events"
        ],
        "summary": "hold.confirmed",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldConfirmedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "hold.released": {
      "post": {
        "operationId": "event.hold.released",
        "tags": [
          "Events"
        ],
        "summary": "hold.released",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldReleasedEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    },
    "hold.expired": {
      "post": {
        "operationId": "event.hold.expired",
        "tags": [
          "Events"
        ],
        "summary": "hold.expired",
        "parameters": [
          {
            "in": "header",
            "name": "webhook-id",
            "schema": {
              "type": "string",
              "description": "The event id; the same on every retry."
            },
            "required": true,
            "description": "The event id; the same on every retry."
          },
          {
            "in": "header",
            "name": "webhook-timestamp",
            "schema": {
              "type": "string",
              "description": "Unix seconds when this attempt was signed."
            },
            "required": true,
            "description": "Unix seconds when this attempt was signed."
          },
          {
            "in": "header",
            "name": "webhook-signature",
            "schema": {
              "type": "string",
              "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
            },
            "required": true,
            "description": "Space-separated `v1,<base64>` HMAC-SHA256 signatures over `{webhook-id}.{webhook-timestamp}.{body}`; two for 24 hours after a roll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldExpiredEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Any 2xx acknowledges it. Anything else is retried for about three days."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EnrolmentRequest": {
        "type": "object",
        "properties": {
          "program": {
            "type": "string",
            "format": "uuid",
            "description": "The card to sign up for, from `GET /programs`."
          },
          "answers": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[a-z0-9_]{1,64}$"
            },
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 500
                },
                {
                  "type": "number"
                }
              ]
            },
            "description": "The join form's answers by `form[].key` from `GET /programs/{id}`: the first name and the dedupe key at least. Dates are `YYYY-MM-DD`. A required field left out is asked on the claim page.",
            "examples": [
              {
                "first_name": "Ayesha",
                "phone": "03001234567"
              }
            ]
          },
          "external_id": {
            "$ref": "#/components/schemas/ExternalId"
          },
          "branch": {
            "description": "Where the customer signed up.",
            "type": "string",
            "format": "uuid"
          },
          "opening_balance": {
            "description": "A starting balance for a customer moving from another system. Needs `customers:opening-balance`, which Passkaar switches on per connection.",
            "type": "object",
            "properties": {
              "amount": {
                "type": "integer",
                "minimum": 1,
                "maximum": 999999999999,
                "description": "In the card's own unit: stamps, points or whole rupees. Which card types take one is not settled (ADR 0214)."
              },
              "reason": {
                "description": "Why, as the ledger row will read: \"Moved from our old card\".",
                "type": "string"
              }
            },
            "required": [
              "amount",
              "reason"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "program",
          "answers"
        ],
        "additionalProperties": false
      },
      "ExternalId": {
        "type": "string",
        "pattern": "^[!-~]{1,128}$",
        "description": "The integration's own id for the customer, 1–128 visible ASCII characters. Unique per connection in both directions.",
        "examples": [
          "shopify-cust-88213"
        ]
      },
      "ExternalIdRequest": {
        "type": "object",
        "properties": {
          "external_id": {
            "$ref": "#/components/schemas/ExternalId"
          }
        },
        "required": [
          "external_id"
        ],
        "additionalProperties": false
      },
      "CardLinkRequest": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "card_id": {
                "type": "string",
                "minLength": 9,
                "maxLength": 20,
                "description": "The card ID printed under the QR and on the back of the card, as typed. Case, spaces and dashes are ignored.",
                "examples": [
                  "PK7-4M2-9XQ"
                ]
              },
              "phone": {
                "description": "A Pakistani mobile number, as typed (`03001234567`, `+92 300 1234567`).",
                "type": "string"
              },
              "external_id": {
                "$ref": "#/components/schemas/ExternalId"
              }
            },
            "required": [
              "card_id",
              "phone",
              "external_id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "card_id": {
                "type": "string",
                "minLength": 9,
                "maxLength": 20,
                "description": "The card ID printed under the QR and on the back of the card, as typed. Case, spaces and dashes are ignored.",
                "examples": [
                  "PK7-4M2-9XQ"
                ]
              },
              "email": {
                "examples": [
                  "ayesha@example.com"
                ],
                "type": "string"
              },
              "external_id": {
                "$ref": "#/components/schemas/ExternalId"
              }
            },
            "required": [
              "card_id",
              "email",
              "external_id"
            ],
            "additionalProperties": false
          }
        ]
      },
      "CardRef": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "serial": {
                "type": "string",
                "minLength": 20,
                "maxLength": 36,
                "description": "What the card's QR holds, as scanned (ADR 0012)."
              }
            },
            "required": [
              "serial"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "card_id": {
                "type": "string",
                "minLength": 9,
                "maxLength": 20,
                "description": "The card ID printed under the QR and on the back of the card, as typed. Case, spaces and dashes are ignored.",
                "examples": [
                  "PK7-4M2-9XQ"
                ]
              }
            },
            "required": [
              "card_id"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "phone": {
                "description": "A Pakistani mobile number, as typed (`03001234567`, `+92 300 1234567`).",
                "type": "string"
              },
              "program": {
                "description": "Which of the customer's cards, when they hold more than one in this shop. Without it, a customer with several answers `409 ambiguous`.",
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "phone"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "email": {
                "examples": [
                  "ayesha@example.com"
                ],
                "type": "string"
              },
              "program": {
                "description": "Which of the customer's cards, when they hold more than one in this shop. Without it, a customer with several answers `409 ambiguous`.",
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "email"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "external_id": {
                "$ref": "#/components/schemas/ExternalId"
              },
              "program": {
                "description": "Which of the customer's cards, when they hold more than one in this shop. Without it, a customer with several answers `409 ambiguous`.",
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "external_id"
            ],
            "additionalProperties": false
          }
        ],
        "description": "Exactly one of `serial`, `card_id`, `phone`, `email` or `external_id`. A phone or email that matches several customers answers `409 ambiguous`. Spending accepts only `serial`, `card_id`, or an `external_id` linked with the card."
      },
      "AwardRequest": {
        "type": "object",
        "properties": {
          "card": {
            "$ref": "#/components/schemas/CardRef"
          },
          "reference": {
            "$ref": "#/components/schemas/Reference"
          },
          "bill": {
            "description": "The sale. Required where the card earns from it; recorded on the card either way.",
            "$ref": "#/components/schemas/Bill"
          },
          "give": {
            "$ref": "#/components/schemas/Give"
          },
          "paid_on_delivery": {
            "description": "True for an order paid on delivery (cash on delivery). Send it only once the order is delivered and paid. A shop that gives nothing on such orders answers `operation_not_allowed`.",
            "type": "boolean"
          },
          "occurred_at": {
            "description": "When the sale happened, for a late sale. Not in the future. Defaults to now.",
            "type": "string",
            "format": "date-time"
          },
          "branch": {
            "type": "string",
            "format": "uuid",
            "description": "A branch's id from `GET /branches`. Omitted, the connection's branch if it has one, otherwise none."
          },
          "note": {
            "description": "Words for the row in the card's history, at most 500 characters.",
            "type": "string"
          }
        },
        "required": [
          "card",
          "reference"
        ],
        "additionalProperties": false
      },
      "Reference": {
        "type": "string",
        "pattern": "^[!-~]{1,64}$",
        "description": "The caller's invoice, order or refund number, 1–64 visible ASCII characters. Unique per connection for ever within its kind (awards, redemptions, reversals, holds): the same reference again, at any age, answers the first result with `replayed: true`.",
        "examples": [
          "ORDER-1047"
        ]
      },
      "Bill": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999999999999,
            "description": "The whole bill in whole rupees, tax and delivery in it."
          },
          "tax": {
            "description": "Whole rupees of tax inside `total`.",
            "type": "integer",
            "minimum": 0,
            "maximum": 999999999999
          },
          "delivery": {
            "description": "Whole rupees of delivery inside `total`.",
            "type": "integer",
            "minimum": 0,
            "maximum": 999999999999
          },
          "currency": {
            "type": "string",
            "const": "PKR"
          }
        },
        "required": [
          "total",
          "currency"
        ],
        "additionalProperties": false,
        "description": "The sale. `tax` and `delivery` are inside `total`, so together they are at most `total`. Whether they count towards earning is the connection's setting."
      },
      "Give": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/GiveStamps"
          },
          {
            "$ref": "#/components/schemas/GivePoints"
          },
          {
            "$ref": "#/components/schemas/GiveTopUp"
          },
          {
            "$ref": "#/components/schemas/GivePlan"
          },
          {
            "$ref": "#/components/schemas/GiveCheckIn"
          },
          {
            "$ref": "#/components/schemas/GiveVisit"
          }
        ],
        "description": "What is given. Omitted, the card earns from `bill`: a points card at its rate, a VIP card by its measure (a visit, or the whole rupees of the bill). Any other card then answers `give_required`. A coupon takes no award.",
        "type": "object",
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "stamps": "#/components/schemas/GiveStamps",
            "points": "#/components/schemas/GivePoints",
            "top_up": "#/components/schemas/GiveTopUp",
            "plan": "#/components/schemas/GivePlan",
            "check_in": "#/components/schemas/GiveCheckIn",
            "visit": "#/components/schemas/GiveVisit"
          }
        }
      },
      "GiveStamps": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "stamps"
          },
          "stamps": {
            "type": "integer",
            "minimum": 1,
            "maximum": 30
          }
        },
        "required": [
          "type",
          "stamps"
        ],
        "additionalProperties": false,
        "description": "Stamps card: a number of stamps."
      },
      "GivePoints": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "points"
          },
          "points": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          }
        },
        "required": [
          "type",
          "points"
        ],
        "additionalProperties": false,
        "description": "Points card: a number of points, instead of earning from the bill."
      },
      "GiveTopUp": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "top_up"
          },
          "amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999999999999,
            "description": "Whole rupees."
          }
        },
        "required": [
          "type",
          "amount"
        ],
        "additionalProperties": false,
        "description": "Prepaid card: a top-up, with any load bonus the card gives."
      },
      "GivePlan": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "plan"
          },
          "plan": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$",
            "description": "A plan's `key` from the program's rules."
          },
          "quantity": {
            "default": 1,
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          }
        },
        "required": [
          "type",
          "plan"
        ],
        "additionalProperties": false,
        "description": "Membership card: renew by time, or sell a pack of sessions."
      },
      "GiveCheckIn": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "check_in"
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": false,
        "description": "Membership card that takes check-ins: a visit at the door."
      },
      "GiveVisit": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "visit"
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": false,
        "description": "VIP card counted in visits: one visit."
      },
      "ReversalRequest": {
        "type": "object",
        "properties": {
          "refund": {
            "description": "A partial refund: the award's proportional share of it is taken back. Omitted, the whole award is reversed.",
            "type": "object",
            "properties": {
              "total": {
                "type": "integer",
                "minimum": 1,
                "maximum": 999999999999,
                "description": "Whole rupees refunded of the bill the award had."
              },
              "currency": {
                "type": "string",
                "const": "PKR"
              }
            },
            "required": [
              "total",
              "currency"
            ],
            "additionalProperties": false
          },
          "refund_reference": {
            "description": "The refund or credit note number. Required with `refund`, so each partial refund is its own and a resend replays it.",
            "$ref": "#/components/schemas/Reference"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "note": {
            "description": "Words for the row in the card's history, at most 500 characters.",
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "RedemptionRequest": {
        "type": "object",
        "properties": {
          "card": {
            "$ref": "#/components/schemas/CardRef"
          },
          "reference": {
            "$ref": "#/components/schemas/Reference"
          },
          "spend": {
            "$ref": "#/components/schemas/Spend"
          },
          "bill": {
            "description": "The sale, where the card asks for one (a coupon's minimum spend).",
            "$ref": "#/components/schemas/Bill"
          },
          "occurred_at": {
            "description": "Defaults to now. Not in the future.",
            "type": "string",
            "format": "date-time"
          },
          "branch": {
            "type": "string",
            "format": "uuid",
            "description": "A branch's id from `GET /branches`. Omitted, the connection's branch if it has one, otherwise none."
          },
          "note": {
            "description": "Words for the row in the card's history, at most 500 characters.",
            "type": "string"
          }
        },
        "required": [
          "card",
          "reference",
          "spend"
        ],
        "additionalProperties": false
      },
      "Spend": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/SpendReward"
          },
          {
            "$ref": "#/components/schemas/SpendPoints"
          },
          {
            "$ref": "#/components/schemas/SpendDeduction"
          },
          {
            "$ref": "#/components/schemas/SpendCoupon"
          },
          {
            "$ref": "#/components/schemas/SpendSession"
          }
        ],
        "description": "What is spent. The card’s type decides which it may be.",
        "type": "object",
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "reward": "#/components/schemas/SpendReward",
            "points": "#/components/schemas/SpendPoints",
            "deduction": "#/components/schemas/SpendDeduction",
            "coupon": "#/components/schemas/SpendCoupon",
            "session": "#/components/schemas/SpendSession"
          }
        }
      },
      "SpendReward": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "reward"
          },
          "reward": {
            "description": "A points card's catalogue `key`. Left out on a stamps card.",
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          },
          "quantity": {
            "default": 1,
            "type": "integer",
            "minimum": 1,
            "maximum": 10
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": false,
        "description": "Stamps card: a reward. Points card with a catalogue: a reward from it."
      },
      "SpendPoints": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "points"
          },
          "points": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          }
        },
        "required": [
          "type",
          "points"
        ],
        "additionalProperties": false,
        "description": "Points card without a catalogue: a number of points. On a cash-back card the answer says what they are worth off the bill."
      },
      "SpendDeduction": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "deduction"
          },
          "amount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999999999999,
            "description": "Whole rupees."
          }
        },
        "required": [
          "type",
          "amount"
        ],
        "additionalProperties": false,
        "description": "Prepaid card: a payment from the balance."
      },
      "SpendCoupon": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "coupon"
          },
          "deals": {
            "default": 1,
            "type": "integer",
            "minimum": 1,
            "maximum": 10
          },
          "item": {
            "description": "Which of a deal's items; the first when left out.",
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": false,
        "description": "Coupon: apply it, once or as several deals in one bill."
      },
      "SpendSession": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "session"
          },
          "service": {
            "description": "A service's `key`, on a card with services.",
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": false,
        "description": "Membership card: use a session."
      },
      "HoldRequest": {
        "type": "object",
        "properties": {
          "card": {
            "$ref": "#/components/schemas/CardRef"
          },
          "reference": {
            "description": "The order the value is held for.",
            "$ref": "#/components/schemas/Reference"
          },
          "spend": {
            "$ref": "#/components/schemas/Spend"
          },
          "branch": {
            "type": "string",
            "format": "uuid",
            "description": "A branch's id from `GET /branches`. Omitted, the connection's branch if it has one, otherwise none."
          }
        },
        "required": [
          "card",
          "reference",
          "spend"
        ],
        "additionalProperties": false
      },
      "HoldConfirmRequest": {
        "type": "object",
        "properties": {
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          }
        },
        "additionalProperties": false
      },
      "EventType": {
        "type": "string",
        "enum": [
          "card.created",
          "card.claimed",
          "card.removed_from_wallet",
          "award.created",
          "award.reversed",
          "reward.unlocked",
          "redemption.created",
          "balance.expired",
          "refund.unresolved",
          "customer.erased",
          "connection.revoked",
          "webhook.test",
          "hold.created",
          "hold.confirmed",
          "hold.released",
          "hold.expired"
        ]
      },
      "WebhookEndpointCreate": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2000,
            "format": "uri",
            "description": "HTTPS only. A name that resolves to a private, link-local or metadata address is refused on every attempt, and redirects are not followed."
          },
          "events": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventType"
            },
            "description": "The events to send. The feed at `GET /events` carries every event either way."
          },
          "description": {
            "type": "string",
            "maxLength": 200
          }
        },
        "required": [
          "url",
          "events"
        ],
        "additionalProperties": false
      },
      "WebhookEndpointUpdate": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2000,
            "format": "uri",
            "description": "HTTPS only. A name that resolves to a private, link-local or metadata address is refused on every attempt, and redirects are not followed."
          },
          "events": {
            "minItems": 1,
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventType"
            },
            "description": "The events to send. The feed at `GET /events` carries every event either way."
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 200
              },
              {
                "type": "null"
              }
            ]
          },
          "enabled": {
            "description": "True turns a switched-off endpoint back on.",
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "CardCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "card.created"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "source": {
                "$ref": "#/components/schemas/Source"
              },
              "branch_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uuid"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The branch it happened at, if any."
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "source",
              "branch_id"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "CardIds": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "card_id": {
            "examples": [
              "PK7-4M2-9XQ"
            ],
            "description": "The printed card ID, only when the call named the card by `serial` or `card_id`, the call made the card (a `created` sign-up), or this connection’s `external_id` was linked with the card. Null when the card was found by phone, email or an unproven link.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "card_id"
        ],
        "description": "The card's id and, where shown, its printed card ID."
      },
      "CustomerIds": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "external_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ExternalId"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "external_id"
        ],
        "description": "This connection's `external_id`, if it set one."
      },
      "ProgramIds": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "$ref": "#/components/schemas/CardType"
          }
        },
        "required": [
          "id",
          "type"
        ]
      },
      "CardType": {
        "type": "string",
        "enum": [
          "stamps",
          "points",
          "coupon",
          "prepaid",
          "membership",
          "tiers"
        ],
        "description": "`tiers` is the VIP card; `prepaid` the prepaid card."
      },
      "Source": {
        "type": "string",
        "enum": [
          "counter",
          "integration",
          "system"
        ],
        "description": "Who wrote it: the shop's till (portal or app), an integration (this one or another of the shop's), or Passkaar itself (expiry, a sweep, a template change)."
      },
      "CardClaimedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "card.claimed"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "wallet": {
                "$ref": "#/components/schemas/Wallet"
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "wallet"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "Wallet": {
        "type": "string",
        "enum": [
          "apple",
          "google"
        ]
      },
      "CardRemovedFromWalletEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "card.removed_from_wallet"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "wallet": {
                "$ref": "#/components/schemas/Wallet"
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "wallet"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "AwardCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "award.created"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "award": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              },
              "earned": {
                "$ref": "#/components/schemas/Value"
              },
              "balance": {
                "$ref": "#/components/schemas/CardBalance"
              },
              "occurred_at": {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              "source": {
                "$ref": "#/components/schemas/Source"
              },
              "branch_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uuid"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The branch it happened at, if any."
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "award",
              "earned",
              "balance",
              "occurred_at",
              "source",
              "branch_id"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "Value": {
        "type": "object",
        "properties": {
          "stamps": {
            "type": "integer"
          },
          "rewards": {
            "description": "Stamp-card rewards.",
            "type": "integer"
          },
          "points": {
            "type": "integer"
          },
          "rupees": {
            "description": "A prepaid card's own rupees.",
            "type": "number"
          },
          "bonus_rupees": {
            "description": "A prepaid top-up's bonus, on top of `rupees`.",
            "type": "number"
          },
          "value_rupees": {
            "description": "What points spent on a cash-back points card are worth off the bill, for the caller's discount line.",
            "type": "number"
          },
          "sessions": {
            "type": "integer"
          },
          "deals": {
            "description": "Coupon deals.",
            "type": "integer"
          },
          "qualifying": {
            "description": "Towards a VIP card's tier, in the card's measure: visits, or whole rupees of spend.",
            "type": "integer"
          },
          "paid_through": {
            "description": "A membership renewed to this day.",
            "type": "string",
            "format": "date"
          }
        },
        "description": "An amount in the card's own units. Only the keys its type counts in are present; a check-in is `{}`."
      },
      "CardBalance": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "stamps"
              },
              "stamps": {
                "type": "integer"
              },
              "stamps_total": {
                "type": "integer"
              },
              "rewards_ready": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "stamps",
              "stamps_total",
              "rewards_ready"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "points"
              },
              "points": {
                "type": "integer"
              },
              "unit_name": {
                "type": "string",
                "description": "What the shop calls its points."
              },
              "next_reward": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "key": {
                        "description": "A points card's catalogue key; null on stamps.",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "name": {
                        "type": "string"
                      },
                      "to_go": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "key",
                      "name",
                      "to_go"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "On a catalogue card, the nearest reward not yet affordable."
              },
              "expiring": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "points": {
                        "type": "integer"
                      },
                      "on": {
                        "type": "string",
                        "format": "date",
                        "description": "A calendar day in Pakistan (UTC+5), `YYYY-MM-DD`."
                      }
                    },
                    "required": [
                      "points",
                      "on"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The next points to lapse, where the card lets points lapse."
              }
            },
            "required": [
              "type",
              "points",
              "unit_name",
              "next_reward",
              "expiring"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "prepaid"
              },
              "rupees": {
                "type": "number",
                "description": "Rupees, with at most two decimals where the till wrote paisa."
              }
            },
            "required": [
              "type",
              "rupees"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "coupon"
              },
              "state": {
                "type": "string",
                "enum": [
                  "scheduled",
                  "available",
                  "wrong_day",
                  "used_up",
                  "expired"
                ]
              },
              "uses_left": {
                "type": "integer"
              }
            },
            "required": [
              "type",
              "state",
              "uses_left"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "membership"
              },
              "status": {
                "type": "string",
                "enum": [
                  "not_started",
                  "active",
                  "grace",
                  "lapsed",
                  "empty"
                ]
              },
              "plan": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "key",
                      "name"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "paid_through": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date",
                    "description": "A calendar day in Pakistan (UTC+5), `YYYY-MM-DD`."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "sessions_left": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "type",
              "status",
              "plan",
              "paid_through",
              "sessions_left"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "tiers"
              },
              "tier": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "key",
                  "name"
                ]
              },
              "qualifying": {
                "type": "integer"
              },
              "next_tier": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "to_go": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "key",
                      "name",
                      "to_go"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Null at the top tier."
              }
            },
            "required": [
              "type",
              "tier",
              "qualifying",
              "next_tier"
            ]
          }
        ],
        "description": "The card's standing after the call, by its type.",
        "type": "object"
      },
      "AwardReversedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "award.reversed"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "reversal": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              },
              "award": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              },
              "kind": {
                "type": "string",
                "enum": [
                  "full",
                  "partial"
                ]
              },
              "reversed": {
                "$ref": "#/components/schemas/Value"
              },
              "shortfall": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Value"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "balance": {
                "$ref": "#/components/schemas/CardBalance"
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "reversal",
              "award",
              "kind",
              "reversed",
              "shortfall",
              "balance"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "RewardUnlockedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "reward.unlocked"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "reward": {
                "$ref": "#/components/schemas/UnlockedReward"
              },
              "award": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "reward",
              "award"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "UnlockedReward": {
        "type": "object",
        "properties": {
          "key": {
            "description": "A points card's catalogue key; null on stamps.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "name"
        ]
      },
      "RedemptionCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "redemption.created"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "redemption": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              },
              "spent": {
                "$ref": "#/components/schemas/Value"
              },
              "balance": {
                "$ref": "#/components/schemas/CardBalance"
              },
              "occurred_at": {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              "source": {
                "$ref": "#/components/schemas/Source"
              },
              "branch_id": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "uuid"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The branch it happened at, if any."
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "redemption",
              "spent",
              "balance",
              "occurred_at",
              "source",
              "branch_id"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "BalanceExpiredEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "balance.expired"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "expired": {
                "$ref": "#/components/schemas/Value"
              },
              "balance": {
                "$ref": "#/components/schemas/CardBalance"
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "expired",
              "balance"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "RefundUnresolvedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "refund.unresolved"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "award": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              },
              "reversal": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              },
              "shortfall": {
                "$ref": "#/components/schemas/Value"
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "award",
              "reversal",
              "shortfall"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "CustomerErasedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "customer.erased"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              }
            },
            "required": [
              "customer"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "ConnectionRevokedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "connection.revoked"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "connection": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              },
              "revoked_at": {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              }
            },
            "required": [
              "connection",
              "revoked_at"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "WebhookTestEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "webhook.test"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "endpoint": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              }
            },
            "required": [
              "endpoint"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "HoldCreatedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "hold.created"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "hold": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              },
              "held": {
                "$ref": "#/components/schemas/Value"
              },
              "expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "hold",
              "held",
              "expires_at"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "HoldConfirmedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "hold.confirmed"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "hold": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              },
              "redemption": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "hold",
              "redemption"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "HoldReleasedEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "hold.released"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "hold": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "hold"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "HoldExpiredEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The event id, sent as `webhook-id`."
          },
          "type": {
            "type": "string",
            "const": "hold.expired"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "When it happened."
          },
          "data": {
            "type": "object",
            "properties": {
              "card": {
                "$ref": "#/components/schemas/CardIds"
              },
              "customer": {
                "$ref": "#/components/schemas/CustomerIds"
              },
              "program": {
                "$ref": "#/components/schemas/ProgramIds"
              },
              "hold": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/Reference"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "This connection's reference, when it wrote the row; otherwise null."
                  }
                },
                "required": [
                  "id",
                  "reference"
                ]
              }
            },
            "required": [
              "card",
              "customer",
              "program",
              "hold"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "timestamp",
          "data"
        ]
      },
      "ProgramList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProgramSummary"
            }
          },
          "next_cursor": {
            "description": "Null on the last page. Opaque, and only good for this list.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "ProgramSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/CardType"
          },
          "accepting_sign_ups": {
            "type": "boolean",
            "description": "False while the card is paused, its sign-up cap is reached or it has ended; `POST /enrolments` then answers `program_closed`."
          },
          "join_url": {
            "type": "string",
            "format": "uri",
            "description": "The printed join link, `https://passkaar.com/j/…`."
          },
          "ends_on": {
            "anyOf": [
              {
                "type": "string",
                "format": "date",
                "description": "A calendar day in Pakistan (UTC+5), `YYYY-MM-DD`."
              },
              {
                "type": "null"
              }
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "accepting_sign_ups",
          "join_url",
          "ends_on",
          "updated_at"
        ]
      },
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "`https://passkaar.com/developers/errors/{code}`: the code's documentation."
          },
          "title": {
            "type": "string",
            "description": "The same for every occurrence of a code."
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "description": "This occurrence, in words for a developer. Never parse it.",
            "type": "string"
          },
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "request_id": {
            "type": "string",
            "description": "The `X-Request-Id` this answer carried."
          },
          "errors": {
            "description": "With `invalid_request` and `invalid_answers`: each field refused.",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "description": "A JSON Pointer into the request body."
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "path",
                "message"
              ]
            }
          },
          "reason": {
            "description": "With `program_closed`.",
            "type": "string",
            "enum": [
              "unpublished",
              "not_accepting",
              "ended",
              "all_claimed"
            ]
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "code",
          "request_id"
        ],
        "description": "RFC 9457 Problem Details, served as `application/problem+json`."
      },
      "ErrorCode": {
        "type": "string",
        "enum": [
          "invalid_request",
          "unauthorized",
          "shop_locked",
          "not_found",
          "ambiguous",
          "card_in_wallet",
          "external_id_taken",
          "already_reversed",
          "request_in_progress",
          "hold_not_open",
          "previous_secret_active",
          "idempotency_key_reused",
          "reference_reused",
          "invalid_answers",
          "program_closed",
          "customer_limit_reached",
          "card_not_active",
          "operation_not_allowed",
          "give_required",
          "card_required",
          "insufficient_balance",
          "daily_cap_reached",
          "bill_too_large",
          "give_limit_reached",
          "invalid_occurred_at",
          "reversal_exceeds_award",
          "opening_balance_not_allowed",
          "webhook_url_not_allowed",
          "rate_limited",
          "internal_error",
          "unavailable"
        ]
      },
      "Program": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/CardType"
          },
          "accepting_sign_ups": {
            "type": "boolean",
            "description": "False while the card is paused, its sign-up cap is reached or it has ended; `POST /enrolments` then answers `program_closed`."
          },
          "join_url": {
            "type": "string",
            "format": "uri",
            "description": "The printed join link, `https://passkaar.com/j/…`."
          },
          "ends_on": {
            "anyOf": [
              {
                "type": "string",
                "format": "date",
                "description": "A calendar day in Pakistan (UTC+5), `YYYY-MM-DD`."
              },
              {
                "type": "null"
              }
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "rules": {
            "$ref": "#/components/schemas/ProgramRules"
          },
          "form": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormField"
            }
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "accepting_sign_ups",
          "join_url",
          "ends_on",
          "updated_at",
          "rules",
          "form"
        ]
      },
      "ProgramRules": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "stamps"
              },
              "stamps_total": {
                "type": "integer"
              },
              "reward": {
                "description": "The shop's words for the reward.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "most_per_visit": {
                "type": "integer"
              },
              "daily_cap": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "type",
              "stamps_total",
              "reward",
              "most_per_visit",
              "daily_cap"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "points"
              },
              "unit_name": {
                "type": "string"
              },
              "earn": {
                "type": "object",
                "properties": {
                  "points": {
                    "type": "integer"
                  },
                  "per_rupees": {
                    "type": "integer"
                  },
                  "min_bill": {
                    "anyOf": [
                      {
                        "type": "number",
                        "description": "Rupees, with at most two decimals where the till wrote paisa."
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "points",
                  "per_rupees",
                  "min_bill"
                ]
              },
              "daily_cap": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "spend": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "free"
                      }
                    },
                    "required": [
                      "mode"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "catalogue"
                      },
                      "rewards": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "key": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "cost": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "key",
                            "name",
                            "cost"
                          ]
                        }
                      }
                    },
                    "required": [
                      "mode",
                      "rewards"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "mode": {
                        "type": "string",
                        "const": "cash"
                      },
                      "rupees_per_point": {
                        "type": "number",
                        "description": "Rupees, with at most two decimals where the till wrote paisa."
                      },
                      "min_points": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "mode",
                      "rupees_per_point",
                      "min_points"
                    ]
                  }
                ],
                "type": "object"
              }
            },
            "required": [
              "type",
              "unit_name",
              "earn",
              "daily_cap",
              "spend"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "prepaid"
              },
              "min_load": {
                "anyOf": [
                  {
                    "type": "number",
                    "description": "Rupees, with at most two decimals where the till wrote paisa."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "max_load": {
                "anyOf": [
                  {
                    "type": "number",
                    "description": "Rupees, with at most two decimals where the till wrote paisa."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "max_balance": {
                "anyOf": [
                  {
                    "type": "number",
                    "description": "Rupees, with at most two decimals where the till wrote paisa."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "reloadable": {
                "type": "boolean"
              },
              "load_bonus": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "load_at_least": {
                        "type": "number",
                        "description": "Rupees, with at most two decimals where the till wrote paisa."
                      },
                      "bonus_percent": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "load_at_least",
                      "bonus_percent"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "type",
              "min_load",
              "max_load",
              "max_balance",
              "reloadable",
              "load_bonus"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "coupon"
              },
              "offer": {
                "description": "The offer in the shop’s words.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "min_spend": {
                "anyOf": [
                  {
                    "type": "number",
                    "description": "Rupees, with at most two decimals where the till wrote paisa."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "deals_per_bill": {
                "type": "integer"
              },
              "items": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "A deal's items; empty on other offers."
              },
              "uses_per_customer": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "valid_from": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date",
                    "description": "A calendar day in Pakistan (UTC+5), `YYYY-MM-DD`."
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "type",
              "offer",
              "min_spend",
              "deals_per_bill",
              "items",
              "uses_per_customer",
              "valid_from"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "membership"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "period",
                  "sessions",
                  "free"
                ]
              },
              "plans": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "price": {
                      "anyOf": [
                        {
                          "type": "number",
                          "description": "Rupees, with at most two decimals where the till wrote paisa."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "length": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "unit": {
                              "type": "string",
                              "enum": [
                                "day",
                                "month",
                                "year"
                              ]
                            },
                            "count": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "unit",
                            "count"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sessions": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "key",
                    "name",
                    "price",
                    "length",
                    "sessions"
                  ]
                }
              },
              "services": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "key",
                    "name"
                  ]
                }
              },
              "check_ins": {
                "type": "boolean",
                "description": "Whether the card takes check-ins (ADR 0125)."
              }
            },
            "required": [
              "type",
              "mode",
              "plans",
              "services",
              "check_ins"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "tiers"
              },
              "measure": {
                "type": "string",
                "enum": [
                  "visits",
                  "spend"
                ]
              },
              "window": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "lifetime"
                      }
                    },
                    "required": [
                      "kind"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "rolling"
                      },
                      "months": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "kind",
                      "months"
                    ]
                  }
                ],
                "type": "object"
              },
              "tiers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "threshold": {
                      "type": "integer"
                    },
                    "perks": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "key",
                    "name",
                    "threshold",
                    "perks"
                  ]
                }
              },
              "min_bill": {
                "anyOf": [
                  {
                    "type": "number",
                    "description": "Rupees, with at most two decimals where the till wrote paisa."
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "type",
              "measure",
              "window",
              "tiers",
              "min_bill"
            ]
          }
        ],
        "description": "The card's rules, by its type.",
        "type": "object"
      },
      "FormField": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "The key its answer goes under in `answers`."
          },
          "type": {
            "type": "string",
            "enum": [
              "first_name",
              "last_name",
              "phone",
              "email",
              "date_of_birth",
              "gender",
              "options",
              "text",
              "number",
              "url"
            ]
          },
          "label": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "dedupe_key": {
            "type": "boolean",
            "description": "The phone or email that identifies a customer on this card. Exactly one field has it, and `POST /enrolments` needs it with the first name. Another required field the caller does not hold is asked on the claim page."
          },
          "options": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "For `options` and `gender`."
          }
        },
        "required": [
          "key",
          "type",
          "label",
          "required",
          "dedupe_key",
          "options"
        ]
      },
      "BranchList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Branch"
            }
          },
          "next_cursor": {
            "description": "Null on the last page. Opaque, and only good for this list.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "Branch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "name",
          "city",
          "active"
        ]
      },
      "Enrolment": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "enum": [
              "created",
              "already_member"
            ],
            "description": "`already_member`: the customer already holds this card. Nothing new is made; `external_id` is linked to them, and the answer is 200 rather than 201. That link was made from a phone or email alone: it earns, it does not spend, and `card.card_id` is null."
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerIds"
          },
          "card": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "card_id": {
                "examples": [
                  "PK7-4M2-9XQ"
                ],
                "description": "The printed card ID, only when the call named the card by `serial` or `card_id`, the call made the card (a `created` sign-up), or this connection’s `external_id` was linked with the card. Null when the card was found by phone, email or an unproven link.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "in_wallet": {
                "type": "boolean"
              },
              "claimable": {
                "type": "boolean",
                "description": "True while this connection made the card and it has never been in a wallet. A lost card is re-handed only at the till."
              }
            },
            "required": [
              "id",
              "card_id",
              "in_wallet",
              "claimable"
            ]
          },
          "claim": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ClaimLink"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null on `already_member` for a card this connection did not make: a phone or email alone never hands out a card, and such a card goes onto a phone only at the till."
          }
        },
        "required": [
          "result",
          "customer",
          "card",
          "claim"
        ]
      },
      "ClaimLink": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Open on the customer’s phone; on a desktop it shows a QR to continue there. Dead once the card is in a wallet."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Seven days from when it was made."
          }
        },
        "required": [
          "url",
          "expires_at"
        ]
      },
      "CardLink": {
        "type": "object",
        "properties": {
          "card": {
            "$ref": "#/components/schemas/CardIds"
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerIds"
          }
        },
        "required": [
          "card",
          "customer"
        ]
      },
      "CardLookup": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Card"
            },
            "description": "Every card the matched customer holds in this shop, or the one card named."
          }
        },
        "required": [
          "data"
        ]
      },
      "Card": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "card_id": {
            "examples": [
              "PK7-4M2-9XQ"
            ],
            "description": "The printed card ID, only when the call named the card by `serial` or `card_id`, the call made the card (a `created` sign-up), or this connection’s `external_id` was linked with the card. Null when the card was found by phone, email or an unproven link.",
            "type": [
              "string",
              "null"
            ]
          },
          "program": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "type": {
                "$ref": "#/components/schemas/CardType"
              }
            },
            "required": [
              "id",
              "name",
              "type"
            ]
          },
          "customer": {
            "$ref": "#/components/schemas/CardCustomer"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "revoked"
            ]
          },
          "ended_on": {
            "anyOf": [
              {
                "type": "string",
                "format": "date",
                "description": "A calendar day in Pakistan (UTC+5), `YYYY-MM-DD`."
              },
              {
                "type": "null"
              }
            ],
            "description": "Set once the card has ended; a banked reward may still be given."
          },
          "in_wallet": {
            "type": "boolean",
            "description": "In Apple or Google Wallet now."
          },
          "wallets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Wallet"
            },
            "description": "Where it is now."
          },
          "claimable": {
            "type": "boolean",
            "description": "Made by this connection’s own sign-up and never yet in a wallet, so `POST /cards/{id}/claim-link` may hand out a fresh link."
          },
          "issued_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "last_activity_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              {
                "type": "null"
              }
            ]
          },
          "balance": {
            "$ref": "#/components/schemas/CardBalance"
          }
        },
        "required": [
          "id",
          "card_id",
          "program",
          "customer",
          "status",
          "ended_on",
          "in_wallet",
          "wallets",
          "claimable",
          "issued_at",
          "last_activity_at",
          "balance"
        ]
      },
      "CardCustomer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "first_name": {
            "type": "string"
          },
          "phone_masked": {
            "examples": [
              "+92 300 •••••••"
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "email_masked": {
            "examples": [
              "•••@example.com"
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "external_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ExternalId"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "first_name",
          "phone_masked",
          "email_masked",
          "external_id"
        ],
        "description": "Never the full phone or email (ADR 0168)."
      },
      "CardTransactionList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CardTransaction"
            }
          },
          "next_cursor": {
            "description": "Null on the last page. Opaque, and only good for this list.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "CardTransaction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "award",
              "redemption",
              "top_up",
              "deduction",
              "check_in",
              "adjustment",
              "expiry",
              "reversal"
            ]
          },
          "change": {
            "additionalProperties": false,
            "description": "Signed: positive for value in, negative for value out; `{}` for a check-in.",
            "$ref": "#/components/schemas/Value"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "branch": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "reference": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Reference"
              },
              {
                "type": "null"
              }
            ],
            "description": "This connection's own reference; null on every other row."
          },
          "reversed_by": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "description": "The undo that took this whole row back, made by the shop in its portal. A refund through `POST /awards/{reference}/reverse` never sets it: each is its own `reversal` row whose `reverses` names this one."
          },
          "reverses": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "description": "On a reversal or undo, the row it took back."
          }
        },
        "required": [
          "id",
          "kind",
          "change",
          "occurred_at",
          "recorded_at",
          "branch",
          "source",
          "reference",
          "reversed_by",
          "reverses"
        ]
      },
      "Award": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "$ref": "#/components/schemas/Reference"
          },
          "card": {
            "$ref": "#/components/schemas/CardIds"
          },
          "type": {
            "$ref": "#/components/schemas/CardType"
          },
          "earned": {
            "$ref": "#/components/schemas/Value"
          },
          "balance": {
            "$ref": "#/components/schemas/CardBalance"
          },
          "rewards_unlocked": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnlockedReward"
            },
            "description": "Rewards this award made ready: a full stamp card, a catalogue reward."
          },
          "tier_reached": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "key",
                  "name"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "A VIP card that rose a tier with this award."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "replayed": {
            "type": "boolean",
            "description": "True when this answers a reference or idempotency key already used."
          }
        },
        "required": [
          "id",
          "reference",
          "card",
          "type",
          "earned",
          "balance",
          "rewards_unlocked",
          "tier_reached",
          "occurred_at",
          "recorded_at",
          "replayed"
        ],
        "description": "201 when made; 200 with `replayed: true` for a reference already used."
      },
      "Reversal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "award": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "reference": {
                "$ref": "#/components/schemas/Reference"
              }
            },
            "required": [
              "id",
              "reference"
            ]
          },
          "card": {
            "$ref": "#/components/schemas/CardIds"
          },
          "kind": {
            "type": "string",
            "enum": [
              "full",
              "partial"
            ]
          },
          "reversed": {
            "additionalProperties": false,
            "description": "What was taken back.",
            "$ref": "#/components/schemas/Value"
          },
          "shortfall": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Value"
              },
              {
                "type": "null"
              }
            ],
            "description": "What could not be taken back because it was already spent. Never below zero; `refund.unresolved` is sent for it."
          },
          "balance": {
            "$ref": "#/components/schemas/CardBalance"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "replayed": {
            "type": "boolean",
            "description": "True when this answers a reference or idempotency key already used."
          }
        },
        "required": [
          "id",
          "award",
          "card",
          "kind",
          "reversed",
          "shortfall",
          "balance",
          "occurred_at",
          "recorded_at",
          "replayed"
        ]
      },
      "Redemption": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "$ref": "#/components/schemas/Reference"
          },
          "card": {
            "$ref": "#/components/schemas/CardIds"
          },
          "type": {
            "$ref": "#/components/schemas/CardType"
          },
          "spent": {
            "$ref": "#/components/schemas/Value"
          },
          "balance": {
            "$ref": "#/components/schemas/CardBalance"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "replayed": {
            "type": "boolean",
            "description": "True when this answers a reference or idempotency key already used."
          }
        },
        "required": [
          "id",
          "reference",
          "card",
          "type",
          "spent",
          "balance",
          "occurred_at",
          "recorded_at",
          "replayed"
        ],
        "description": "201 when made; 200 with `replayed: true` for a reference already used."
      },
      "Hold": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "reference": {
            "$ref": "#/components/schemas/Reference"
          },
          "card": {
            "$ref": "#/components/schemas/CardIds"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "confirmed",
              "released",
              "expired"
            ]
          },
          "held": {
            "$ref": "#/components/schemas/Value"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "When an open hold lapses: 15 minutes after it was made."
          },
          "available": {
            "description": "The balance less every open hold.",
            "$ref": "#/components/schemas/CardBalance"
          },
          "redemption": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "id"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Once confirmed, the redemption it became."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "replayed": {
            "type": "boolean",
            "description": "True when this answers a reference or idempotency key already used."
          }
        },
        "required": [
          "id",
          "reference",
          "card",
          "status",
          "held",
          "expires_at",
          "available",
          "redemption",
          "created_at",
          "replayed"
        ]
      },
      "EventList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "next_cursor": {
            "description": "Where to read on from. Null only before there is any event. A page shorter than `limit` means you have caught up: keep this cursor and ask again later. An event joins the feed about ten seconds after it is recorded.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "Event": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/CardCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/CardClaimedEvent"
          },
          {
            "$ref": "#/components/schemas/CardRemovedFromWalletEvent"
          },
          {
            "$ref": "#/components/schemas/AwardCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/AwardReversedEvent"
          },
          {
            "$ref": "#/components/schemas/RewardUnlockedEvent"
          },
          {
            "$ref": "#/components/schemas/RedemptionCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/BalanceExpiredEvent"
          },
          {
            "$ref": "#/components/schemas/RefundUnresolvedEvent"
          },
          {
            "$ref": "#/components/schemas/CustomerErasedEvent"
          },
          {
            "$ref": "#/components/schemas/ConnectionRevokedEvent"
          },
          {
            "$ref": "#/components/schemas/WebhookTestEvent"
          },
          {
            "$ref": "#/components/schemas/HoldCreatedEvent"
          },
          {
            "$ref": "#/components/schemas/HoldConfirmedEvent"
          },
          {
            "$ref": "#/components/schemas/HoldReleasedEvent"
          },
          {
            "$ref": "#/components/schemas/HoldExpiredEvent"
          }
        ],
        "description": "A Standard Webhooks envelope: `type`, `timestamp`, `data`.",
        "type": "object",
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "card.created": "#/components/schemas/CardCreatedEvent",
            "card.claimed": "#/components/schemas/CardClaimedEvent",
            "card.removed_from_wallet": "#/components/schemas/CardRemovedFromWalletEvent",
            "award.created": "#/components/schemas/AwardCreatedEvent",
            "award.reversed": "#/components/schemas/AwardReversedEvent",
            "reward.unlocked": "#/components/schemas/RewardUnlockedEvent",
            "redemption.created": "#/components/schemas/RedemptionCreatedEvent",
            "balance.expired": "#/components/schemas/BalanceExpiredEvent",
            "refund.unresolved": "#/components/schemas/RefundUnresolvedEvent",
            "customer.erased": "#/components/schemas/CustomerErasedEvent",
            "connection.revoked": "#/components/schemas/ConnectionRevokedEvent",
            "webhook.test": "#/components/schemas/WebhookTestEvent",
            "hold.created": "#/components/schemas/HoldCreatedEvent",
            "hold.confirmed": "#/components/schemas/HoldConfirmedEvent",
            "hold.released": "#/components/schemas/HoldReleasedEvent",
            "hold.expired": "#/components/schemas/HoldExpiredEvent"
          }
        }
      },
      "WebhookEndpointList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEndpoint"
            }
          },
          "next_cursor": {
            "description": "Null on the last page. Opaque, and only good for this list.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "next_cursor"
        ]
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventType"
            }
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "disabled_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "failing",
                  "owner",
                  "passkaar"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "`failing`: deliveries failed for about three days and the owner was told. `owner` or `passkaar`: switched off by hand."
          },
          "last_success_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              {
                "type": "null"
              }
            ]
          },
          "last_failure_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "description",
          "enabled",
          "disabled_reason",
          "last_success_at",
          "last_failure_at",
          "created_at"
        ]
      },
      "WebhookEndpointCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventType"
            }
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "disabled_reason": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "failing",
                  "owner",
                  "passkaar"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "`failing`: deliveries failed for about three days and the owner was told. `owner` or `passkaar`: switched off by hand."
          },
          "last_success_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              {
                "type": "null"
              }
            ]
          },
          "last_failure_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339. Answers are in UTC; requests may carry any offset."
          },
          "secret": {
            "type": "string",
            "pattern": "^whsec_[A-Za-z0-9+/=]+$",
            "description": "Shown once. Store it on your server."
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "description",
          "enabled",
          "disabled_reason",
          "last_success_at",
          "last_failure_at",
          "created_at",
          "secret"
        ]
      },
      "WebhookTestSent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "event_id"
        ],
        "description": "A test delivery was queued from the outbox."
      },
      "WebhookSecretRolled": {
        "type": "object",
        "properties": {
          "secret": {
            "type": "string",
            "pattern": "^whsec_[A-Za-z0-9+/=]+$",
            "description": "Shown once. Store it on your server."
          },
          "previous_expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Until then each delivery carries both signatures."
          }
        },
        "required": [
          "secret",
          "previous_expires_at"
        ]
      }
    },
    "headers": {
      "RequestId": {
        "required": true,
        "description": "Quote it to Passkaar support.",
        "schema": {
          "type": "string",
          "description": "Quote it to Passkaar support."
        }
      },
      "RetryAfter": {
        "required": true,
        "description": "Seconds to wait before trying again.",
        "schema": {
          "type": "string",
          "description": "Seconds to wait before trying again."
        }
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "in": "header",
        "name": "Idempotency-Key",
        "schema": {
          "description": "Any 1–255 visible ASCII characters, a UUID by preference. A retry with the same key within 24 hours answers the first result. `reference` is what guards a resend after that.",
          "type": "string",
          "pattern": "^[!-~]{1,255}$"
        },
        "description": "Any 1–255 visible ASCII characters, a UUID by preference. A retry with the same key within 24 hours answers the first result. `reference` is what guards a resend after that."
      }
    },
    "securitySchemes": {
      "integrationKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "psk_live_… or psk_test_…",
        "description": "A key from the portal, Settings → Integrations. On a server only."
      }
    }
  }
}
