{
  "openapi": "3.1.0",
  "info": {
    "title": "YOUth Public API",
    "version": "1",
    "description": "The API partners' servers call, under `/v1`, with an OAuth access token their client credentials get."
  },
  "servers": [
    {
      "url": "https://api.youth-platform.io"
    }
  ],
  "tags": [
    {
      "name": "organization",
      "description": "The organization an integration's credentials belong to, and the integration itself."
    },
    {
      "name": "access codes",
      "description": "Batches of access codes your organization orders, and the codes in them: each gives one person access to YOU(th), and names no one."
    },
    {
      "name": "webhooks",
      "description": "Your organization's webhook endpoints: the HTTPS addresses YOU(th) sends signed events to, each with its own signing secret and the events it receives."
    }
  ],
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://auth.youth-platform.io/realms/youth/protocol/openid-connect/token",
            "scopes": {
              "access_codes:read": "Read batches and codes",
              "access_codes:write": "Order batches, block a code, end an access",
              "webhooks:write": "Create, read and disable webhook endpoints",
              "checkups:read": "Read checkups",
              "patients:read": "Read members"
            }
          }
        }
      }
    },
    "schemas": {
      "AccessCodeRedeemed": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "pattern": "^evt_[0-9a-f]{32}$",
            "example": "evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c"
          },
          "event_type": {
            "type": "string",
            "enum": [
              "AccessCode.redeemed"
            ],
            "example": "AccessCode.redeemed"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-12T09:30:00.375000Z"
          },
          "resource_url": {
            "type": "string",
            "format": "uri",
            "example": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
          },
          "access_code_id": {
            "type": "string",
            "format": "uuid",
            "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
          },
          "batch_id": {
            "type": "string",
            "format": "uuid",
            "example": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
          }
        },
        "required": [
          "event_id",
          "event_type",
          "occurred_at",
          "resource_url",
          "access_code_id",
          "batch_id"
        ]
      },
      "AccessEnded": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "pattern": "^evt_[0-9a-f]{32}$",
            "example": "evt_3b9f2c1a7d4e4f6a8c5b0e1d2f3a4b5c"
          },
          "event_type": {
            "type": "string",
            "enum": [
              "Access.ended"
            ],
            "example": "Access.ended"
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-12T09:30:00.375000Z"
          },
          "resource_url": {
            "type": "string",
            "format": "uri",
            "example": "https://api.youth-platform.io/v1/access-codes/0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
          },
          "access_code_id": {
            "type": "string",
            "format": "uuid",
            "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
          },
          "batch_id": {
            "type": "string",
            "format": "uuid",
            "example": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
          },
          "reason": {
            "type": "string",
            "enum": [
              "ended_by_partner",
              "term_over"
            ],
            "example": "ended_by_partner"
          }
        },
        "required": [
          "event_id",
          "event_type",
          "occurred_at",
          "resource_url",
          "access_code_id",
          "batch_id",
          "reason"
        ]
      },
      "CurrentOrganization": {
        "type": "object",
        "properties": {
          "organization": {
            "type": "object",
            "properties": {
              "alias": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255,
                "description": "The organization's alias, which never changes.",
                "example": "example-clinic"
              },
              "name": {
                "type": "string",
                "description": "The organization's name.",
                "example": "Example Clinic"
              }
            },
            "required": [
              "alias",
              "name"
            ],
            "description": "The organization the credentials belong to."
          },
          "integration": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "The integration's id.",
                "example": "3f2b8c1e-9a47-4d65-b0e2-7c1a5d9e4f08"
              },
              "name": {
                "type": "string",
                "description": "The name its admins gave it.",
                "example": "Billing"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "The OAuth scopes the calling token holds, in the catalogue's order. Today: access_codes:read, access_codes:write, webhooks:write, checkups:read, patients:read. A scope added later appears here without a new version, so read each as text.",
                "example": [
                  "access_codes:read"
                ]
              }
            },
            "required": [
              "id",
              "name",
              "scopes"
            ],
            "description": "The integration calling."
          }
        },
        "required": [
          "organization",
          "integration"
        ],
        "description": "The organization the credentials belong to, and the integration calling: what a partner reads to check new credentials."
      },
      "Problem": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "about:blank"
            ],
            "description": "Always `about:blank`: the status and `code` say what happened.",
            "example": "about:blank"
          },
          "title": {
            "type": "string",
            "description": "The status's English name, for logs; match on `code` instead.",
            "example": "Unauthorized"
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status of the answer.",
            "example": 401
          },
          "code": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$",
            "description": "What happened, stable and in snake_case; clients translate it. Codes can be added within v1, so a client treats a code it doesn't know by the HTTP status.",
            "example": "invalid_token"
          },
          "request_id": {
            "type": "string",
            "description": "The request's id, as the logs name it.",
            "example": "7f3c2a9e-5b1d-4c6a-9e0f-2d8b4a1c6e53"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "code",
          "request_id"
        ]
      },
      "AccessCodeBatch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The batch's id: what its codes and the other routes name.",
            "example": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
          },
          "label": {
            "type": "string",
            "description": "The name of yours the order gave it.",
            "example": "december-2026"
          },
          "status": {
            "type": "string",
            "enum": [
              "creating",
              "ready",
              "failed"
            ],
            "description": "`ready` once every code can be read and redeemed, which an order answers with. `creating` while an order that answered `503` hasn't been sent again; `failed` when none was within a day, and then none of its codes is listed or billed.",
            "example": "ready"
          },
          "count": {
            "type": "integer",
            "description": "How many codes it holds.",
            "example": 1000
          },
          "redeem_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The last moment one of its codes can be redeemed; none for no end.",
            "example": "2027-12-31T23:59:59.000Z"
          },
          "access": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FixedDaysAccess"
              },
              {
                "$ref": "#/components/schemas/UntilEndedAccess"
              }
            ],
            "description": "What a redeemed code grants.",
            "example": {
              "term": "until_ended"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was ordered.",
            "example": "2026-12-01T10:00:00.000Z"
          }
        },
        "required": [
          "id",
          "label",
          "status",
          "count",
          "redeem_by",
          "access",
          "created_at"
        ]
      },
      "FixedDaysAccess": {
        "type": "object",
        "properties": {
          "term": {
            "type": "string",
            "enum": [
              "fixed_days"
            ],
            "description": "Access for `days` days from the redemption, which then ends by itself.",
            "example": "fixed_days"
          },
          "days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650,
            "description": "How many days a redeemed code's access lasts.",
            "example": 30
          }
        },
        "required": [
          "term",
          "days"
        ]
      },
      "UntilEndedAccess": {
        "type": "object",
        "properties": {
          "term": {
            "type": "string",
            "enum": [
              "until_ended"
            ],
            "description": "Access until the organization ends it, for a service billed by period.",
            "example": "until_ended"
          }
        },
        "required": [
          "term"
        ]
      },
      "AccessCodeBatchOrder": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20000,
            "description": "How many codes, at most 20,000, and within your organization's daily limit: 1,000 codes a day unless YOU(th) raised it.",
            "example": 1000
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "A name of yours for the batch, such as the month or your order number. It is never shown to a customer.",
            "example": "december-2026"
          },
          "redeem_by": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The last moment a code of the batch can be redeemed, still to come and at most five years ahead; none for no end.",
            "example": "2027-12-31T23:59:59Z"
          },
          "access": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FixedDaysAccessOrder"
              },
              {
                "$ref": "#/components/schemas/UntilEndedAccessOrder"
              }
            ],
            "description": "What a redeemed code of the batch grants.",
            "example": {
              "term": "until_ended"
            }
          }
        },
        "required": [
          "count",
          "label",
          "access"
        ],
        "additionalProperties": false
      },
      "FixedDaysAccessOrder": {
        "type": "object",
        "properties": {
          "term": {
            "type": "string",
            "enum": [
              "fixed_days"
            ],
            "description": "Access for `days` days from the redemption, which then ends by itself.",
            "example": "fixed_days"
          },
          "days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650,
            "description": "How many days a redeemed code's access lasts.",
            "example": 30
          }
        },
        "required": [
          "term",
          "days"
        ],
        "additionalProperties": false
      },
      "UntilEndedAccessOrder": {
        "type": "object",
        "properties": {
          "term": {
            "type": "string",
            "enum": [
              "until_ended"
            ],
            "description": "Access until the organization ends it, for a service billed by period.",
            "example": "until_ended"
          }
        },
        "required": [
          "term"
        ],
        "additionalProperties": false
      },
      "AccessCodePage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccessCode"
            },
            "description": "The page's codes, in order of their ids.",
            "example": [
              {
                "id": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34",
                "batch_id": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21",
                "code": "482957362845",
                "redeem_url": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845",
                "status": "available",
                "redeemed_at": null,
                "access": {
                  "term": "until_ended",
                  "ends_at": null
                }
              }
            ]
          },
          "next": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Pass it as `after` to read the next page; none on the last.",
            "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
          }
        },
        "required": [
          "items",
          "next"
        ]
      },
      "AccessCode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The code's id: what events and the other routes name. Store it beside the code.",
            "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
          },
          "batch_id": {
            "type": "string",
            "format": "uuid",
            "description": "Its batch's id.",
            "example": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
          },
          "code": {
            "type": "string",
            "description": "What the customer types. An opaque string: store and show it exactly as it is, without spaces. A secret until redeemed.",
            "example": "482957362845"
          },
          "redeem_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "The link that redeems it in the YOU(th) app, with your organization and the code filled in: use it exactly as it is. Absent (`null`) when your organization's members redeem in an app of its own.",
            "example": "https://youthai.app.link/?~channel=partners&~feature=access_code&$partner_configuration_system_name=coopvoce&$access_code=482957362845"
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "redeemed",
              "ended",
              "deactivated",
              "expired"
            ],
            "description": "`available` until someone redeems it, then `redeemed`, then `ended` once its access has stopped; or `deactivated` once you block it, or `expired` past its batch's `redeem_by`.",
            "example": "available"
          },
          "redeemed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was redeemed; none until it is.",
            "example": null
          },
          "access": {
            "type": "object",
            "properties": {
              "term": {
                "type": "string",
                "enum": [
                  "fixed_days",
                  "until_ended"
                ],
                "description": "Its batch's term.",
                "example": "until_ended"
              },
              "ends_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "When its access ends or ended: the end you set, or a `fixed_days` code's last day once redeemed; none while no end is set.",
                "example": null
              }
            },
            "required": [
              "term",
              "ends_at"
            ],
            "description": "The access it grants, once redeemed."
          }
        },
        "required": [
          "id",
          "batch_id",
          "code",
          "redeem_url",
          "status",
          "redeemed_at",
          "access"
        ]
      },
      "AccessEndChange": {
        "type": "object",
        "properties": {
          "ends_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the access ends. A time to come ends it then; one that has passed, or none sent, ends it now; `null` undoes an end that hasn't passed, back to the code's own term.",
            "example": "2027-01-12T00:00:00Z"
          }
        },
        "additionalProperties": false
      },
      "CreatedWebhookEndpoint": {
        "allOf": [
          {
            "$ref": "#/components/schemas/WebhookEndpoint"
          },
          {
            "type": "object",
            "properties": {
              "signing_secret": {
                "type": "string",
                "description": "What your receiver verifies each delivery with: `whsec_` and its key. Only the create answers it, and a repeat of the create with the same `Idempotency-Key` within 24 hours; store it in your secret store at once.",
                "example": "whsec_Zm9vYmFyYmF6cXV4LWV4YW1wbGUtc2VjcmV0LXZhbHVl"
              }
            },
            "required": [
              "signing_secret"
            ]
          }
        ]
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint's id.",
            "example": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90"
          },
          "url": {
            "type": "string",
            "description": "Where its deliveries go.",
            "example": "https://partner.example.com/youth-webhook"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your note about it; none if you gave none.",
            "example": "Billing"
          },
          "event_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The events it receives, in alphabetical order.",
            "example": [
              "Access.ended",
              "AccessCode.redeemed"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused",
              "disabled"
            ],
            "description": "`active`: deliveries are sent. `paused`: YOU(th) stopped sending, because the address kept answering `404` or `410`. `disabled`: you stopped it.",
            "example": "active"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was created, in UTC.",
            "example": "2026-11-20T09:30:00.000Z"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it last changed, in UTC.",
            "example": "2026-11-20T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "url",
          "description",
          "event_types",
          "status",
          "created_at",
          "updated_at"
        ]
      },
      "WebhookEndpointRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048,
            "description": "Where deliveries go: an `https` address on port 443, without credentials, whose host resolves to public addresses when each delivery is sent.",
            "example": "https://partner.example.com/youth-webhook"
          },
          "event_types": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "minItems": 1,
            "maxItems": 20,
            "description": "The events it receives, by `event_type`; each named once is enough.",
            "example": [
              "AccessCode.redeemed",
              "Access.ended"
            ]
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "A note of yours about it, such as the system it feeds.",
            "example": "Billing"
          }
        },
        "required": [
          "url",
          "event_types"
        ],
        "additionalProperties": false
      },
      "WebhookEndpointPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEndpoint"
            },
            "description": "The page's endpoints, oldest first.",
            "example": [
              {
                "id": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90",
                "url": "https://partner.example.com/youth-webhook",
                "description": "Billing",
                "event_types": [
                  "Access.ended",
                  "AccessCode.redeemed"
                ],
                "status": "active",
                "created_at": "2026-11-20T09:30:00.000Z",
                "updated_at": "2026-11-20T09:30:00.000Z"
              }
            ]
          },
          "next": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Pass as `after` for the next page; none after the last.",
            "example": null
          }
        },
        "required": [
          "items",
          "next"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/v1/organization": {
      "get": {
        "operationId": "get_current_organization",
        "tags": [
          "organization"
        ],
        "summary": "The organization the credentials belong to, and the integration calling",
        "description": "Needs no particular scope, but the token must be requested with at least one granted scope, which gives it the API's audience: a partner calls it to check new credentials. The organization is the credentials', never the request's.",
        "security": [
          {
            "oauth2": []
          }
        ],
        "responses": {
          "200": {
            "description": "The organization and the integration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentOrganization"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/access-code-batches": {
      "post": {
        "operationId": "create_access_code_batch",
        "tags": [
          "access codes"
        ],
        "summary": "Order a batch of access codes",
        "description": "Makes `count` codes for your organization and answers `201` once every one can be read and redeemed. When that can't be finished now, it answers `503` with `Retry-After`: send the same order again, with the same `Idempotency-Key` and body, and it goes on with the same batch, never a second one. Your organization's batches ordered in one day, from 00:00 UTC, hold at most its daily limit of codes together: 1,000 unless YOU(th) raised it, on request. A repeat that goes on with a batch isn't counted again. Requires an `Idempotency-Key`. Needs `access_codes:write`.",
        "security": [
          {
            "oauth2": [
              "access_codes:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "A key of yours for the request, such as a UUID, at most 255 characters. The same key and body answer the first request again, and resume it after a `503`, for 24 hours after the latest attempt.",
              "example": "5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11"
            },
            "required": true,
            "description": "A key of yours for the request, such as a UUID, at most 255 characters. The same key and body answer the first request again, and resume it after a `503`, for 24 hours after the latest attempt.",
            "name": "idempotency-key",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccessCodeBatchOrder"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The batch, `ready`, at the address in `Location`.",
            "headers": {
              "location": {
                "schema": {
                  "type": "string"
                },
                "required": true,
                "description": "Where the batch is read.",
                "example": "/v1/access-code-batches/0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessCodeBatch"
                }
              }
            }
          },
          "400": {
            "description": "The body can't be parsed (`malformed_request`), the order has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "malformed_request",
                            "idempotency_key_required",
                            "idempotency_key_invalid"
                          ],
                          "example": "malformed_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "The key was used with another body (`idempotency_conflict`): use a new key. An order with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization isn't in the app yet, so no code could be redeemed (`app_not_set_up`): ask YOU(th).",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "idempotency_conflict",
                            "idempotency_in_progress",
                            "app_not_set_up"
                          ],
                          "example": "idempotency_conflict"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "The body is over the API's limit (`too_large`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "too_large"
                          ],
                          "example": "too_large"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "415": {
            "description": "The body isn't JSON (`unsupported_media_type`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "unsupported_media_type"
                          ],
                          "example": "unsupported_media_type"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing, not valid or not one the order takes (`invalid_request`), `redeem_by` has passed (`redeem_by_passed`) or is more than five years ahead (`redeem_by_too_far`), or the order would take your organization past its daily limit (`count_over_limit`): nothing was made.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request",
                            "redeem_by_passed",
                            "redeem_by_too_far",
                            "count_over_limit"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out",
                            "temporarily_unavailable"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/access-code-batches/{batch_id}": {
      "get": {
        "operationId": "get_access_code_batch",
        "tags": [
          "access codes"
        ],
        "summary": "Read a batch of access codes",
        "description": "One of your organization's batches. Needs `access_codes:read` or `access_codes:write`.",
        "security": [
          {
            "oauth2": [
              "access_codes:read"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The batch's id.",
              "example": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
            },
            "required": true,
            "description": "The batch's id.",
            "name": "batch_id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The batch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessCodeBatch"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No batch of yours has this id (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ],
                          "example": "not_found"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/access-codes": {
      "get": {
        "operationId": "list_access_codes",
        "tags": [
          "access codes"
        ],
        "summary": "List access codes",
        "description": "Your organization's codes of batches that are `ready`, that the filters keep, in a stable order. As JSON, a page at a time: pass a page's `next` as `after` for the next one. With `Accept: text/csv`, one CSV file of every code the filters keep, not paged, up to 50,000 codes. Needs `access_codes:read` or `access_codes:write`.",
        "security": [
          {
            "oauth2": [
              "access_codes:read"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The codes of one batch.",
              "example": "0193b1c0-11aa-7e02-8c55-9d3f0a7b6c21"
            },
            "required": false,
            "description": "The codes of one batch.",
            "name": "batch_id",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "available",
                "redeemed",
                "ended",
                "deactivated",
                "expired"
              ],
              "description": "The codes in one status.",
              "example": "redeemed"
            },
            "required": false,
            "description": "The codes in one status.",
            "name": "status",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "The codes redeemed at or after this time.",
              "example": "2026-12-01T00:00:00Z"
            },
            "required": false,
            "description": "The codes redeemed at or after this time.",
            "name": "redeemed_from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "The codes redeemed before this time.",
              "example": "2027-01-01T00:00:00Z"
            },
            "required": false,
            "description": "The codes redeemed before this time.",
            "name": "redeemed_to",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "The codes whose access ended at or after this time, and has ended by now: an end still ahead isn't kept.",
              "example": "2026-12-12T08:30:00Z"
            },
            "required": false,
            "description": "The codes whose access ended at or after this time, and has ended by now: an end still ahead isn't kept.",
            "name": "ended_from",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The next page: the `next` of the page before. Not with `Accept: text/csv`.",
              "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
            },
            "required": false,
            "description": "The next page: the `next` of the page before. Not with `Accept: text/csv`.",
            "name": "after",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "description": "How many codes a page holds, at most 1,000; 100 unless set. Not with `Accept: text/csv`.",
              "example": 100
            },
            "required": false,
            "description": "How many codes a page holds, at most 1,000; 100 unless set. Not with `Accept: text/csv`.",
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of codes, or every one as CSV.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessCodePage"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string",
                  "description": "A header line, then one line per code: `id`, `batch_id`, `code`, `redeem_url`, `status`, `redeemed_at`, `access_term`, `access_ends_at`, each empty for none.",
                  "example": "id,batch_id,code,redeem_url,status,redeemed_at,access_term,access_ends_at\r\n"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`), or a CSV file would hold more than 50,000 codes (`too_many_codes`): filter by `batch_id` or a time range, or read pages as JSON.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request",
                            "too_many_codes"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/access-codes/{access_code_id}": {
      "get": {
        "operationId": "get_access_code",
        "tags": [
          "access codes"
        ],
        "summary": "Read an access code",
        "description": "One of your organization's codes, with its `redeem_url`: the address an event's `resource_url` names. Needs `access_codes:read` or `access_codes:write`.",
        "security": [
          {
            "oauth2": [
              "access_codes:read"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The code's id.",
              "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
            },
            "required": true,
            "description": "The code's id.",
            "name": "access_code_id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessCode"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No code of yours has this id (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ],
                          "example": "not_found"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/access-codes/{access_code_id}/deactivate": {
      "post": {
        "operationId": "deactivate_access_code",
        "tags": [
          "access codes"
        ],
        "summary": "Block an access code",
        "description": "Blocks one of your organization's codes nobody redeemed, which then can never be redeemed, and answers it `deactivated`. Blocking it again changes nothing. A redeemed code is refused: end its access instead. Needs `access_codes:write`.",
        "security": [
          {
            "oauth2": [
              "access_codes:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The code's id.",
              "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
            },
            "required": true,
            "description": "The code's id.",
            "name": "access_code_id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The code, `deactivated`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessCode"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No code of yours has this id (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ],
                          "example": "not_found"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Someone redeemed the code (`already_redeemed`): end its access instead. Someone is redeeming it this moment (`redemption_in_progress`, with `Retry-After`): send it again then.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "already_redeemed",
                            "redemption_in_progress"
                          ],
                          "example": "already_redeemed"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out",
                            "temporarily_unavailable"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/access-codes/{access_code_id}/access": {
      "put": {
        "operationId": "set_access_end",
        "tags": [
          "access codes"
        ],
        "summary": "End the access a code started",
        "description": "Sets when the access one of your organization's redeemed codes started ends, and answers the code. A time to come ends it then; one that has passed, or none sent, ends it now; `null` undoes an end that hasn't passed. The access stops in the YOU(th) app within about 10 minutes after its end, later when the app can't be reached then. The same call twice leaves the same end. An end that has passed is final: ending it again answers the code as it is. Needs `access_codes:write`.",
        "security": [
          {
            "oauth2": [
              "access_codes:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The code's id.",
              "example": "0193b1c2-7a4e-7c1d-9f0a-2b6d5e8f1a34"
            },
            "required": true,
            "description": "The code's id.",
            "name": "access_code_id",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccessEndChange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The code, with the end set.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessCode"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No code of yours has this id (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ],
                          "example": "not_found"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Nobody redeemed the code (`not_redeemed`): block it instead. Its access has ended, and the call asks for a later end or none (`access_ended`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_redeemed",
                            "access_ended"
                          ],
                          "example": "not_redeemed"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "The body is over the API's limit (`too_large`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "too_large"
                          ],
                          "example": "too_large"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "415": {
            "description": "The body isn't JSON (`unsupported_media_type`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "unsupported_media_type"
                          ],
                          "example": "unsupported_media_type"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing, not valid or not one the call takes (`invalid_request`), or the end is later than a `fixed_days` code's own term (`ends_at_beyond_term`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request",
                            "ends_at_beyond_term"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out",
                            "temporarily_unavailable"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints": {
      "post": {
        "operationId": "create_webhook_endpoint",
        "tags": [
          "webhooks"
        ],
        "summary": "Create a webhook endpoint",
        "description": "Creates an endpoint of your organization's and answers `201` with it and its signing secret, the only answer that carries the secret. Send the same create again, with the same `Idempotency-Key` and body, and it answers the same endpoint and secret, never a second endpoint. Requires an `Idempotency-Key`. Needs `webhooks:write`.",
        "security": [
          {
            "oauth2": [
              "webhooks:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "A key of yours for the request, such as a UUID, at most 255 characters. The same key and body answer the first request again, and resume it after a `503`, for 24 hours after the latest attempt.",
              "example": "5f2b6f0e-3a51-4c58-9a57-2a1f6f1d3c11"
            },
            "required": true,
            "description": "A key of yours for the request, such as a UUID, at most 255 characters. The same key and body answer the first request again, and resume it after a `503`, for 24 hours after the latest attempt.",
            "name": "idempotency-key",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEndpointRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The endpoint, with its signing secret, at the address in `Location`.",
            "headers": {
              "location": {
                "schema": {
                  "type": "string"
                },
                "required": true,
                "description": "Where the endpoint is read.",
                "example": "/v1/webhook-endpoints/0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedWebhookEndpoint"
                }
              }
            }
          },
          "400": {
            "description": "The body can't be parsed (`malformed_request`), the create has no `Idempotency-Key` (`idempotency_key_required`), or its key is empty or longer than 255 characters (`idempotency_key_invalid`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "malformed_request",
                            "idempotency_key_required",
                            "idempotency_key_invalid"
                          ],
                          "example": "malformed_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "The key was used with another body (`idempotency_conflict`): use a new key. A create with the key runs now (`idempotency_in_progress`, with `Retry-After`): send it again then. Your organization keeps ten endpoints already, disabled ones aside (`endpoint_limit_reached`): disable one first.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "idempotency_conflict",
                            "idempotency_in_progress",
                            "endpoint_limit_reached"
                          ],
                          "example": "idempotency_conflict"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "The body is over the API's limit (`too_large`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "too_large"
                          ],
                          "example": "too_large"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "415": {
            "description": "The body isn't JSON (`unsupported_media_type`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "unsupported_media_type"
                          ],
                          "example": "unsupported_media_type"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing, not valid or not one the create takes (`invalid_request`), the address isn't https on port 443 without credentials, or its host is localhost, a name of one label or an IP address that isn't public (`url_not_allowed`), or an event type isn't one YOU(th) sends (`unknown_event_type`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request",
                            "url_not_allowed",
                            "unknown_event_type"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), gave up (`timed_out`), or can't finish the request now (`temporarily_unavailable`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out",
                            "temporarily_unavailable"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list_webhook_endpoints",
        "tags": [
          "webhooks"
        ],
        "summary": "List your webhook endpoints",
        "description": "Your organization's endpoints, oldest first, a page at a time: pass a page's `next` as `after` for the next. An `after` that isn't one of your endpoints is refused with `422 invalid_request`. Needs `webhooks:write`: there is no read-only webhook scope.",
        "security": [
          {
            "oauth2": [
              "webhooks:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The `next` of the page before; none for the first page.",
              "example": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90"
            },
            "required": false,
            "description": "The `next` of the page before; none for the first page.",
            "name": "after",
            "in": "query"
          },
          {
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "description": "How many endpoints a page holds, at most 100.",
              "example": 50
            },
            "required": false,
            "description": "How many endpoints a page holds, at most 100.",
            "name": "limit",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpointPage"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints/{webhook_endpoint_id}": {
      "get": {
        "operationId": "get_webhook_endpoint",
        "tags": [
          "webhooks"
        ],
        "summary": "Read a webhook endpoint",
        "description": "One of your organization's endpoints, without its signing secret. Needs `webhooks:write`.",
        "security": [
          {
            "oauth2": [
              "webhooks:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The endpoint's id.",
              "example": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90"
            },
            "required": true,
            "description": "The endpoint's id.",
            "name": "webhook_endpoint_id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No endpoint of yours has this id (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ],
                          "example": "not_found"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints/{webhook_endpoint_id}/disable": {
      "post": {
        "operationId": "disable_webhook_endpoint",
        "tags": [
          "webhooks"
        ],
        "summary": "Disable a webhook endpoint",
        "description": "Stops deliveries to one of your organization's endpoints, active or paused: what it still had to receive fails at once, and you read it from the API. It can't be turned on again; create an endpoint for the address instead. Disabling it again answers it as it stands. Needs `webhooks:write`.",
        "security": [
          {
            "oauth2": [
              "webhooks:write"
            ]
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "The endpoint's id.",
              "example": "0193b1d2-6f10-7a3e-9c41-2b8e7d5f4a90"
            },
            "required": true,
            "description": "The endpoint's id.",
            "name": "webhook_endpoint_id",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint, `disabled`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or one that doesn't hold, or whose client is unknown (`invalid_token`), or whose integration was revoked (`integration_revoked`).",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_token",
                            "integration_revoked"
                          ],
                          "example": "invalid_token"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token holds none of the OAuth scopes the route needs (`insufficient_scope`), and the header names them; or it holds a health scope whose Doctor's grant no longer counts, and the header names none.",
            "headers": {
              "www-authenticate": {
                "schema": {
                  "type": "string",
                  "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold.",
                  "example": "Bearer error=\"invalid_token\""
                },
                "required": true,
                "description": "What the caller must present: `Bearer`, alone when the request carried no bearer token, and with the error it was refused for when the token didn't hold."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "insufficient_scope"
                          ],
                          "example": "insufficient_scope"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No endpoint of yours has this id (`not_found`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ],
                          "example": "not_found"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid (`invalid_request`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "invalid_request"
                          ],
                          "example": "invalid_request"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "The API failed; the request id in the answer names the request (`internal_error`).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "internal_error"
                          ],
                          "example": "internal_error"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "503": {
            "description": "The API can't check the token now (`identity_unavailable`), or gave up (`timed_out`): send the same request again after `Retry-After` seconds.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "string",
                  "description": "In how many seconds to send the same request again.",
                  "example": "10"
                },
                "required": false,
                "description": "In how many seconds to send the same request again."
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Problem"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "enum": [
                            "identity_unavailable",
                            "timed_out"
                          ],
                          "example": "identity_unavailable"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "AccessCode.redeemed": {
      "post": {
        "summary": "AccessCode.redeemed",
        "description": "A code of your organization's was redeemed. `occurred_at` is the redemption: the time to bill from.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccessCodeRedeemed"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx takes the delivery."
          }
        }
      }
    },
    "Access.ended": {
      "post": {
        "summary": "Access.ended",
        "description": "The access a code started ended: the end you set passed (`ended_by_partner`), or a `fixed_days` code reached its last day (`term_over`). `occurred_at` is when it ended. New reasons can appear.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccessEnded"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx takes the delivery."
          }
        }
      }
    }
  }
}
