{
  "openapi": "3.1.0",
  "info": {
    "title": "Partner API",
    "version": "1.0.0",
    "summary": "Run WhatsApp for many shops from your own software.",
    "description": "Server-to-server API. Authenticate with `Authorization: Bearer sjp_...`. Every request and response is JSON; successful responses are wrapped as `{ \"data\": ... }` and errors as `{ \"error\": { \"code\", \"message\" } }`. Webhook payloads and the signature recipe are described under `webhooks` and in docs/PARTNER_GUIDE.md."
  },
  "servers": [
    {
      "url": "/partner/v1"
    }
  ],
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "Shops"
    },
    {
      "name": "Connection"
    },
    {
      "name": "Sending"
    },
    {
      "name": "Reconciliation"
    },
    {
      "name": "Webhook"
    },
    {
      "name": "Docs"
    }
  ],
  "paths": {
    "/account": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "Account"
        ],
        "summary": "Your account: billing mode, safety policy, sending switch",
        "security": [
          {
            "partnerKey": [
              "shops:read"
            ]
          }
        ],
        "x-scope": "shops:read",
        "x-rate-limit-per-minute": 600,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Account"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sending/suspend": {
      "post": {
        "operationId": "suspendSending",
        "tags": [
          "Account"
        ],
        "summary": "Stop ALL sending for every shop",
        "description": "The partner-wide kill switch. While on, every send is refused with `sending_suspended` and queued messages are cancelled instead of sent. Connections stay up.",
        "security": [
          {
            "partnerKey": [
              "sending:control"
            ]
          }
        ],
        "x-scope": "sending:control",
        "x-rate-limit-per-minute": 60,
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Account"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sending/resume": {
      "post": {
        "operationId": "resumeSending",
        "tags": [
          "Account"
        ],
        "summary": "Allow sending again",
        "security": [
          {
            "partnerKey": [
              "sending:control"
            ]
          }
        ],
        "x-scope": "sending:control",
        "x-rate-limit-per-minute": 60,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Account"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops": {
      "post": {
        "operationId": "createShop",
        "tags": [
          "Shops"
        ],
        "summary": "Create a shop (workspace + number), idempotent on externalId",
        "description": "Creates the shop and its WhatsApp number slot. Calling it again with the same externalId returns the existing shop (200) and never creates a second one. The instance token is returned only when the shop is created (201); lose it and use rotate-token.",
        "security": [
          {
            "partnerKey": [
              "shops:write"
            ]
          }
        ],
        "x-scope": "shops:write",
        "x-rate-limit-per-minute": 300,
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "externalId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": [
                  "externalId",
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ShopCreated"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "external_id_deleted"
        ]
      },
      "get": {
        "operationId": "listShops",
        "tags": [
          "Shops"
        ],
        "summary": "List your shops",
        "security": [
          {
            "partnerKey": [
              "shops:read"
            ]
          }
        ],
        "x-scope": "shops:read",
        "x-rate-limit-per-minute": 600,
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "suspended",
                "paused_suspected_ban",
                "deleted"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 300
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}": {
      "get": {
        "operationId": "getShop",
        "tags": [
          "Shops"
        ],
        "summary": "Read one shop, its state, warm-up and limits",
        "security": [
          {
            "partnerKey": [
              "shops:read"
            ]
          }
        ],
        "x-scope": "shops:read",
        "x-rate-limit-per-minute": 1200,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Shop"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "shop_not_found"
        ]
      },
      "delete": {
        "operationId": "deleteShop",
        "tags": [
          "Shops"
        ],
        "summary": "Delete a shop (soft): unlink the number, wipe credentials, keep message and usage history",
        "security": [
          {
            "partnerKey": [
              "shops:write"
            ]
          }
        ],
        "x-scope": "shops:write",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Shop"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/state": {
      "get": {
        "operationId": "getShopState",
        "tags": [
          "Shops"
        ],
        "summary": "Connection state only (cheap to poll)",
        "security": [
          {
            "partnerKey": [
              "shops:read"
            ]
          }
        ],
        "x-scope": "shops:read",
        "x-rate-limit-per-minute": 1200,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ShopState"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/suspend": {
      "post": {
        "operationId": "suspendShop",
        "tags": [
          "Shops"
        ],
        "summary": "Suspend a shop: stop its session and refuse sends",
        "security": [
          {
            "partnerKey": [
              "shops:write"
            ]
          }
        ],
        "x-scope": "shops:write",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 200
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Shop"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/resume": {
      "post": {
        "operationId": "resumeShop",
        "tags": [
          "Shops"
        ],
        "summary": "Resume a suspended (or auto-paused) shop",
        "security": [
          {
            "partnerKey": [
              "shops:write"
            ]
          }
        ],
        "x-scope": "shops:write",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Shop"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/token/rotate": {
      "post": {
        "operationId": "rotateShopToken",
        "tags": [
          "Shops"
        ],
        "summary": "Rotate the shop's instance token (shown once)",
        "security": [
          {
            "partnerKey": [
              "shops:write"
            ]
          }
        ],
        "x-scope": "shops:write",
        "x-rate-limit-per-minute": 60,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/limits": {
      "patch": {
        "operationId": "setShopLimits",
        "tags": [
          "Shops"
        ],
        "summary": "Lower or raise a shop's caps (never above your account policy)",
        "security": [
          {
            "partnerKey": [
              "shops:write"
            ]
          }
        ],
        "x-scope": "shops:write",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dailyCap": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1000
                  },
                  "hourlyCap": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 200
                  },
                  "perRecipientHourly": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 5
                  },
                  "perRecipientDaily": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Shop"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "limit_above_policy"
        ]
      }
    },
    "/shops/{externalId}/opt-outs": {
      "get": {
        "operationId": "listShopOptOuts",
        "tags": [
          "Shops"
        ],
        "summary": "People who replied STOP (they are never messaged again)",
        "security": [
          {
            "partnerKey": [
              "shops:read"
            ]
          }
        ],
        "x-scope": "shops:read",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/connect": {
      "post": {
        "operationId": "connectShop",
        "tags": [
          "Connection"
        ],
        "summary": "Start the shop's session",
        "security": [
          {
            "partnerKey": [
              "connect"
            ]
          }
        ],
        "x-scope": "connect",
        "x-rate-limit-per-minute": 120,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ShopState"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/qr": {
      "get": {
        "operationId": "getShopQr",
        "tags": [
          "Connection"
        ],
        "summary": "Short-lived QR code to scan (starts the session if needed)",
        "description": "Poll every ~3 seconds while the shop owner scans. The code rotates about every 20 seconds. When `state` becomes `connected`, stop polling (or wait for the instance.state webhook).",
        "security": [
          {
            "partnerKey": [
              "connect"
            ]
          }
        ],
        "x-scope": "connect",
        "x-rate-limit-per-minute": 120,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Qr"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/pairing-code": {
      "post": {
        "operationId": "getShopPairingCode",
        "tags": [
          "Connection"
        ],
        "summary": "Link by typing a code on the phone instead of scanning",
        "security": [
          {
            "partnerKey": [
              "connect"
            ]
          }
        ],
        "x-scope": "connect",
        "x-rate-limit-per-minute": 30,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phoneNumber": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 30,
                    "description": "The number of the phone being linked, international format"
                  }
                },
                "required": [
                  "phoneNumber"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "already_connected",
          "invalid_phone"
        ]
      }
    },
    "/shops/{externalId}/logout": {
      "post": {
        "operationId": "logoutShop",
        "tags": [
          "Connection"
        ],
        "summary": "Unlink the number so the shop can link another one",
        "description": "Wipes the stored credentials. The warm-up period restarts with the next number.",
        "security": [
          {
            "partnerKey": [
              "connect"
            ]
          }
        ],
        "x-scope": "connect",
        "x-rate-limit-per-minute": 30,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ShopState"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/shops/{externalId}/messages/text": {
      "post": {
        "operationId": "sendText",
        "tags": [
          "Sending"
        ],
        "summary": "Send a text message",
        "description": "Returns 202 immediately: the message is queued, not delivered. Watch the webhook (or poll) for its status. A recipient who is not on WhatsApp is refused up front with `not_on_whatsapp` and is never billed.",
        "security": [
          {
            "partnerKey": [
              "messages:send"
            ]
          }
        ],
        "x-scope": "messages:send",
        "x-rate-limit-per-minute": 600,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A unique key per message you want to send (max 128 chars). Retrying with the same key never sends twice.",
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 30
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4096
                  },
                  "reference": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9_.-]{1,40}$"
                    },
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                },
                "required": [
                  "to",
                  "text"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/SendResult"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "idempotency_key_required",
          "idempotency_key_reused",
          "not_on_whatsapp",
          "recipient_opted_out",
          "daily_limit_reached",
          "hourly_limit_reached",
          "warmup_limit_reached",
          "recipient_rate_limited",
          "instance_not_connected",
          "sending_suspended",
          "shop_suspended",
          "shop_paused_suspected_ban",
          "shop_deleted"
        ]
      }
    },
    "/shops/{externalId}/messages/document": {
      "post": {
        "operationId": "sendDocument",
        "tags": [
          "Sending"
        ],
        "summary": "Send a PDF / document / image, by URL or by upload",
        "description": "Either JSON with a `url` (https, on a host in your allow-list; fetched safely, 25 MB max) or multipart/form-data with a `file` part. Same rules and responses as text.",
        "security": [
          {
            "partnerKey": [
              "messages:send"
            ]
          }
        ],
        "x-scope": "messages:send",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "The partner's own id for the shop",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "description": "The partner's own id for the shop"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A unique key per message you want to send (max 128 chars). Retrying with the same key never sends twice.",
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 30
                  },
                  "url": {
                    "type": "string",
                    "maxLength": 2000,
                    "format": "uri"
                  },
                  "fileName": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "caption": {
                    "type": "string",
                    "maxLength": 1024
                  },
                  "kind": {
                    "default": "document",
                    "type": "string",
                    "enum": [
                      "document",
                      "image"
                    ]
                  },
                  "reference": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9_.-]{1,40}$"
                    },
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 200
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "boolean"
                        }
                      ]
                    }
                  }
                },
                "required": [
                  "to",
                  "url"
                ],
                "additionalProperties": false
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "caption": {
                    "type": "string"
                  },
                  "fileName": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "document",
                      "image"
                    ]
                  },
                  "reference": {
                    "description": "JSON object as a string",
                    "type": "string"
                  }
                },
                "required": [
                  "to",
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/SendResult"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "file_host_not_allowed",
          "url_blocked",
          "file_too_large",
          "unsupported_file_type",
          "not_on_whatsapp",
          "idempotency_key_required",
          "idempotency_key_reused",
          "daily_limit_reached",
          "hourly_limit_reached",
          "warmup_limit_reached",
          "recipient_rate_limited"
        ]
      }
    },
    "/messages": {
      "get": {
        "operationId": "listMessages",
        "tags": [
          "Reconciliation"
        ],
        "summary": "List messages by date range (or by what changed)",
        "description": "Oldest first, keyset-paginated: follow `nextCursor` until it is null. Rows younger than 2 seconds are held back (`settledUntil`) so a cursor can never skip a row. Use `from`/`to` to enumerate a period, and `updatedSince` to pick up status and billing changes.",
        "security": [
          {
            "partnerKey": [
              "messages:read"
            ]
          }
        ],
        "x-scope": "messages:read",
        "x-rate-limit-per-minute": 600,
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "Messages CREATED at or after this time (UTC)",
            "schema": {
              "description": "Messages CREATED at or after this time (UTC)",
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "Messages created before this time (default: now)",
            "schema": {
              "description": "Messages created before this time (default: now)",
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "required": false,
            "description": "Alternative to from/to: everything that CHANGED at or after this time (status, billing)",
            "schema": {
              "description": "Alternative to from/to: everything that CHANGED at or after this time (status, billing)",
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            }
          },
          {
            "name": "shop",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "sent",
                "delivered",
                "read",
                "failed"
              ]
            }
          },
          {
            "name": "billable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "referenceKey",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 40
            }
          },
          {
            "name": "referenceValue",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 300
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MessageList"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "date_range_required",
          "invalid_cursor"
        ]
      }
    },
    "/messages/{messageId}": {
      "get": {
        "operationId": "getMessage",
        "tags": [
          "Reconciliation"
        ],
        "summary": "Read one message and its usage record",
        "security": [
          {
            "partnerKey": [
              "messages:read"
            ]
          }
        ],
        "x-scope": "messages:read",
        "x-rate-limit-per-minute": 1200,
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Message"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/usage/summary": {
      "get": {
        "operationId": "getUsageSummary",
        "tags": [
          "Reconciliation"
        ],
        "summary": "Counts by status and billing outcome for a period",
        "security": [
          {
            "partnerKey": [
              "usage:read"
            ]
          }
        ],
        "x-scope": "usage:read",
        "x-rate-limit-per-minute": 120,
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/UsageSummary"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/statement": {
      "get": {
        "operationId": "getStatement",
        "tags": [
          "Reconciliation"
        ],
        "summary": "Monthly statement: billable messages and what Sendjade bills you",
        "description": "Messages count in the month they BECAME billable (UTC), so a message is in exactly one statement and a closed month never changes.",
        "security": [
          {
            "partnerKey": [
              "usage:read"
            ]
          }
        ],
        "x-scope": "usage:read",
        "x-rate-limit-per-minute": 60,
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "required": true,
            "description": "YYYY-MM",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])$",
              "description": "YYYY-MM"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Statement"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "invalid_month"
        ]
      }
    },
    "/webhook": {
      "get": {
        "operationId": "getWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Webhook configuration and health",
        "security": [
          {
            "partnerKey": [
              "webhook:manage"
            ]
          }
        ],
        "x-scope": "webhook:manage",
        "x-rate-limit-per-minute": 300,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Webhook"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Set the webhook URL, event filter or enabled flag",
        "description": "The signing secret is generated the first time and returned ONCE in `secret`.",
        "security": [
          {
            "partnerKey": [
              "webhook:manage"
            ]
          }
        ],
        "x-scope": "webhook:manage",
        "x-rate-limit-per-minute": 60,
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 500,
                    "format": "uri"
                  },
                  "events": {
                    "description": "Empty / omitted = all events",
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "message.queued",
                        "message.sent",
                        "message.delivered",
                        "message.read",
                        "message.failed",
                        "instance.state",
                        "shop.status"
                      ]
                    }
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "https_required",
          "url_blocked",
          "invalid_event"
        ]
      }
    },
    "/webhook/rotate-secret": {
      "post": {
        "operationId": "rotateWebhookSecret",
        "tags": [
          "Webhook"
        ],
        "summary": "New signing secret (returned once)",
        "security": [
          {
            "partnerKey": [
              "webhook:manage"
            ]
          }
        ],
        "x-scope": "webhook:manage",
        "x-rate-limit-per-minute": 30,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook/test": {
      "post": {
        "operationId": "testWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Send a signed webhook.test event",
        "security": [
          {
            "partnerKey": [
              "webhook:manage"
            ]
          }
        ],
        "x-scope": "webhook:manage",
        "x-rate-limit-per-minute": 30,
        "parameters": [],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebhookDelivery"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-errors": [
          "webhook_not_configured"
        ]
      }
    },
    "/webhook/deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "tags": [
          "Webhook"
        ],
        "summary": "Recent deliveries and their outcome",
        "security": [
          {
            "partnerKey": [
              "webhook:manage"
            ]
          }
        ],
        "x-scope": "webhook:manage",
        "x-rate-limit-per-minute": 300,
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "success",
                "failed"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook/deliveries/{deliveryId}/redeliver": {
      "post": {
        "operationId": "redeliverWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Send a delivery again (same event id and body)",
        "security": [
          {
            "partnerKey": [
              "webhook:manage"
            ]
          }
        ],
        "x-scope": "webhook:manage",
        "x-rate-limit-per-minute": 60,
        "parameters": [
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/WebhookDelivery"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "tags": [
          "Docs"
        ],
        "summary": "This API as an OpenAPI 3.1 document",
        "security": [],
        "x-rate-limit-per-minute": 60,
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "partnerEvent": {
      "post": {
        "summary": "An event delivered to your webhook URL",
        "description": "POSTed as JSON with headers `X-Sendjade-Signature: t=<unix>,v1=<hex>` (HMAC-SHA256 of `<t>.<raw body>` with your webhook secret), `X-Sendjade-Event`, `X-Sendjade-Delivery`. Answer with any 2xx within 10 seconds. Failed deliveries are retried with exponential backoff (8 attempts) and can be redelivered.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Received"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "partnerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A partner key (sjp_...). Create and rotate keys with Sendjade support; shown once."
      }
    },
    "schemas": {
      "Usage": {
        "type": "object",
        "properties": {
          "usageId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
            "description": "Stable and unique per message. Use it as the idempotency key of your own charge: charge a usageId at most once."
          },
          "billable": {
            "type": "boolean",
            "description": "Becomes true once the billing condition is met (see billableOn). Only ever goes false -> true."
          },
          "reason": {
            "type": "string",
            "enum": [
              "queued",
              "awaiting_delivery",
              "accepted",
              "delivered",
              "failed",
              "cancelled",
              "delivery_unconfirmed"
            ]
          },
          "billableAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "deliveryUnconfirmed": {
            "type": "boolean",
            "description": "Accepted by WhatsApp but no delivery receipt after 24 hours. Not billable unless a receipt arrives later."
          }
        },
        "required": [
          "usageId",
          "billable",
          "reason",
          "billableAt",
          "deliveryUnconfirmed"
        ],
        "additionalProperties": false
      },
      "Message": {
        "type": "object",
        "properties": {
          "messageId": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "shop": {
            "type": "object",
            "properties": {
              "externalId": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "externalId"
            ],
            "additionalProperties": false
          },
          "to": {
            "type": "string",
            "description": "Recipient phone number, digits only"
          },
          "type": {
            "type": "string",
            "description": "text | document | image"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "sent",
              "delivered",
              "read",
              "failed"
            ]
          },
          "errorCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "errorMessage": {
            "type": [
              "string",
              "null"
            ]
          },
          "reference": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ],
            "description": "The structured reference you sent, returned unchanged"
          },
          "idempotencyKey": {
            "type": [
              "string",
              "null"
            ]
          },
          "fileName": {
            "type": [
              "string",
              "null"
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "usageId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "Stable and unique per message. Use it as the idempotency key of your own charge: charge a usageId at most once."
              },
              "billable": {
                "type": "boolean",
                "description": "Becomes true once the billing condition is met (see billableOn). Only ever goes false -> true."
              },
              "reason": {
                "type": "string",
                "enum": [
                  "queued",
                  "awaiting_delivery",
                  "accepted",
                  "delivered",
                  "failed",
                  "cancelled",
                  "delivery_unconfirmed"
                ]
              },
              "billableAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "deliveryUnconfirmed": {
                "type": "boolean",
                "description": "Accepted by WhatsApp but no delivery receipt after 24 hours. Not billable unless a receipt arrives later."
              }
            },
            "required": [
              "usageId",
              "billable",
              "reason",
              "billableAt",
              "deliveryUnconfirmed"
            ],
            "additionalProperties": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "sentAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "deliveredAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "readAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          }
        },
        "required": [
          "messageId",
          "shop",
          "to",
          "type",
          "status",
          "errorCode",
          "errorMessage",
          "reference",
          "idempotencyKey",
          "fileName",
          "usage",
          "createdAt",
          "sentAt",
          "deliveredAt",
          "readAt",
          "updatedAt"
        ],
        "additionalProperties": false
      },
      "Shop": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "paused_suspected_ban",
              "deleted"
            ]
          },
          "statusReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "statusChangedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "deletedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "instance": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "created",
                      "qr_pending",
                      "connecting",
                      "connected",
                      "disconnected",
                      "logged_out",
                      "failed",
                      "suspected_ban"
                    ]
                  },
                  "connectionStatus": {
                    "type": "string"
                  },
                  "phoneNumber": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "firstLinkedAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lastConnectedAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lastDisconnect": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "note": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "code",
                          "note"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "warmup": {
                    "type": "object",
                    "properties": {
                      "active": {
                        "type": "boolean"
                      },
                      "endsAt": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "dailyCap": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "hourlyCap": {
                        "type": [
                          "number",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "active",
                      "endsAt",
                      "dailyCap",
                      "hourlyCap"
                    ],
                    "additionalProperties": false
                  },
                  "limits": {
                    "type": "object",
                    "properties": {
                      "dailyCap": {
                        "type": "number"
                      },
                      "hourlyCap": {
                        "type": "number"
                      },
                      "perRecipientHourly": {
                        "type": "number"
                      },
                      "perRecipientDaily": {
                        "type": "number"
                      },
                      "gapMs": {
                        "type": "number"
                      },
                      "gapJitterMs": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "dailyCap",
                      "hourlyCap",
                      "perRecipientHourly",
                      "perRecipientDaily",
                      "gapMs",
                      "gapJitterMs"
                    ],
                    "additionalProperties": false
                  },
                  "sent24h": {
                    "type": "number"
                  }
                },
                "required": [
                  "id",
                  "state",
                  "connectionStatus",
                  "phoneNumber",
                  "firstLinkedAt",
                  "lastConnectedAt",
                  "lastDisconnect",
                  "warmup",
                  "limits",
                  "sent24h"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "externalId",
          "name",
          "status",
          "statusReason",
          "statusChangedAt",
          "createdAt",
          "deletedAt",
          "instance"
        ],
        "additionalProperties": false
      },
      "ShopCreated": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "paused_suspected_ban",
              "deleted"
            ]
          },
          "statusReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "statusChangedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "deletedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "instance": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "state": {
                    "type": "string",
                    "enum": [
                      "created",
                      "qr_pending",
                      "connecting",
                      "connected",
                      "disconnected",
                      "logged_out",
                      "failed",
                      "suspected_ban"
                    ]
                  },
                  "connectionStatus": {
                    "type": "string"
                  },
                  "phoneNumber": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "firstLinkedAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lastConnectedAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "lastDisconnect": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "note": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "code",
                          "note"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "warmup": {
                    "type": "object",
                    "properties": {
                      "active": {
                        "type": "boolean"
                      },
                      "endsAt": {
                        "anyOf": [
                          {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "dailyCap": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "hourlyCap": {
                        "type": [
                          "number",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "active",
                      "endsAt",
                      "dailyCap",
                      "hourlyCap"
                    ],
                    "additionalProperties": false
                  },
                  "limits": {
                    "type": "object",
                    "properties": {
                      "dailyCap": {
                        "type": "number"
                      },
                      "hourlyCap": {
                        "type": "number"
                      },
                      "perRecipientHourly": {
                        "type": "number"
                      },
                      "perRecipientDaily": {
                        "type": "number"
                      },
                      "gapMs": {
                        "type": "number"
                      },
                      "gapJitterMs": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "dailyCap",
                      "hourlyCap",
                      "perRecipientHourly",
                      "perRecipientDaily",
                      "gapMs",
                      "gapJitterMs"
                    ],
                    "additionalProperties": false
                  },
                  "sent24h": {
                    "type": "number"
                  }
                },
                "required": [
                  "id",
                  "state",
                  "connectionStatus",
                  "phoneNumber",
                  "firstLinkedAt",
                  "lastConnectedAt",
                  "lastDisconnect",
                  "warmup",
                  "limits",
                  "sent24h"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "created": {
            "type": "boolean"
          },
          "instanceToken": {
            "description": "Shown only when the shop is created (201)",
            "type": [
              "string",
              "null"
            ]
          },
          "notice": {
            "type": "string"
          }
        },
        "required": [
          "externalId",
          "name",
          "status",
          "statusReason",
          "statusChangedAt",
          "createdAt",
          "deletedAt",
          "instance",
          "created",
          "instanceToken"
        ],
        "additionalProperties": false
      },
      "ShopState": {
        "type": "object",
        "properties": {
          "externalId": {
            "type": "string"
          },
          "shopStatus": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "created",
              "qr_pending",
              "connecting",
              "connected",
              "disconnected",
              "logged_out",
              "failed",
              "suspected_ban"
            ]
          },
          "connectionStatus": {
            "type": "string"
          },
          "phoneNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "lastConnectedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastDisconnect": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "code",
                  "note"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          }
        },
        "required": [
          "externalId",
          "shopStatus",
          "state",
          "connectionStatus",
          "phoneNumber",
          "lastConnectedAt",
          "lastDisconnect",
          "checkedAt"
        ],
        "additionalProperties": false
      },
      "Qr": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "created",
              "qr_pending",
              "connecting",
              "connected",
              "disconnected",
              "logged_out",
              "failed",
              "suspected_ban"
            ]
          },
          "qr": {
            "description": "PNG as a data URL (data:image/png;base64,...). Show it in an <img>. Null when there is nothing to scan (already connected, or not ready yet).",
            "type": [
              "string",
              "null"
            ]
          },
          "expiresInSeconds": {
            "type": [
              "number",
              "null"
            ]
          },
          "refreshAfterSeconds": {
            "type": [
              "number",
              "null"
            ]
          },
          "phoneNumber": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "state",
          "qr",
          "expiresInSeconds",
          "refreshAfterSeconds",
          "phoneNumber"
        ],
        "additionalProperties": false
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "hasSecret": {
            "type": "boolean"
          },
          "health": {
            "type": "object",
            "properties": {
              "pending": {
                "type": "number"
              },
              "failedLast24h": {
                "type": "number"
              },
              "deliveredLast24h": {
                "type": "number"
              },
              "lastSuccessAt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "lastFailureAt": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "lastError": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "pending",
              "failedLast24h",
              "deliveredLast24h",
              "lastSuccessAt",
              "lastFailureAt",
              "lastError"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "url",
          "enabled",
          "events",
          "hasSecret",
          "health"
        ],
        "additionalProperties": false
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "eventId": {
            "type": "string"
          },
          "sequence": {
            "type": "number"
          },
          "type": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "messageId": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "success",
              "failed"
            ]
          },
          "attempts": {
            "type": "number"
          },
          "lastStatusCode": {
            "type": [
              "number",
              "null"
            ]
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ]
          },
          "nextAttemptAt": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "deliveredAt": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "eventId",
          "sequence",
          "type",
          "externalId",
          "messageId",
          "status",
          "attempts",
          "lastStatusCode",
          "lastError",
          "nextAttemptAt",
          "createdAt",
          "deliveredAt"
        ],
        "additionalProperties": false
      },
      "WebhookEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique event id (evt_...). The same id is used for retries and redeliveries: de-duplicate on it."
          },
          "type": {
            "type": "string",
            "enum": [
              "message.queued",
              "message.sent",
              "message.delivered",
              "message.read",
              "message.failed",
              "instance.state",
              "shop.status",
              "webhook.test"
            ]
          },
          "sequence": {
            "type": "number",
            "description": "Global, increasing. If two events for one message arrive out of order, trust the higher sequence."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "externalId": {
            "description": "The shop's externalId",
            "type": [
              "string",
              "null"
            ]
          },
          "messageId": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "reference": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ],
            "description": "The reference you sent with the message, unchanged"
          },
          "data": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {},
            "description": "message.*: { status, to, type, errorCode, errorMessage, usage, idempotencyKey, sentAt, deliveredAt, readAt, occurredAt }. instance.state: { state, status, reason, shopStatus, phoneNumber, occurredAt }. shop.status: { status, reason, occurredAt }."
          }
        },
        "required": [
          "id",
          "type",
          "sequence",
          "createdAt",
          "externalId",
          "messageId",
          "reference",
          "data"
        ],
        "additionalProperties": false
      },
      "Account": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "billableOn": {
            "type": "string",
            "enum": [
              "ACCEPTED",
              "DELIVERED"
            ]
          },
          "allowedFileHosts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sendingSuspended": {
            "type": "boolean"
          },
          "sendingSuspendedReason": {
            "type": [
              "string",
              "null"
            ]
          },
          "policy": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "number"
            }
          },
          "ceilings": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "number"
            }
          }
        },
        "required": [
          "name",
          "slug",
          "status",
          "billableOn",
          "allowedFileHosts",
          "sendingSuspended",
          "sendingSuspendedReason",
          "policy",
          "ceilings"
        ],
        "additionalProperties": false
      },
      "Statement": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string"
          },
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string"
              },
              "to": {
                "type": "string"
              }
            },
            "required": [
              "from",
              "to"
            ],
            "additionalProperties": false
          },
          "closed": {
            "type": "boolean"
          },
          "usage": {
            "type": "object",
            "properties": {
              "billableMessages": {
                "type": "number"
              },
              "messagesCreated": {
                "type": "number"
              },
              "failed": {
                "type": "number"
              },
              "deliveryUnconfirmed": {
                "type": "number"
              },
              "billableByType": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "number"
                }
              },
              "billableByShop": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "externalId": {
                      "type": "string"
                    },
                    "billableMessages": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "externalId",
                    "billableMessages"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "billableMessages",
              "messagesCreated",
              "failed",
              "deliveryUnconfirmed",
              "billableByType",
              "billableByShop"
            ],
            "additionalProperties": false
          },
          "sendjadeFee": {
            "type": "object",
            "properties": {
              "currency": {
                "type": "string",
                "const": "USD"
              },
              "numbers": {
                "type": "number"
              },
              "minBilledNumbers": {
                "type": "number"
              },
              "billedNumbers": {
                "type": "number"
              },
              "perNumberCents": {
                "type": "number"
              },
              "totalCents": {
                "type": "number"
              },
              "messagesIncluded": {
                "type": "boolean"
              }
            },
            "required": [
              "currency",
              "numbers",
              "minBilledNumbers",
              "billedNumbers",
              "perNumberCents",
              "totalCents",
              "messagesIncluded"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "month",
          "period",
          "closed",
          "usage",
          "sendjadeFee"
        ],
        "additionalProperties": false
      },
      "UsageSummary": {
        "type": "object",
        "properties": {
          "total": {
            "type": "number"
          },
          "byStatus": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "number"
            }
          },
          "billable": {
            "type": "number"
          },
          "notBillable": {
            "type": "number"
          },
          "byReason": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "number"
            }
          },
          "byShop": {
            "type": "array",
            "items": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": [
                  "string",
                  "number"
                ]
              }
            }
          }
        },
        "required": [
          "total",
          "byStatus",
          "billable",
          "notBillable",
          "byReason",
          "byShop"
        ],
        "additionalProperties": false
      },
      "MessageList": {
        "type": "object",
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "messageId": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "shop": {
                  "type": "object",
                  "properties": {
                    "externalId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "externalId"
                  ],
                  "additionalProperties": false
                },
                "to": {
                  "type": "string",
                  "description": "Recipient phone number, digits only"
                },
                "type": {
                  "type": "string",
                  "description": "text | document | image"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "queued",
                    "sent",
                    "delivered",
                    "read",
                    "failed"
                  ]
                },
                "errorCode": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "errorMessage": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "reference": {
                  "anyOf": [
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    {
                      "type": "null"
                    }
                  ],
                  "description": "The structured reference you sent, returned unchanged"
                },
                "idempotencyKey": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "fileName": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "usage": {
                  "type": "object",
                  "properties": {
                    "usageId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "Stable and unique per message. Use it as the idempotency key of your own charge: charge a usageId at most once."
                    },
                    "billable": {
                      "type": "boolean",
                      "description": "Becomes true once the billing condition is met (see billableOn). Only ever goes false -> true."
                    },
                    "reason": {
                      "type": "string",
                      "enum": [
                        "queued",
                        "awaiting_delivery",
                        "accepted",
                        "delivered",
                        "failed",
                        "cancelled",
                        "delivery_unconfirmed"
                      ]
                    },
                    "billableAt": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deliveryUnconfirmed": {
                      "type": "boolean",
                      "description": "Accepted by WhatsApp but no delivery receipt after 24 hours. Not billable unless a receipt arrives later."
                    }
                  },
                  "required": [
                    "usageId",
                    "billable",
                    "reason",
                    "billableAt",
                    "deliveryUnconfirmed"
                  ],
                  "additionalProperties": false
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                },
                "sentAt": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "deliveredAt": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "readAt": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "updatedAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                }
              },
              "required": [
                "messageId",
                "shop",
                "to",
                "type",
                "status",
                "errorCode",
                "errorMessage",
                "reference",
                "idempotencyKey",
                "fileName",
                "usage",
                "createdAt",
                "sentAt",
                "deliveredAt",
                "readAt",
                "updatedAt"
              ],
              "additionalProperties": false
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "settledUntil": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
            "description": "Everything with a timestamp before this is complete in this view"
          },
          "mode": {
            "type": "string",
            "enum": [
              "created",
              "updated"
            ]
          }
        },
        "required": [
          "messages",
          "nextCursor",
          "settledUntil",
          "mode"
        ],
        "additionalProperties": false
      },
      "SendResult": {
        "type": "object",
        "properties": {
          "message": {
            "type": "object",
            "properties": {
              "messageId": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
              },
              "shop": {
                "type": "object",
                "properties": {
                  "externalId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "externalId"
                ],
                "additionalProperties": false
              },
              "to": {
                "type": "string",
                "description": "Recipient phone number, digits only"
              },
              "type": {
                "type": "string",
                "description": "text | document | image"
              },
              "status": {
                "type": "string",
                "enum": [
                  "queued",
                  "sent",
                  "delivered",
                  "read",
                  "failed"
                ]
              },
              "errorCode": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "errorMessage": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "reference": {
                "anyOf": [
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "The structured reference you sent, returned unchanged"
              },
              "idempotencyKey": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "fileName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "usage": {
                "type": "object",
                "properties": {
                  "usageId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                    "description": "Stable and unique per message. Use it as the idempotency key of your own charge: charge a usageId at most once."
                  },
                  "billable": {
                    "type": "boolean",
                    "description": "Becomes true once the billing condition is met (see billableOn). Only ever goes false -> true."
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "queued",
                      "awaiting_delivery",
                      "accepted",
                      "delivered",
                      "failed",
                      "cancelled",
                      "delivery_unconfirmed"
                    ]
                  },
                  "billableAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "deliveryUnconfirmed": {
                    "type": "boolean",
                    "description": "Accepted by WhatsApp but no delivery receipt after 24 hours. Not billable unless a receipt arrives later."
                  }
                },
                "required": [
                  "usageId",
                  "billable",
                  "reason",
                  "billableAt",
                  "deliveryUnconfirmed"
                ],
                "additionalProperties": false
              },
              "createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              },
              "sentAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "deliveredAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "readAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              }
            },
            "required": [
              "messageId",
              "shop",
              "to",
              "type",
              "status",
              "errorCode",
              "errorMessage",
              "reference",
              "idempotencyKey",
              "fileName",
              "usage",
              "createdAt",
              "sentAt",
              "deliveredAt",
              "readAt",
              "updatedAt"
            ],
            "additionalProperties": false
          },
          "duplicate": {
            "type": "boolean",
            "description": "true when this Idempotency-Key was already used: the original message is returned and nothing new is sent"
          }
        },
        "required": [
          "message",
          "duplicate"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "retryAfterSeconds": {
                "type": "integer"
              }
            },
            "additionalProperties": true
          }
        }
      }
    }
  },
  "x-error-codes": [
    {
      "code": "validation_error",
      "status": 400,
      "description": "The request body or query is invalid. `details` lists each problem."
    },
    {
      "code": "idempotency_key_required",
      "status": 400,
      "description": "Sending needs an Idempotency-Key header (max 128 characters)."
    },
    {
      "code": "invalid_idempotency_key",
      "status": 400,
      "description": "The Idempotency-Key is too long."
    },
    {
      "code": "invalid_chat_id",
      "status": 400,
      "description": "The recipient is not a valid phone number."
    },
    {
      "code": "date_range_required",
      "status": 400,
      "description": "GET /messages needs `from` (or `updatedSince`)."
    },
    {
      "code": "invalid_phone",
      "status": 400,
      "description": "The phone number is not valid: use international format, digits only."
    },
    {
      "code": "invalid_event",
      "status": 400,
      "description": "Unknown webhook event type in the filter."
    },
    {
      "code": "range_too_large",
      "status": 400,
      "description": "Ask for at most 93 days of usage at a time."
    },
    {
      "code": "invalid_cursor",
      "status": 400,
      "description": "The pagination cursor is not valid."
    },
    {
      "code": "invalid_month",
      "status": 400,
      "description": "month must look like 2026-11."
    },
    {
      "code": "https_required",
      "status": 400,
      "description": "The webhook URL must use https."
    },
    {
      "code": "unauthorized",
      "status": 401,
      "description": "Missing, wrong, revoked or expired key."
    },
    {
      "code": "missing_scope",
      "status": 403,
      "description": "The key does not carry the scope this endpoint needs."
    },
    {
      "code": "ip_not_allowed",
      "status": 403,
      "description": "The key is restricted to other IP addresses."
    },
    {
      "code": "partner_suspended",
      "status": 403,
      "description": "Your partner account is suspended."
    },
    {
      "code": "sending_suspended",
      "status": 403,
      "description": "Sending is switched off for your whole account (see POST /sending/resume)."
    },
    {
      "code": "shop_suspended",
      "status": 403,
      "description": "This shop is suspended."
    },
    {
      "code": "shop_paused_suspected_ban",
      "status": 403,
      "description": "The shop was paused automatically because WhatsApp may have restricted its number."
    },
    {
      "code": "shop_not_found",
      "status": 404,
      "description": "No such shop for your account."
    },
    {
      "code": "not_found",
      "status": 404,
      "description": "No such resource for your account."
    },
    {
      "code": "external_id_deleted",
      "status": 409,
      "description": "A shop with this externalId was deleted. Use a new externalId."
    },
    {
      "code": "instance_not_connected",
      "status": 409,
      "description": "The shop's number is not linked or not connected right now."
    },
    {
      "code": "idempotency_key_reused",
      "status": 409,
      "description": "The Idempotency-Key was used before for a different message."
    },
    {
      "code": "already_connected",
      "status": 409,
      "description": "The shop is already linked."
    },
    {
      "code": "webhook_not_configured",
      "status": 409,
      "description": "Set the webhook URL first."
    },
    {
      "code": "shop_deleted",
      "status": 410,
      "description": "The shop was deleted."
    },
    {
      "code": "file_too_large",
      "status": 413,
      "description": "Files can be at most 25 MB."
    },
    {
      "code": "unsupported_file_type",
      "status": 415,
      "description": "That file type cannot be sent."
    },
    {
      "code": "no_file",
      "status": 422,
      "description": "Provide a url, or upload a file."
    },
    {
      "code": "not_on_whatsapp",
      "status": 422,
      "description": "The recipient is not on WhatsApp. Nothing was queued or billed."
    },
    {
      "code": "recipient_opted_out",
      "status": 422,
      "description": "The recipient replied STOP and must not be messaged."
    },
    {
      "code": "recipient_not_allowed",
      "status": 422,
      "description": "Only direct messages to phone numbers are allowed (no groups)."
    },
    {
      "code": "file_host_not_allowed",
      "status": 422,
      "description": "The file URL is not https or its host is not in your allow-list. Upload the file instead."
    },
    {
      "code": "url_blocked",
      "status": 422,
      "description": "The URL points at a private or internal address."
    },
    {
      "code": "content_type_not_allowed",
      "status": 422,
      "description": "Only text and documents can be sent."
    },
    {
      "code": "limit_above_policy",
      "status": 422,
      "description": "A shop limit cannot exceed your account policy."
    },
    {
      "code": "warmup_limit_reached",
      "status": 429,
      "description": "A new number is limited during its first 7 days. Carries retryAfterSeconds."
    },
    {
      "code": "daily_limit_reached",
      "status": 429,
      "description": "The number reached its 24-hour cap. Carries retryAfterSeconds."
    },
    {
      "code": "hourly_limit_reached",
      "status": 429,
      "description": "The number reached its hourly cap. Carries retryAfterSeconds."
    },
    {
      "code": "recipient_rate_limited",
      "status": 429,
      "description": "Too many messages to the same person. Carries retryAfterSeconds."
    },
    {
      "code": "rate_limited",
      "status": 429,
      "description": "Too many API requests for this key."
    },
    {
      "code": "number_check_failed",
      "status": 503,
      "description": "Could not check the number against WhatsApp. Retry; nothing was queued or billed."
    }
  ]
}
