{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "Coussema Public API",
    "version": "v1",
    "summary": "Programmable SMS delivery, campaign orchestration, contacts, API keys, and webhook endpoints.",
    "description": "Coussema expose une API publique pour envoyer des SMS, gérer les contacts, créer des campagnes et configurer des webhooks sur la même logique métier que le dashboard."
  },
  "servers": [
    {
      "url": "/v1",
      "description": "Relative base path on the API host."
    }
  ],
  "tags": [
    {
      "name": "Platform",
      "description": "Service discovery, health, and machine-readable API metadata."
    },
    {
      "name": "SMS",
      "description": "Single-recipient SMS sends from the developer API."
    },
    {
      "name": "Account",
      "description": "Organization account state, entitlements, and invoice-ready usage history."
    },
    {
      "name": "Contacts",
      "description": "Organization-scoped contact management."
    },
    {
      "name": "Campaigns",
      "description": "Create and list outbound SMS campaigns."
    },
    {
      "name": "API Keys",
      "description": "Manage organization API keys for the developer product."
    },
    {
      "name": "Webhooks",
      "description": "Manage outbound event delivery endpoints."
    }
  ],
  "paths": {
    "/": {
      "get": {
        "tags": [
          "Platform"
        ],
        "operationId": "getApiIndex",
        "summary": "Get API entrypoint metadata",
        "description": "Returns the current API version, the public docs path, and the machine-readable OpenAPI document path.",
        "responses": {
          "200": {
            "description": "API discovery metadata with docs and health paths.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndexResponse"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "Platform"
        ],
        "operationId": "getHealth",
        "summary": "Get API health",
        "description": "Lightweight health probe for uptime and platform status checks.",
        "responses": {
          "200": {
            "description": "Current API health snapshot.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "tags": [
          "Platform"
        ],
        "operationId": "getOpenApiDocument",
        "summary": "Get the OpenAPI 3.1 document",
        "description": "Returns the machine-readable OpenAPI 3.1 contract generated from the shared Zod schemas.",
        "responses": {
          "200": {
            "description": "The current OpenAPI 3.1 document for the public API.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "description": "OpenAPI 3.1 document"
                }
              }
            }
          }
        }
      }
    },
    "/sms/send": {
      "post": {
        "tags": [
          "SMS"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "sendSms",
        "summary": "Send one SMS",
        "description": "Enqueues and dispatches one SMS through the active supplier resolution flow for the authenticated organization.",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestIdHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKeyHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Single-recipient SMS payload.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendSmsRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Transactional send",
                  "value": {
                    "to": "243837509125",
                    "message": "Votre code de verification est 1234.",
                    "senderName": "Coussema",
                    "clientReference": "txn-2026-0001"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SMS accepted by the platform and supplier.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendSmsSuccessResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "getAccountSummary",
        "summary": "Get account commercial summary",
        "description": "Returns the authenticated organization commercial state, current subscription, and remaining quota.",
        "responses": {
          "200": {
            "description": "Current organization commercial summary.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSummaryResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "tags": [
          "Account"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "listUsage",
        "summary": "List quota usage ledger entries",
        "description": "Returns cursor-paginated usage and quota adjustment entries for the authenticated organization.",
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "$ref": "#/components/parameters/CursorQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated commercial usage ledger.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListUsageResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/contacts": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "listContacts",
        "summary": "List contacts",
        "description": "Returns a cursor-paginated collection of organization contacts.",
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "$ref": "#/components/parameters/CursorQuery"
          },
          {
            "$ref": "#/components/parameters/ContactTagQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated organization contacts.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListContactsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "createContact",
        "summary": "Create a contact",
        "description": "Creates one organization contact and normalizes phone/tags server-side.",
        "requestBody": {
          "required": true,
          "description": "Contact creation payload.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContactRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Contact with tags",
                  "value": {
                    "name": "Nadine M.",
                    "phone": "243837509125",
                    "tags": [
                      "vip",
                      "retail"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created contact.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateContactResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "deleteContact",
        "summary": "Delete a contact",
        "description": "Deletes one organization contact by identifier.",
        "parameters": [
          {
            "$ref": "#/components/parameters/ContactIdQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Contact deleted.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/campaigns": {
      "get": {
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "listCampaigns",
        "summary": "List campaigns",
        "description": "Returns cursor-paginated campaigns for the authenticated organization.",
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "$ref": "#/components/parameters/CursorQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated campaign collection.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListCampaignsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "post": {
        "tags": [
          "Campaigns"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "createCampaign",
        "summary": "Create a campaign",
        "description": "Creates one immediate or scheduled SMS campaign on the shared organization-centric runtime.",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestIdHeader"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKeyHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Campaign creation payload.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCampaignRequest"
              },
              "examples": {
                "scheduled": {
                  "summary": "Scheduled campaign",
                  "value": {
                    "name": "Promo week-end",
                    "message_template": "Bonjour {{name}}, profitez de -15% ce week-end.",
                    "scheduled_at": "2026-04-10T08:30:00.000Z",
                    "sender_name": "Coussema",
                    "audience_tags": [
                      "vip",
                      "retail"
                    ],
                    "audience_tag_match_mode": "all"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created campaign.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCampaignResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/api-keys": {
      "get": {
        "tags": [
          "API Keys"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "listApiKeys",
        "summary": "List API keys",
        "description": "Lists the organization API keys visible to the authenticated principal, paginated by cursor.",
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "$ref": "#/components/parameters/CursorQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated API key collection.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListApiKeysResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "post": {
        "tags": [
          "API Keys"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "createApiKey",
        "summary": "Create an API key",
        "description": "Creates a new organization API key and returns the plaintext secret exactly once.",
        "requestBody": {
          "required": true,
          "description": "API key creation payload.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Server integration key",
                  "value": {
                    "name": "Production backend"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created API key.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateApiKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/api-keys/{apiKeyId}": {
      "delete": {
        "tags": [
          "API Keys"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "revokeApiKey",
        "summary": "Revoke an API key",
        "description": "Revokes one organization API key by identifier.",
        "parameters": [
          {
            "$ref": "#/components/parameters/ApiKeyIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "API key revoked.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "listWebhookEndpoints",
        "summary": "List webhook endpoints",
        "description": "Lists outbound webhook endpoints configured for the authenticated organization.",
        "parameters": [
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "$ref": "#/components/parameters/CursorQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated webhook endpoint collection.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListWebhookEndpointsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "createWebhookEndpoint",
        "summary": "Create a webhook endpoint",
        "description": "Registers a webhook endpoint and returns its signing secret once at creation time.",
        "requestBody": {
          "required": true,
          "description": "Webhook endpoint creation payload.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookEndpointRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Message lifecycle events",
                  "value": {
                    "url": "https://example.com/hooks/coussema",
                    "subscribed_events": [
                      "message.sent",
                      "message.delivered",
                      "message.failed"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created webhook endpoint and signing secret.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateWebhookEndpointResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/webhooks/{webhookEndpointId}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "xApiKey": []
          }
        ],
        "operationId": "disableWebhookEndpoint",
        "summary": "Disable a webhook endpoint",
        "description": "Disables an existing outbound webhook endpoint by identifier.",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointIdPath"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook endpoint disabled.",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/XRequestId"
              },
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/XRateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/XRateLimitRemaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/XRateLimitReset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Send your Coussema API key as Authorization: Bearer <api-key>."
      },
      "xApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Alternative header for clients that cannot send Authorization."
      }
    },
    "parameters": {
      "RequestIdHeader": {
        "name": "x-request-id",
        "in": "header",
        "required": false,
        "description": "Optional caller-supplied correlation identifier. The API always echoes a request id in responses.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "IdempotencyKeyHeader": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Recommended for POST requests. Reusing the same key with the same payload replays the stored response.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "LimitQuery": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Maximum number of items to return.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "CursorQuery": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "description": "Opaque cursor returned by the previous page.",
        "schema": {
          "type": "string",
          "minLength": 1
        }
      },
      "ContactTagQuery": {
        "name": "tag",
        "in": "query",
        "required": false,
        "description": "Filter contacts to a single tag value.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        }
      },
      "ContactIdQuery": {
        "name": "id",
        "in": "query",
        "required": true,
        "description": "Contact identifier.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "ApiKeyIdPath": {
        "name": "apiKeyId",
        "in": "path",
        "required": true,
        "description": "API key identifier.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "WebhookEndpointIdPath": {
        "name": "webhookEndpointId",
        "in": "path",
        "required": true,
        "description": "Webhook endpoint identifier.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "headers": {
      "XRequestId": {
        "description": "Unique request correlation id generated or echoed by the API.",
        "schema": {
          "type": "string"
        }
      },
      "XRateLimitLimit": {
        "description": "Rate limit budget allocated to the authenticated API key window.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      },
      "XRateLimitRemaining": {
        "description": "Remaining requests in the current API key window.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      },
      "XRateLimitReset": {
        "description": "Unix timestamp at which the current rate-limit window resets.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying after a rate-limit rejection.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request payload, query, or header values.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ValidationErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key authentication.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Authenticated principal cannot access the requested organization resource.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Requested resource was not found.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Conflict": {
        "description": "The request conflicts with current state or a prior idempotent request.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ConflictErrorResponse"
            }
          }
        }
      },
      "RateLimited": {
        "description": "The authenticated API key exceeded its request budget for the current window.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/XRateLimitLimit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/XRateLimitRemaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/XRateLimitReset"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Unexpected server-side failure.",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/XRequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "ApiIndexResponse": {
        "type": "object",
        "properties": {
          "service": {
            "type": "string",
            "const": "coussema-api"
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "status": {
            "type": "string",
            "const": "available"
          },
          "docsPath": {
            "type": "string",
            "const": "/docs/api"
          },
          "healthPath": {
            "type": "string",
            "const": "/v1/health"
          },
          "openApiPath": {
            "type": "string",
            "const": "/v1/openapi.json"
          }
        },
        "required": [
          "service",
          "version",
          "status",
          "docsPath",
          "healthPath",
          "openApiPath"
        ],
        "additionalProperties": false
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "service": {
            "type": "string",
            "const": "coussema-api"
          },
          "version": {
            "type": "string",
            "const": "v1"
          },
          "status": {
            "type": "string",
            "const": "ok"
          },
          "timestamp": {
            "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": [
          "service",
          "version",
          "status",
          "timestamp"
        ],
        "additionalProperties": false
      },
      "AccountSummaryResponse": {
        "type": "object",
        "properties": {
          "organizationId": {
            "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)$"
          },
          "organizationName": {
            "type": "string",
            "minLength": 1
          },
          "organizationSlug": {
            "type": "string",
            "minLength": 1
          },
          "billingEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "defaultSenderName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "minLength": 1
          },
          "canSend": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "plan": {
            "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)$"
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "includedSms": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "priceUsd": {
                    "type": "number",
                    "minimum": 0
                  },
                  "isActive": {
                    "type": "boolean"
                  },
                  "overageEnabled": {
                    "type": "boolean"
                  },
                  "overageLimitSms": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "overagePriceUsdPerSms": {
                    "type": "number",
                    "minimum": 0
                  },
                  "createdAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "updatedAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "id",
                  "code",
                  "name",
                  "description",
                  "includedSms",
                  "priceUsd",
                  "isActive",
                  "overageEnabled",
                  "overageLimitSms",
                  "overagePriceUsdPerSms",
                  "createdAt",
                  "updatedAt"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "subscription": {
            "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)$"
                  },
                  "planId": {
                    "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"
                      }
                    ]
                  },
                  "status": {
                    "type": "string",
                    "minLength": 1
                  },
                  "smsLimit": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "priceUsd": {
                    "type": "number",
                    "minimum": 0
                  },
                  "startsAt": {
                    "type": "string"
                  },
                  "expiresAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "createdAt": {
                    "type": "string"
                  },
                  "updatedAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "overageEnabled": {
                    "type": "boolean"
                  },
                  "overageLimitSms": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "overagePriceUsdPerSms": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "required": [
                  "id",
                  "planId",
                  "status",
                  "smsLimit",
                  "priceUsd",
                  "startsAt",
                  "expiresAt",
                  "createdAt",
                  "updatedAt",
                  "overageEnabled",
                  "overageLimitSms",
                  "overagePriceUsdPerSms"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "quota": {
            "type": "object",
            "properties": {
              "creditUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "debitUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "remainingUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "limitUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "creditUnits",
              "debitUnits",
              "remainingUnits",
              "limitUnits"
            ],
            "additionalProperties": false
          },
          "overage": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "limitUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "usedUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "remainingUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "billableUnits": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "priceUsdPerSms": {
                "type": "number",
                "minimum": 0
              }
            },
            "required": [
              "enabled",
              "limitUnits",
              "usedUnits",
              "remainingUnits",
              "billableUnits",
              "priceUsdPerSms"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "organizationId",
          "organizationName",
          "organizationSlug",
          "billingEmail",
          "defaultSenderName",
          "status",
          "canSend",
          "createdAt",
          "plan",
          "subscription",
          "quota",
          "overage"
        ],
        "additionalProperties": false
      },
      "ListUsageResponse": {
        "type": "object",
        "properties": {
          "usage": {
            "type": "array",
            "items": {
              "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)$"
                },
                "organizationId": {
                  "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"
                    }
                  ]
                },
                "providerAccountId": {
                  "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"
                    }
                  ]
                },
                "entryType": {
                  "type": "string",
                  "minLength": 1
                },
                "direction": {
                  "type": "string",
                  "enum": [
                    "credit",
                    "debit"
                  ]
                },
                "units": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "referenceType": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "referenceId": {
                  "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"
                    }
                  ]
                },
                "note": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "metadata": {
                  "anyOf": [
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "createdAt": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "organizationId",
                "providerAccountId",
                "entryType",
                "direction",
                "units",
                "referenceType",
                "referenceId",
                "note",
                "metadata",
                "createdAt"
              ],
              "additionalProperties": false
            }
          },
          "pageInfo": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "hasMore": {
                "type": "boolean"
              },
              "nextCursor": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "limit",
              "hasMore",
              "nextCursor"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "usage",
          "pageInfo"
        ],
        "additionalProperties": false
      },
      "SendSmsRequest": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string",
            "minLength": 6,
            "maxLength": 32
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1530
          },
          "senderName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32
          },
          "clientReference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          }
        },
        "required": [
          "to",
          "message"
        ],
        "additionalProperties": false
      },
      "SendSmsSuccessResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "count": {
            "type": "integer",
            "exclusiveMinimum": 0,
            "maximum": 9007199254740991
          },
          "remainingQuota": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "provider": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1
              },
              "messageId": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "httpStatus": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "code",
              "messageId",
              "httpStatus"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "success",
          "count",
          "remainingQuota",
          "provider"
        ],
        "additionalProperties": false
      },
      "CreateContactRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "phone": {
            "type": "string",
            "minLength": 6,
            "maxLength": 32
          },
          "tags": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          }
        },
        "required": [
          "phone"
        ],
        "additionalProperties": false
      },
      "CreateContactResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "contact": {
            "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)$"
              },
              "organization_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)$"
              },
              "name": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "phone": {
                "type": "string"
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "metadata": {
                "anyOf": [
                  {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {}
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "created_at": {
                "type": "string"
              },
              "updated_at": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "organization_id",
              "name",
              "phone",
              "tags",
              "created_at",
              "updated_at"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "success",
          "contact"
        ],
        "additionalProperties": false
      },
      "ListContactsResponse": {
        "type": "object",
        "properties": {
          "contacts": {
            "type": "array",
            "items": {
              "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)$"
                },
                "organization_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)$"
                },
                "name": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "phone": {
                  "type": "string"
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "metadata": {
                  "anyOf": [
                    {
                      "type": "object",
                      "propertyNames": {
                        "type": "string"
                      },
                      "additionalProperties": {}
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "created_at": {
                  "type": "string"
                },
                "updated_at": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "organization_id",
                "name",
                "phone",
                "tags",
                "created_at",
                "updated_at"
              ],
              "additionalProperties": false
            }
          },
          "pageInfo": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "hasMore": {
                "type": "boolean"
              },
              "nextCursor": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "limit",
              "hasMore",
              "nextCursor"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "contacts",
          "pageInfo"
        ],
        "additionalProperties": false
      },
      "CreateCampaignRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          },
          "message_template": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1530
          },
          "scheduled_at": {
            "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"
              }
            ]
          },
          "total_recipients": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "sender_name": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 32
              },
              {
                "type": "null"
              }
            ]
          },
          "audience_preset_id": {
            "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"
              }
            ]
          },
          "audience_tags": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          "audience_tag_match_mode": {
            "type": "string",
            "enum": [
              "any",
              "all"
            ]
          }
        },
        "required": [
          "name",
          "message_template"
        ],
        "additionalProperties": false
      },
      "CreateCampaignResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "campaign": {
            "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)$"
              },
              "organization_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)$"
              },
              "created_by_user_id": {
                "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"
                  }
                ]
              },
              "name": {
                "type": "string"
              },
              "sender_name": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "message_template": {
                "type": "string"
              },
              "audience_preset_id": {
                "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"
                  }
                ]
              },
              "audience_tags": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "audience_tag_match_mode": {
                "type": "string",
                "enum": [
                  "any",
                  "all"
                ]
              },
              "status": {
                "type": "string"
              },
              "scheduled_at": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "total_recipients": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "queued_count": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "sent_count": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "delivered_count": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "failed_count": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "created_at": {
                "type": "string"
              },
              "updated_at": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "organization_id",
              "created_by_user_id",
              "name",
              "sender_name",
              "message_template",
              "audience_preset_id",
              "audience_tags",
              "audience_tag_match_mode",
              "status",
              "scheduled_at",
              "total_recipients",
              "queued_count",
              "sent_count",
              "delivered_count",
              "failed_count",
              "created_at",
              "updated_at"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "success",
          "campaign"
        ],
        "additionalProperties": false
      },
      "ListCampaignsResponse": {
        "type": "object",
        "properties": {
          "campaigns": {
            "type": "array",
            "items": {
              "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)$"
                },
                "organization_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)$"
                },
                "created_by_user_id": {
                  "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"
                    }
                  ]
                },
                "name": {
                  "type": "string"
                },
                "sender_name": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "message_template": {
                  "type": "string"
                },
                "audience_preset_id": {
                  "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"
                    }
                  ]
                },
                "audience_tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "audience_tag_match_mode": {
                  "type": "string",
                  "enum": [
                    "any",
                    "all"
                  ]
                },
                "status": {
                  "type": "string"
                },
                "scheduled_at": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "total_recipients": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "queued_count": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "sent_count": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "delivered_count": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "failed_count": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "created_at": {
                  "type": "string"
                },
                "updated_at": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "organization_id",
                "created_by_user_id",
                "name",
                "sender_name",
                "message_template",
                "audience_preset_id",
                "audience_tags",
                "audience_tag_match_mode",
                "status",
                "scheduled_at",
                "total_recipients",
                "queued_count",
                "sent_count",
                "delivered_count",
                "failed_count",
                "created_at",
                "updated_at"
              ],
              "additionalProperties": false
            }
          },
          "pageInfo": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "hasMore": {
                "type": "boolean"
              },
              "nextCursor": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "limit",
              "hasMore",
              "nextCursor"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "campaigns",
          "pageInfo"
        ],
        "additionalProperties": false
      },
      "CreateApiKeyRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "CreateApiKeyResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "apiKey": {
            "type": "object",
            "properties": {
              "apiKeyId": {
                "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)$"
              },
              "organizationId": {
                "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)$"
              },
              "name": {
                "type": "string",
                "minLength": 1
              },
              "keyPrefix": {
                "type": "string",
                "minLength": 1
              },
              "maskedKey": {
                "type": "string",
                "minLength": 1
              },
              "plainTextKey": {
                "type": "string",
                "minLength": 1
              },
              "lastUsedAt": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "revokedAt": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "createdAt": {
                "type": "string"
              }
            },
            "required": [
              "apiKeyId",
              "organizationId",
              "name",
              "keyPrefix",
              "maskedKey",
              "plainTextKey",
              "lastUsedAt",
              "revokedAt",
              "createdAt"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "success",
          "apiKey"
        ],
        "additionalProperties": false
      },
      "ListApiKeysResponse": {
        "type": "object",
        "properties": {
          "apiKeys": {
            "type": "array",
            "items": {
              "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)$"
                },
                "organizationId": {
                  "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)$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "keyPrefix": {
                  "type": "string",
                  "minLength": 1
                },
                "maskedKey": {
                  "type": "string",
                  "minLength": 1
                },
                "lastUsedAt": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "revokedAt": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "createdAt": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "organizationId",
                "name",
                "keyPrefix",
                "maskedKey",
                "lastUsedAt",
                "revokedAt",
                "createdAt"
              ],
              "additionalProperties": false
            }
          },
          "pageInfo": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "hasMore": {
                "type": "boolean"
              },
              "nextCursor": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "limit",
              "hasMore",
              "nextCursor"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "apiKeys",
          "pageInfo"
        ],
        "additionalProperties": false
      },
      "CreateWebhookEndpointRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "subscribed_events": {
            "minItems": 1,
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "message.queued",
                "message.sent",
                "message.delivered",
                "message.failed"
              ]
            }
          }
        },
        "required": [
          "url",
          "subscribed_events"
        ],
        "additionalProperties": false
      },
      "CreateWebhookEndpointResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "webhookEndpoint": {
            "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)$"
              },
              "organization_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)$"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "subscribed_events": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "message.queued",
                    "message.sent",
                    "message.delivered",
                    "message.failed"
                  ]
                }
              },
              "status": {
                "type": "string"
              },
              "created_at": {
                "type": "string"
              },
              "updated_at": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "organization_id",
              "url",
              "subscribed_events",
              "status",
              "created_at",
              "updated_at"
            ],
            "additionalProperties": false
          },
          "signingSecret": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "success",
          "webhookEndpoint",
          "signingSecret"
        ],
        "additionalProperties": false
      },
      "ListWebhookEndpointsResponse": {
        "type": "object",
        "properties": {
          "webhookEndpoints": {
            "type": "array",
            "items": {
              "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)$"
                },
                "organization_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)$"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "subscribed_events": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "message.queued",
                      "message.sent",
                      "message.delivered",
                      "message.failed"
                    ]
                  }
                },
                "status": {
                  "type": "string"
                },
                "created_at": {
                  "type": "string"
                },
                "updated_at": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "organization_id",
                "url",
                "subscribed_events",
                "status",
                "created_at",
                "updated_at"
              ],
              "additionalProperties": false
            }
          },
          "pageInfo": {
            "type": "object",
            "properties": {
              "limit": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              },
              "hasMore": {
                "type": "boolean"
              },
              "nextCursor": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "limit",
              "hasMore",
              "nextCursor"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "webhookEndpoints",
          "pageInfo"
        ],
        "additionalProperties": false
      },
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "success"
        ],
        "additionalProperties": false
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "requestId"
        ],
        "additionalProperties": true
      },
      "ConflictErrorResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ErrorResponse"
          },
          {
            "type": "object",
            "properties": {
              "remainingQuota": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          }
        ]
      },
      "ValidationErrorResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ErrorResponse"
          },
          {
            "type": "object",
            "properties": {
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "path",
                    "message"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        ]
      }
    }
  }
}
