{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "info": {
    "title": "Contact centre API",
    "version": "1.0.0",
    "description": "Tenant-scoped REST API. Authenticate with \"Authorization: Bearer cck_...\"; never put a token in a URL. Lists page with nextCursor. Writes accept an Idempotency-Key. Webhooks are signed: CC-Signature: t=<unix>,v1=<hex HMAC-SHA-256 of \"<t>.<body>\"> under the endpoint secret."
  },
  "servers": [
    {
      "url": "https://api.ringura.com"
    }
  ],
  "paths": {
    "/api/v1/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "List contacts, oldest first; filter by phone (E.164) or e-mail for screen-pop.",
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerAuth": [
              "contacts:read"
            ]
          }
        ],
        "x-scope": "contacts:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[+][1-9][0-9]{6,14}$"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 320
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "displayName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "language": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "timeZone": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "identifiers": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                },
                                "scope": {
                                  "type": "string"
                                },
                                "verified": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "kind",
                                "value",
                                "scope",
                                "verified"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "displayName",
                          "language",
                          "timeZone",
                          "identifiers",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createContact",
        "summary": "Create a contact with at least one phone number or e-mail address.",
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerAuth": [
              "contacts:write"
            ]
          }
        ],
        "x-scope": "contacts:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "displayName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "language": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timeZone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "identifiers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string"
                          },
                          "verified": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "kind",
                          "value",
                          "scope",
                          "verified"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "displayName",
                    "language",
                    "timeZone",
                    "identifiers",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "displayName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "language": {
                    "type": "string",
                    "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{1,8})*$"
                  },
                  "timeZone": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "identifiers": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "enum": [
                            "e164",
                            "email"
                          ]
                        },
                        "value": {
                          "type": "string",
                          "minLength": 3,
                          "maxLength": 320
                        }
                      },
                      "required": [
                        "kind",
                        "value"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 10
                  }
                },
                "required": [
                  "identifiers"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/contacts/{id}": {
      "get": {
        "operationId": "getContact",
        "summary": "One contact with its identifiers.",
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerAuth": [
              "contacts:read"
            ]
          }
        ],
        "x-scope": "contacts:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "displayName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "language": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timeZone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "identifiers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string"
                          },
                          "verified": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "kind",
                          "value",
                          "scope",
                          "verified"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "displayName",
                    "language",
                    "timeZone",
                    "identifiers",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateContact",
        "summary": "Change a contact's name, language or time zone.",
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerAuth": [
              "contacts:write"
            ]
          }
        ],
        "x-scope": "contacts:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "displayName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "language": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "timeZone": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "identifiers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string"
                          },
                          "verified": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "kind",
                          "value",
                          "scope",
                          "verified"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "displayName",
                    "language",
                    "timeZone",
                    "identifiers",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "displayName": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "language": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{1,8})*$"
                  },
                  "timeZone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations": {
      "get": {
        "operationId": "listConversations",
        "summary": "List conversations, oldest first.",
        "tags": [
          "Conversations"
        ],
        "security": [
          {
            "bearerAuth": [
              "conversations:read"
            ]
          }
        ],
        "x-scope": "conversations:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "pending",
                "snoozed",
                "resolved",
                "closed"
              ]
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "contactId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string"
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "urgent",
                              "high",
                              "normal",
                              "low",
                              "lowest"
                            ]
                          },
                          "subject": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "queueId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "assigneeId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "caseNumber": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "channels": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "openedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "lastActivityAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "closedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "contactId",
                          "status",
                          "priority",
                          "subject",
                          "queueId",
                          "assigneeId",
                          "caseNumber",
                          "tags",
                          "channels",
                          "openedAt",
                          "lastActivityAt",
                          "closedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}": {
      "get": {
        "operationId": "getConversation",
        "summary": "One conversation.",
        "tags": [
          "Conversations"
        ],
        "security": [
          {
            "bearerAuth": [
              "conversations:read"
            ]
          }
        ],
        "x-scope": "conversations:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string"
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "urgent",
                        "high",
                        "normal",
                        "low",
                        "lowest"
                      ]
                    },
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "assigneeId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "caseNumber": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "channels": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "openedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "lastActivityAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "closedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "contactId",
                    "status",
                    "priority",
                    "subject",
                    "queueId",
                    "assigneeId",
                    "caseNumber",
                    "tags",
                    "channels",
                    "openedAt",
                    "lastActivityAt",
                    "closedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateConversation",
        "summary": "Change a conversation's subject, priority or tags, or resolve it (which sends the survey and writes back to CRMs).",
        "tags": [
          "Conversations"
        ],
        "security": [
          {
            "bearerAuth": [
              "conversations:write"
            ]
          }
        ],
        "x-scope": "conversations:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string"
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "urgent",
                        "high",
                        "normal",
                        "low",
                        "lowest"
                      ]
                    },
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "assigneeId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "caseNumber": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "channels": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "openedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "lastActivityAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "closedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "contactId",
                    "status",
                    "priority",
                    "subject",
                    "queueId",
                    "assigneeId",
                    "caseNumber",
                    "tags",
                    "channels",
                    "openedAt",
                    "lastActivityAt",
                    "closedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "urgent",
                      "high",
                      "normal",
                      "low",
                      "lowest"
                    ]
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "resolved"
                    ]
                  },
                  "disposition": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/conversations/{id}/messages": {
      "get": {
        "operationId": "listMessages",
        "summary": "A conversation's messages across its threads, oldest first.",
        "tags": [
          "Messages"
        ],
        "security": [
          {
            "bearerAuth": [
              "messages:read"
            ]
          }
        ],
        "x-scope": "messages:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "conversationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "interactionId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "direction": {
                            "type": "string",
                            "enum": [
                              "inbound",
                              "outbound",
                              "internal"
                            ]
                          },
                          "kind": {
                            "type": "string"
                          },
                          "body": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "sentAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "author": {
                            "type": "object",
                            "properties": {
                              "kind": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "agentId": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "format": "uuid"
                              },
                              "label": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "kind",
                              "agentId",
                              "label"
                            ],
                            "additionalProperties": false
                          },
                          "aiGenerated": {
                            "type": "boolean"
                          },
                          "aiProvenance": {
                            "type": [
                              "object",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "interactionId",
                          "direction",
                          "kind",
                          "body",
                          "status",
                          "sentAt",
                          "author",
                          "aiGenerated",
                          "aiProvenance"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "sendMessage",
        "summary": "Send a text or an approved WhatsApp template on one of the conversation's threads (web chat, WhatsApp, e-mail or SMS), under every rule the console applies.",
        "tags": [
          "Messages"
        ],
        "security": [
          {
            "bearerAuth": [
              "messages:write"
            ]
          }
        ],
        "x-scope": "messages:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "messageId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string"
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "messageId",
                    "status",
                    "replayed"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "interactionId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "text",
                      "template"
                    ]
                  },
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4096
                  },
                  "template": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "maxLength": 512
                      },
                      "language": {
                        "type": "string",
                        "maxLength": 20
                      },
                      "parameters": {
                        "type": "object"
                      }
                    },
                    "required": [
                      "name",
                      "language"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "interactionId",
                  "type"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/interactions": {
      "get": {
        "operationId": "listInteractions",
        "summary": "Calls, chats and threads, oldest first.",
        "tags": [
          "Interactions"
        ],
        "security": [
          {
            "bearerAuth": [
              "interactions:read"
            ]
          }
        ],
        "x-scope": "interactions:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "conversationId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "conversationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "type": {
                            "type": "string"
                          },
                          "channel": {
                            "type": "string"
                          },
                          "direction": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "startedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "remoteAddress": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "localAddress": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "type",
                          "channel",
                          "direction",
                          "status",
                          "startedAt",
                          "endedAt",
                          "remoteAddress",
                          "localAddress"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/interactions/{id}": {
      "get": {
        "operationId": "getInteraction",
        "summary": "One call, chat or thread.",
        "tags": [
          "Interactions"
        ],
        "security": [
          {
            "bearerAuth": [
              "interactions:read"
            ]
          }
        ],
        "x-scope": "interactions:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "conversationId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "type": {
                      "type": "string"
                    },
                    "channel": {
                      "type": "string"
                    },
                    "direction": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "startedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "endedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "remoteAddress": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "localAddress": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "type",
                    "channel",
                    "direction",
                    "status",
                    "startedAt",
                    "endedAt",
                    "remoteAddress",
                    "localAddress"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns": {
      "get": {
        "operationId": "listCampaigns",
        "summary": "Outbound campaigns, oldest first.",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "campaigns:read"
            ]
          }
        ],
        "x-scope": "campaigns:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          },
                          "mode": {
                            "type": "string"
                          },
                          "purpose": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "queueId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "mode",
                          "purpose",
                          "status",
                          "queueId",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/{id}": {
      "get": {
        "operationId": "getCampaign",
        "summary": "One campaign.",
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerAuth": [
              "campaigns:read"
            ]
          }
        ],
        "x-scope": "campaigns:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "name": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "purpose": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "mode",
                    "purpose",
                    "status",
                    "queueId",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/users": {
      "get": {
        "operationId": "listUsers",
        "summary": "The tenant's console users and their roles.",
        "tags": [
          "People"
        ],
        "security": [
          {
            "bearerAuth": [
              "users:read"
            ]
          }
        ],
        "x-scope": "users:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "email": {
                            "type": "string"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "agentId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "email",
                          "displayName",
                          "role",
                          "agentId",
                          "status"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agents": {
      "get": {
        "operationId": "listAgents",
        "summary": "Agents with their presence now.",
        "tags": [
          "People"
        ],
        "security": [
          {
            "bearerAuth": [
              "users:read"
            ]
          }
        ],
        "x-scope": "users:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "displayName": {
                            "type": "string"
                          },
                          "teamId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "status": {
                            "type": "string"
                          },
                          "presence": {
                            "type": "object",
                            "properties": {
                              "state": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "reason": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "since": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "state",
                              "reason",
                              "since"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "id",
                          "displayName",
                          "teamId",
                          "status",
                          "presence"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/queues": {
      "get": {
        "operationId": "listQueues",
        "summary": "Queues and the channels they take.",
        "tags": [
          "People"
        ],
        "security": [
          {
            "bearerAuth": [
              "queues:read"
            ]
          }
        ],
        "x-scope": "queues:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "name": {
                            "type": "string"
                          },
                          "channels": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "mode": {
                            "type": "string"
                          },
                          "scheduleId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "channels",
                          "mode",
                          "scheduleId"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/wallet": {
      "get": {
        "operationId": "getWallet",
        "summary": "The prepaid balance, as strings of minor units.",
        "tags": [
          "Wallet"
        ],
        "security": [
          {
            "bearerAuth": [
              "wallet:read"
            ]
          }
        ],
        "x-scope": "wallet:read",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "availableMinor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reservedMinor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "thresholdMinor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "voiceRefusal": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "messagesRefusal": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "currency",
                    "availableMinor",
                    "reservedMinor",
                    "thresholdMinor",
                    "voiceRefusal",
                    "messagesRefusal"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tickets": {
      "get": {
        "operationId": "listTickets",
        "summary": "Tickets, newest reference number first.",
        "tags": [
          "Tickets"
        ],
        "security": [
          {
            "bearerAuth": [
              "tickets:read"
            ]
          }
        ],
        "x-scope": "tickets:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "pending",
                "snoozed",
                "resolved",
                "closed"
              ]
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "caseNumber": {
                            "type": "integer"
                          },
                          "reference": {
                            "type": "string"
                          },
                          "subject": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "urgent",
                              "high",
                              "normal",
                              "low",
                              "lowest"
                            ]
                          },
                          "caseType": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "fields": {
                            "type": "object"
                          },
                          "disposition": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "assigneeId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "queueId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "contactId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "slaPolicyId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "firstResponseDueAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "nextResponseDueAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "resolutionDueAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "firstRepliedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "openedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "closedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "mergedInto": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "lastActivityAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "caseNumber",
                          "reference",
                          "subject",
                          "status",
                          "priority",
                          "caseType",
                          "fields",
                          "disposition",
                          "tags",
                          "assigneeId",
                          "queueId",
                          "contactId",
                          "version",
                          "slaPolicyId",
                          "firstResponseDueAt",
                          "nextResponseDueAt",
                          "resolutionDueAt",
                          "firstRepliedAt",
                          "openedAt",
                          "closedAt",
                          "mergedInto",
                          "lastActivityAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTicket",
        "summary": "Make a conversation a ticket: a reference number, case fields and SLA due times.",
        "tags": [
          "Tickets"
        ],
        "security": [
          {
            "bearerAuth": [
              "tickets:write"
            ]
          }
        ],
        "x-scope": "tickets:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "caseNumber": {
                      "type": "integer"
                    },
                    "reference": {
                      "type": "string"
                    },
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "urgent",
                        "high",
                        "normal",
                        "low",
                        "lowest"
                      ]
                    },
                    "caseType": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "fields": {
                      "type": "object"
                    },
                    "disposition": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "assigneeId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "slaPolicyId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "firstResponseDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "nextResponseDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "resolutionDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "firstRepliedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "openedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "closedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "mergedInto": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "lastActivityAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "caseNumber",
                    "reference",
                    "subject",
                    "status",
                    "priority",
                    "caseType",
                    "fields",
                    "disposition",
                    "tags",
                    "assigneeId",
                    "queueId",
                    "contactId",
                    "version",
                    "slaPolicyId",
                    "firstResponseDueAt",
                    "nextResponseDueAt",
                    "resolutionDueAt",
                    "firstRepliedAt",
                    "openedAt",
                    "closedAt",
                    "mergedInto",
                    "lastActivityAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "urgent",
                      "high",
                      "normal",
                      "low",
                      "lowest"
                    ]
                  },
                  "caseType": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "fields": {
                    "type": "object"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "assigneeId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  }
                },
                "required": [
                  "conversationId"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/tickets/{id}": {
      "get": {
        "operationId": "getTicket",
        "summary": "One ticket.",
        "tags": [
          "Tickets"
        ],
        "security": [
          {
            "bearerAuth": [
              "tickets:read"
            ]
          }
        ],
        "x-scope": "tickets:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "caseNumber": {
                      "type": "integer"
                    },
                    "reference": {
                      "type": "string"
                    },
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "urgent",
                        "high",
                        "normal",
                        "low",
                        "lowest"
                      ]
                    },
                    "caseType": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "fields": {
                      "type": "object"
                    },
                    "disposition": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "assigneeId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "slaPolicyId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "firstResponseDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "nextResponseDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "resolutionDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "firstRepliedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "openedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "closedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "mergedInto": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "lastActivityAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "caseNumber",
                    "reference",
                    "subject",
                    "status",
                    "priority",
                    "caseType",
                    "fields",
                    "disposition",
                    "tags",
                    "assigneeId",
                    "queueId",
                    "contactId",
                    "version",
                    "slaPolicyId",
                    "firstResponseDueAt",
                    "nextResponseDueAt",
                    "resolutionDueAt",
                    "firstRepliedAt",
                    "openedAt",
                    "closedAt",
                    "mergedInto",
                    "lastActivityAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTicket",
        "summary": "Change a ticket. Send the version you read: a stale version is refused with 409 version_conflict.",
        "tags": [
          "Tickets"
        ],
        "security": [
          {
            "bearerAuth": [
              "tickets:write"
            ]
          }
        ],
        "x-scope": "tickets:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "caseNumber": {
                      "type": "integer"
                    },
                    "reference": {
                      "type": "string"
                    },
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "priority": {
                      "type": "string",
                      "enum": [
                        "urgent",
                        "high",
                        "normal",
                        "low",
                        "lowest"
                      ]
                    },
                    "caseType": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "fields": {
                      "type": "object"
                    },
                    "disposition": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "assigneeId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "slaPolicyId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "firstResponseDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "nextResponseDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "resolutionDueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "firstRepliedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "openedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "closedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "mergedInto": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "lastActivityAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "caseNumber",
                    "reference",
                    "subject",
                    "status",
                    "priority",
                    "caseType",
                    "fields",
                    "disposition",
                    "tags",
                    "assigneeId",
                    "queueId",
                    "contactId",
                    "version",
                    "slaPolicyId",
                    "firstResponseDueAt",
                    "nextResponseDueAt",
                    "resolutionDueAt",
                    "firstRepliedAt",
                    "openedAt",
                    "closedAt",
                    "mergedInto",
                    "lastActivityAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "version": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "pending",
                      "resolved"
                    ]
                  },
                  "priority": {
                    "type": "string",
                    "enum": [
                      "urgent",
                      "high",
                      "normal",
                      "low",
                      "lowest"
                    ]
                  },
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "caseType": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "assigneeId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "addTags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "removeTags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "fields": {
                    "type": "object"
                  },
                  "disposition": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "required": [
                  "version"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/tickets/{id}/merge": {
      "post": {
        "operationId": "mergeTicket",
        "summary": "Merge this ticket into another of the same contact.",
        "tags": [
          "Tickets"
        ],
        "security": [
          {
            "bearerAuth": [
              "tickets:write"
            ]
          }
        ],
        "x-scope": "tickets:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "source": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "caseNumber": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "subject": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "urgent",
                            "high",
                            "normal",
                            "low",
                            "lowest"
                          ]
                        },
                        "caseType": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "fields": {
                          "type": "object"
                        },
                        "disposition": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "assigneeId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "queueId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "contactId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "version": {
                          "type": "integer"
                        },
                        "slaPolicyId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "firstResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "nextResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "resolutionDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "firstRepliedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "openedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "closedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "mergedInto": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "lastActivityAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "caseNumber",
                        "reference",
                        "subject",
                        "status",
                        "priority",
                        "caseType",
                        "fields",
                        "disposition",
                        "tags",
                        "assigneeId",
                        "queueId",
                        "contactId",
                        "version",
                        "slaPolicyId",
                        "firstResponseDueAt",
                        "nextResponseDueAt",
                        "resolutionDueAt",
                        "firstRepliedAt",
                        "openedAt",
                        "closedAt",
                        "mergedInto",
                        "lastActivityAt"
                      ],
                      "additionalProperties": false
                    },
                    "target": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "caseNumber": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "subject": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "urgent",
                            "high",
                            "normal",
                            "low",
                            "lowest"
                          ]
                        },
                        "caseType": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "fields": {
                          "type": "object"
                        },
                        "disposition": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "assigneeId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "queueId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "contactId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "version": {
                          "type": "integer"
                        },
                        "slaPolicyId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "firstResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "nextResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "resolutionDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "firstRepliedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "openedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "closedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "mergedInto": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "lastActivityAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "caseNumber",
                        "reference",
                        "subject",
                        "status",
                        "priority",
                        "caseType",
                        "fields",
                        "disposition",
                        "tags",
                        "assigneeId",
                        "queueId",
                        "contactId",
                        "version",
                        "slaPolicyId",
                        "firstResponseDueAt",
                        "nextResponseDueAt",
                        "resolutionDueAt",
                        "firstRepliedAt",
                        "openedAt",
                        "closedAt",
                        "mergedInto",
                        "lastActivityAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "source",
                    "target"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "into": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "into"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/tickets/{id}/split": {
      "post": {
        "operationId": "splitTicket",
        "summary": "Move threads off this ticket into a new one.",
        "tags": [
          "Tickets"
        ],
        "security": [
          {
            "bearerAuth": [
              "tickets:write"
            ]
          }
        ],
        "x-scope": "tickets:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "source": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "caseNumber": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "subject": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "urgent",
                            "high",
                            "normal",
                            "low",
                            "lowest"
                          ]
                        },
                        "caseType": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "fields": {
                          "type": "object"
                        },
                        "disposition": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "assigneeId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "queueId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "contactId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "version": {
                          "type": "integer"
                        },
                        "slaPolicyId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "firstResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "nextResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "resolutionDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "firstRepliedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "openedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "closedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "mergedInto": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "lastActivityAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "caseNumber",
                        "reference",
                        "subject",
                        "status",
                        "priority",
                        "caseType",
                        "fields",
                        "disposition",
                        "tags",
                        "assigneeId",
                        "queueId",
                        "contactId",
                        "version",
                        "slaPolicyId",
                        "firstResponseDueAt",
                        "nextResponseDueAt",
                        "resolutionDueAt",
                        "firstRepliedAt",
                        "openedAt",
                        "closedAt",
                        "mergedInto",
                        "lastActivityAt"
                      ],
                      "additionalProperties": false
                    },
                    "ticket": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "caseNumber": {
                          "type": "integer"
                        },
                        "reference": {
                          "type": "string"
                        },
                        "subject": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "priority": {
                          "type": "string",
                          "enum": [
                            "urgent",
                            "high",
                            "normal",
                            "low",
                            "lowest"
                          ]
                        },
                        "caseType": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "fields": {
                          "type": "object"
                        },
                        "disposition": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "assigneeId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "queueId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "contactId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "version": {
                          "type": "integer"
                        },
                        "slaPolicyId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "firstResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "nextResponseDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "resolutionDueAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "firstRepliedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "openedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "closedAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "mergedInto": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "lastActivityAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "caseNumber",
                        "reference",
                        "subject",
                        "status",
                        "priority",
                        "caseType",
                        "fields",
                        "disposition",
                        "tags",
                        "assigneeId",
                        "queueId",
                        "contactId",
                        "version",
                        "slaPolicyId",
                        "firstResponseDueAt",
                        "nextResponseDueAt",
                        "resolutionDueAt",
                        "firstRepliedAt",
                        "openedAt",
                        "closedAt",
                        "mergedInto",
                        "lastActivityAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "source",
                    "ticket"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "interactionIds": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  },
                  "subject": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  }
                },
                "required": [
                  "interactionIds"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/event-types": {
      "get": {
        "operationId": "listEventTypes",
        "summary": "The event catalogue an endpoint can subscribe to.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:read"
            ]
          }
        ],
        "x-scope": "webhooks:read",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "data": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "type",
                          "summary",
                          "data"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhook-endpoints": {
      "get": {
        "operationId": "listWebhookEndpoints",
        "summary": "The tenant's webhook endpoints.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:read"
            ]
          }
        ],
        "x-scope": "webhooks:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "url": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "eventTypes": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "active",
                              "disabled"
                            ]
                          },
                          "rotating": {
                            "type": "boolean"
                          },
                          "previousSecretExpiresAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "url",
                          "description",
                          "eventTypes",
                          "status",
                          "rotating",
                          "previousSecretExpiresAt",
                          "createdAt",
                          "updatedAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhookEndpoint",
        "summary": "Subscribe a URL to event types. The signing secret is in this answer only.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:write"
            ]
          }
        ],
        "x-scope": "webhooks:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "endpoint": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "url": {
                          "type": "string"
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "eventTypes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "disabled"
                          ]
                        },
                        "rotating": {
                          "type": "boolean"
                        },
                        "previousSecretExpiresAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "url",
                        "description",
                        "eventTypes",
                        "status",
                        "rotating",
                        "previousSecretExpiresAt",
                        "createdAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    },
                    "secret": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "endpoint",
                    "secret"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "eventTypes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200
                  }
                },
                "required": [
                  "url",
                  "eventTypes"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/webhook-endpoints/{id}": {
      "get": {
        "operationId": "getWebhookEndpoint",
        "summary": "One endpoint.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:read"
            ]
          }
        ],
        "x-scope": "webhooks:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "url": {
                      "type": "string"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "eventTypes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "active",
                        "disabled"
                      ]
                    },
                    "rotating": {
                      "type": "boolean"
                    },
                    "previousSecretExpiresAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "url",
                    "description",
                    "eventTypes",
                    "status",
                    "rotating",
                    "previousSecretExpiresAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateWebhookEndpoint",
        "summary": "Change an endpoint's URL, event types or status.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:write"
            ]
          }
        ],
        "x-scope": "webhooks:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "url": {
                      "type": "string"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "eventTypes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "active",
                        "disabled"
                      ]
                    },
                    "rotating": {
                      "type": "boolean"
                    },
                    "previousSecretExpiresAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "url",
                    "description",
                    "eventTypes",
                    "status",
                    "rotating",
                    "previousSecretExpiresAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "eventTypes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 100
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "disabled"
                    ]
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/webhook-endpoints/{id}/rotate-secret": {
      "post": {
        "operationId": "rotateWebhookSecret",
        "summary": "A new signing secret; for 24 hours deliveries are signed under both.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:write"
            ]
          }
        ],
        "x-scope": "webhooks:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "endpoint": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "url": {
                          "type": "string"
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "eventTypes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "active",
                            "disabled"
                          ]
                        },
                        "rotating": {
                          "type": "boolean"
                        },
                        "previousSecretExpiresAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "url",
                        "description",
                        "eventTypes",
                        "status",
                        "rotating",
                        "previousSecretExpiresAt",
                        "createdAt",
                        "updatedAt"
                      ],
                      "additionalProperties": false
                    },
                    "secret": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "endpoint",
                    "secret"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhook-deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "summary": "Deliveries, newest first; dead ones are the dead letter.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:read"
            ]
          }
        ],
        "x-scope": "webhooks:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "endpointId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "sending",
                "delivered",
                "dead"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "endpointId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "eventId": {
                            "type": "string"
                          },
                          "eventType": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "sending",
                              "delivered",
                              "dead"
                            ]
                          },
                          "attempts": {
                            "type": "integer"
                          },
                          "nextAttemptAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "lastStatusCode": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "lastError": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "deliveredAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "replayOf": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "endpointId",
                          "eventId",
                          "eventType",
                          "status",
                          "attempts",
                          "nextAttemptAt",
                          "lastStatusCode",
                          "lastError",
                          "deliveredAt",
                          "replayOf",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhook-deliveries/{id}/replay": {
      "post": {
        "operationId": "replayWebhookDelivery",
        "summary": "Send a delivered or dead event again, as a new delivery with the same event id.",
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerAuth": [
              "webhooks:write"
            ]
          }
        ],
        "x-scope": "webhooks:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "endpointId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "eventId": {
                      "type": "string"
                    },
                    "eventType": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "sending",
                        "delivered",
                        "dead"
                      ]
                    },
                    "attempts": {
                      "type": "integer"
                    },
                    "nextAttemptAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "lastStatusCode": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "lastError": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "deliveredAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "replayOf": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "endpointId",
                    "eventId",
                    "eventType",
                    "status",
                    "attempts",
                    "nextAttemptAt",
                    "lastStatusCode",
                    "lastError",
                    "deliveredAt",
                    "replayOf",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/{groupBy}": {
      "get": {
        "operationId": "getReport",
        "summary": "Historical figures from the metric dictionary by channel, queue, agent or campaign. Ask for text/csv to get CSV.",
        "tags": [
          "Reports"
        ],
        "security": [
          {
            "bearerAuth": [
              "reports:read"
            ]
          }
        ],
        "x-scope": "reports:read",
        "parameters": [
          {
            "name": "groupBy",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "channel",
                "queue",
                "agent",
                "campaign"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dictionaryVersion": {
                      "type": "integer"
                    },
                    "window": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "to": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "from",
                        "to"
                      ],
                      "additionalProperties": false
                    },
                    "groupBy": {
                      "type": "string",
                      "enum": [
                        "channel",
                        "queue",
                        "agent",
                        "campaign"
                      ]
                    },
                    "metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "metrics": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "object",
                              "properties": {
                                "value": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                },
                                "n": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                },
                                "unit": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "value",
                                "n",
                                "unit"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "key",
                          "label",
                          "metrics"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "total": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "value": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "n": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "unit": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "value",
                          "n",
                          "unit"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "dictionaryVersion",
                    "window",
                    "groupBy",
                    "metrics",
                    "rows",
                    "total"
                  ],
                  "additionalProperties": false
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/surveys": {
      "get": {
        "operationId": "listSurveys",
        "summary": "CSAT and NPS surveys, newest first.",
        "tags": [
          "Surveys"
        ],
        "security": [
          {
            "bearerAuth": [
              "surveys:read"
            ]
          }
        ],
        "x-scope": "surveys:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 400
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "sent",
                "answered",
                "expired",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "conversationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "contactId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "agentId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "queueId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "channel": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "csat",
                              "nps"
                            ]
                          },
                          "scale": {
                            "type": "object",
                            "properties": {
                              "min": {
                                "type": "integer"
                              },
                              "max": {
                                "type": "integer"
                              }
                            },
                            "required": [
                              "min",
                              "max"
                            ],
                            "additionalProperties": false
                          },
                          "status": {
                            "type": "string"
                          },
                          "failure": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sentAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "expiresAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "respondedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "score": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "comment": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "via": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "followUpConversationId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          }
                        },
                        "required": [
                          "id",
                          "conversationId",
                          "contactId",
                          "agentId",
                          "queueId",
                          "channel",
                          "kind",
                          "scale",
                          "status",
                          "failure",
                          "sentAt",
                          "expiresAt",
                          "respondedAt",
                          "score",
                          "comment",
                          "via",
                          "followUpConversationId"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/surveys/{id}/responses": {
      "post": {
        "operationId": "answerSurvey",
        "summary": "Record an answer collected elsewhere: the post-call IVR's digit, or your own form.",
        "tags": [
          "Surveys"
        ],
        "security": [
          {
            "bearerAuth": [
              "surveys:write"
            ]
          }
        ],
        "x-scope": "surveys:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "conversationId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "agentId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "queueId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "channel": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "csat",
                        "nps"
                      ]
                    },
                    "scale": {
                      "type": "object",
                      "properties": {
                        "min": {
                          "type": "integer"
                        },
                        "max": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "min",
                        "max"
                      ],
                      "additionalProperties": false
                    },
                    "status": {
                      "type": "string"
                    },
                    "failure": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "sentAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "respondedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "score": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "comment": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "via": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "followUpConversationId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "id",
                    "conversationId",
                    "contactId",
                    "agentId",
                    "queueId",
                    "channel",
                    "kind",
                    "scale",
                    "status",
                    "failure",
                    "sentAt",
                    "expiresAt",
                    "respondedAt",
                    "score",
                    "comment",
                    "via",
                    "followUpConversationId"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "score": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10
                  },
                  "comment": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "via": {
                    "type": "string",
                    "enum": [
                      "ivr",
                      "api"
                    ]
                  }
                },
                "required": [
                  "score",
                  "via"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/exports": {
      "post": {
        "operationId": "createExport",
        "summary": "Queue an export of a dataset (conversations, work_items, dial_attempts, outcomes, insights) as CSV, JSON lines or Parquet. Start from a time (since), from the watermark of a previous export (cursor), or from the beginning. It is built asynchronously; an export.ready webhook (or polling GET /exports/{id}) says when to download.",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "bearerAuth": [
              "analytics:read"
            ]
          }
        ],
        "x-scope": "analytics:read",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "dataset": {
                      "type": "string",
                      "enum": [
                        "conversations",
                        "work_items",
                        "dial_attempts",
                        "outcomes",
                        "insights"
                      ]
                    },
                    "format": {
                      "type": "string",
                      "enum": [
                        "csv",
                        "jsonl",
                        "parquet"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "running",
                        "ready",
                        "failed",
                        "expired"
                      ]
                    },
                    "via": {
                      "type": "string",
                      "enum": [
                        "console",
                        "api"
                      ]
                    },
                    "cursorAfter": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rows": {
                      "type": "integer"
                    },
                    "bytes": {
                      "type": "integer"
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "snapshotUntil": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "finishedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "expiresAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "dataset",
                    "format",
                    "status",
                    "cursorAfter",
                    "rows",
                    "bytes",
                    "hasMore",
                    "nextCursor",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dataset": {
                    "type": "string",
                    "enum": [
                      "conversations",
                      "work_items",
                      "dial_attempts",
                      "outcomes",
                      "insights"
                    ]
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "csv",
                      "jsonl",
                      "parquet"
                    ]
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "since": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "dataset"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listExports",
        "summary": "Recent exports, newest first.",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "bearerAuth": [
              "analytics:read"
            ]
          }
        ],
        "x-scope": "analytics:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "dataset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "conversations",
                "work_items",
                "dial_attempts",
                "outcomes",
                "insights"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "dataset": {
                            "type": "string",
                            "enum": [
                              "conversations",
                              "work_items",
                              "dial_attempts",
                              "outcomes",
                              "insights"
                            ]
                          },
                          "format": {
                            "type": "string",
                            "enum": [
                              "csv",
                              "jsonl",
                              "parquet"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "queued",
                              "running",
                              "ready",
                              "failed",
                              "expired"
                            ]
                          },
                          "via": {
                            "type": "string",
                            "enum": [
                              "console",
                              "api"
                            ]
                          },
                          "cursorAfter": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "rows": {
                            "type": "integer"
                          },
                          "bytes": {
                            "type": "integer"
                          },
                          "hasMore": {
                            "type": "boolean"
                          },
                          "nextCursor": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "snapshotUntil": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "error": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "finishedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "expiresAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "dataset",
                          "format",
                          "status",
                          "cursorAfter",
                          "rows",
                          "bytes",
                          "hasMore",
                          "nextCursor",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/exports/{id}": {
      "get": {
        "operationId": "getExport",
        "summary": "One export: its status, size, row count and the watermark to start the next pull from.",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "bearerAuth": [
              "analytics:read"
            ]
          }
        ],
        "x-scope": "analytics:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "dataset": {
                      "type": "string",
                      "enum": [
                        "conversations",
                        "work_items",
                        "dial_attempts",
                        "outcomes",
                        "insights"
                      ]
                    },
                    "format": {
                      "type": "string",
                      "enum": [
                        "csv",
                        "jsonl",
                        "parquet"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "running",
                        "ready",
                        "failed",
                        "expired"
                      ]
                    },
                    "via": {
                      "type": "string",
                      "enum": [
                        "console",
                        "api"
                      ]
                    },
                    "cursorAfter": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "rows": {
                      "type": "integer"
                    },
                    "bytes": {
                      "type": "integer"
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "snapshotUntil": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "finishedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "expiresAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "dataset",
                    "format",
                    "status",
                    "cursorAfter",
                    "rows",
                    "bytes",
                    "hasMore",
                    "nextCursor",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/exports/{id}/download": {
      "get": {
        "operationId": "downloadExport",
        "summary": "The finished export as text/csv, application/x-ndjson or application/vnd.apache.parquet. X-Export-Watermark carries the watermark for the next pull and X-Export-Has-More says to pull again at once.",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "bearerAuth": [
              "analytics:read"
            ]
          }
        ],
        "x-scope": "analytics:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              },
              "application/vnd.apache.parquet": {
                "schema": {
                  "type": "string",
                  "contentEncoding": "binary"
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outcomes": {
      "post": {
        "operationId": "recordOutcomes",
        "summary": "Record deposits and conversions (up to 500). Each is attributed to the agent, campaign, channel and WhatsApp template that last touched the contact inside the attribution window. externalRef makes each idempotent: a repeat is counted once. Items that do not fit are reported in problems and skipped.",
        "tags": [
          "Outcomes"
        ],
        "security": [
          {
            "bearerAuth": [
              "outcomes:write"
            ]
          }
        ],
        "x-scope": "outcomes:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "created": {
                      "type": "integer"
                    },
                    "duplicates": {
                      "type": "integer"
                    },
                    "problems": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "created",
                    "duplicates",
                    "problems"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "outcomes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "externalRef": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "kind": {
                          "type": "string",
                          "enum": [
                            "deposit",
                            "conversion"
                          ]
                        },
                        "amountMinor": {
                          "type": [
                            "integer",
                            "string"
                          ]
                        },
                        "currency": {
                          "type": "string",
                          "pattern": "^[A-Z]{3}$"
                        },
                        "occurredAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "contactId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "phone": {
                          "type": "string",
                          "maxLength": 32
                        },
                        "email": {
                          "type": "string",
                          "maxLength": 320
                        }
                      },
                      "required": [
                        "externalRef",
                        "kind",
                        "currency",
                        "occurredAt"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 500
                  }
                },
                "required": [
                  "outcomes"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/calls": {
      "post": {
        "operationId": "clickToCall",
        "summary": "Click-to-call from a CRM: the named agent's phone rings first, then the number, presented from one of your verified numbers, through the outbound gate. A refusal (calling hours, DNC, consent, a number called in the last 10 minutes, telephony not active) answers 409 with the reason.",
        "tags": [
          "Calls"
        ],
        "security": [
          {
            "bearerAuth": [
              "calls:write"
            ]
          }
        ],
        "x-scope": "calls:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "source": {
                          "type": "string"
                        },
                        "e164": {
                          "type": "string"
                        },
                        "purpose": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "waiting_agent",
                            "dialling",
                            "refused",
                            "failed",
                            "expired"
                          ]
                        },
                        "refusal": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "agentId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "queueId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "contactId": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "uuid"
                        },
                        "callId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "dialledAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "source",
                        "e164",
                        "purpose",
                        "status",
                        "refusal",
                        "agentId",
                        "queueId",
                        "contactId",
                        "callId",
                        "createdAt",
                        "dialledAt"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "request"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "number": {
                    "type": "string",
                    "minLength": 4,
                    "maxLength": 32
                  },
                  "defaultCountry": {
                    "type": "string",
                    "pattern": "^[A-Z]{2}$"
                  },
                  "agentId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "queueId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contactId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "callerId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "purpose": {
                    "type": "string",
                    "enum": [
                      "service",
                      "marketing"
                    ]
                  }
                },
                "required": [
                  "number"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/leads": {
      "post": {
        "operationId": "createLead",
        "summary": "A new lead for a speed-to-lead source: top of its campaign's hopper and its sequence's first step due now; dialled or messaged at once when the gate allows.",
        "tags": [
          "Leads"
        ],
        "security": [
          {
            "bearerAuth": [
              "leads:write"
            ]
          }
        ],
        "x-scope": "leads:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "event": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "sourceId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "leadId": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "via": {
                          "type": "string"
                        },
                        "externalId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "receivedAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "targetSeconds": {
                          "type": "integer"
                        },
                        "firstAction": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "firstActionAt": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "seconds": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "met": {
                          "type": [
                            "boolean",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "sourceId",
                        "leadId",
                        "via",
                        "externalId",
                        "receivedAt",
                        "targetSeconds",
                        "firstAction",
                        "firstActionAt",
                        "seconds",
                        "met"
                      ],
                      "additionalProperties": false
                    },
                    "duplicate": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "event",
                    "duplicate"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sourceId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "phone": {
                    "type": "string",
                    "minLength": 4,
                    "maxLength": 32
                  },
                  "defaultCountry": {
                    "type": "string",
                    "pattern": "^[A-Z]{2}$"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "email": {
                    "type": "string",
                    "maxLength": 320
                  },
                  "externalId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "consent": {
                    "type": "boolean"
                  },
                  "timeZone": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "fields": {
                    "type": "object"
                  }
                },
                "required": [
                  "sourceId",
                  "phone"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/tasks": {
      "post": {
        "operationId": "createTask",
        "summary": "Create a task (a callback, voicemail, web form, CRM follow-up or back-office case) routed to the agents of a queue like a conversation; externalRef makes it idempotent.",
        "tags": [
          "Tasks"
        ],
        "security": [
          {
            "bearerAuth": [
              "tasks:write"
            ]
          }
        ],
        "x-scope": "tasks:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "callback",
                        "voicemail",
                        "web_form",
                        "crm_followup",
                        "back_office"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object"
                    },
                    "contactId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "conversationId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "interactionId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "queueId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "dueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "done",
                        "cancelled"
                      ]
                    },
                    "externalRef": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "completedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "outcome": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "workItem": {
                      "type": [
                        "object",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "kind",
                    "title",
                    "details",
                    "contactId",
                    "conversationId",
                    "interactionId",
                    "queueId",
                    "priority",
                    "dueAt",
                    "status",
                    "externalRef",
                    "createdBy",
                    "createdAt",
                    "completedAt",
                    "outcome",
                    "workItem"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "callback",
                      "voicemail",
                      "web_form",
                      "crm_followup",
                      "back_office"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "queueId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contactId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "priority": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 5
                  },
                  "dueAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "externalRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "details": {
                    "type": "object"
                  }
                },
                "required": [
                  "kind",
                  "title",
                  "queueId"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/tasks/{id}": {
      "get": {
        "operationId": "getTask",
        "summary": "One task with its routing state.",
        "tags": [
          "Tasks"
        ],
        "security": [
          {
            "bearerAuth": [
              "tasks:read"
            ]
          }
        ],
        "x-scope": "tasks:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "callback",
                        "voicemail",
                        "web_form",
                        "crm_followup",
                        "back_office"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object"
                    },
                    "contactId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "conversationId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "interactionId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "queueId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "dueAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "done",
                        "cancelled"
                      ]
                    },
                    "externalRef": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "createdBy": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "completedAt": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "outcome": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "workItem": {
                      "type": [
                        "object",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "kind",
                    "title",
                    "details",
                    "contactId",
                    "conversationId",
                    "interactionId",
                    "queueId",
                    "priority",
                    "dueAt",
                    "status",
                    "externalRef",
                    "createdBy",
                    "createdAt",
                    "completedAt",
                    "outcome",
                    "workItem"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications": {
      "post": {
        "operationId": "sendNotification",
        "summary": "Send an order update, reminder or one-time code on WhatsApp (an approved template), SMS or e-mail, in the recipient's preferred order with fallback. The message lands on the contact's timeline; a reply routes to agents.",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": [
              "notifications:write"
            ]
          }
        ],
        "x-scope": "notifications:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": [
                        "utility",
                        "authentication"
                      ]
                    },
                    "reference": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "sent",
                        "failed"
                      ]
                    },
                    "channel": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "messageId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "interactionId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "attempts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string"
                          },
                          "outcome": {
                            "type": "string"
                          },
                          "reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "channel",
                          "outcome",
                          "reason"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "contactId",
                    "purpose",
                    "reference",
                    "status",
                    "channel",
                    "messageId",
                    "interactionId",
                    "attempts",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contactId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "to": {
                    "type": "object",
                    "properties": {
                      "phone": {
                        "type": "string",
                        "pattern": "^[+][1-9][0-9]{6,14}$"
                      },
                      "email": {
                        "type": "string",
                        "maxLength": 320
                      }
                    },
                    "required": [],
                    "additionalProperties": false
                  },
                  "purpose": {
                    "type": "string",
                    "enum": [
                      "utility",
                      "authentication"
                    ]
                  },
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "whatsapp",
                        "sms",
                        "email"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 3
                  },
                  "reference": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "whatsapp": {
                    "type": "object",
                    "properties": {
                      "template": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "maxLength": 512
                          },
                          "language": {
                            "type": "string",
                            "maxLength": 20
                          },
                          "category": {
                            "type": "string",
                            "enum": [
                              "utility",
                              "authentication"
                            ]
                          },
                          "parameters": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1024
                            },
                            "maxItems": 20
                          }
                        },
                        "required": [
                          "name",
                          "language"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "template"
                    ],
                    "additionalProperties": false
                  },
                  "sms": {
                    "type": "object",
                    "properties": {
                      "body": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 1600
                      }
                    },
                    "required": [
                      "body"
                    ],
                    "additionalProperties": false
                  },
                  "email": {
                    "type": "object",
                    "properties": {
                      "subject": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "body": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 20000
                      }
                    },
                    "required": [
                      "subject",
                      "body"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "purpose",
                  "channels"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/{id}": {
      "get": {
        "operationId": "getNotification",
        "summary": "One notification with every channel tried.",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": [
              "notifications:write"
            ]
          }
        ],
        "x-scope": "notifications:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "purpose": {
                      "type": "string",
                      "enum": [
                        "utility",
                        "authentication"
                      ]
                    },
                    "reference": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "sent",
                        "failed"
                      ]
                    },
                    "channel": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "messageId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "interactionId": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uuid"
                    },
                    "attempts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "channel": {
                            "type": "string"
                          },
                          "outcome": {
                            "type": "string"
                          },
                          "reason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "channel",
                          "outcome",
                          "reason"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "contactId",
                    "purpose",
                    "reference",
                    "status",
                    "channel",
                    "messageId",
                    "interactionId",
                    "attempts",
                    "createdAt"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/contacts/{id}/notification-preferences": {
      "put": {
        "operationId": "setNotificationPreferences",
        "summary": "A contact's preferred channel order and the channels it opted out of.",
        "tags": [
          "Notifications"
        ],
        "security": [
          {
            "bearerAuth": [
              "contacts:write"
            ]
          }
        ],
        "x-scope": "contacts:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{8,100}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contactId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "channels": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "optedOut": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "contactId",
                    "channels",
                    "optedOut"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The Idempotency-Key was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "whatsapp",
                        "sms",
                        "email"
                      ]
                    },
                    "maxItems": 3
                  },
                  "optedOut": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "whatsapp",
                        "sms",
                        "email"
                      ]
                    },
                    "maxItems": 3
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/qa/evaluations": {
      "get": {
        "operationId": "listQaEvaluations",
        "summary": "Human QA evaluations, newest first (drafts included).",
        "tags": [
          "Quality"
        ],
        "security": [
          {
            "bearerAuth": [
              "qa:read"
            ]
          }
        ],
        "x-scope": "qa:read",
        "parameters": [
          {
            "name": "agentId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "submitted",
                "acknowledged",
                "disputed",
                "upheld",
                "revised"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "formId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "conversationId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "agentId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "evaluatorUserId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "planId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "calibrationId": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "uuid"
                          },
                          "answers": {
                            "type": "object"
                          },
                          "scoreBp": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "criticalFailed": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string"
                          },
                          "comment": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "submittedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "acknowledgedAt": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "id",
                          "formId",
                          "conversationId",
                          "agentId",
                          "evaluatorUserId",
                          "planId",
                          "calibrationId",
                          "answers",
                          "scoreBp",
                          "criticalFailed",
                          "status",
                          "comment",
                          "submittedAt",
                          "acknowledgedAt",
                          "version",
                          "createdAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed: see problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The token lacks the scope, or the address is not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "No such object in your tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "The object is not in a state that allows this.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: wait Retry-After seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Scopes: contacts:read, contacts:write, conversations:read, conversations:write, messages:read, messages:write, interactions:read, campaigns:read, users:read, queues:read, wallet:read, tickets:read, tickets:write, webhooks:read, webhooks:write, reports:read, surveys:read, surveys:write, crm:write, calls:write, leads:write, notifications:write, qa:read, tasks:read, tasks:write, analytics:read, outcomes:write"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "message"
        ],
        "additionalProperties": true
      }
    }
  }
}
