{
  "openapi": "3.1.0",
  "info": {
    "title": "ORQO API",
    "version": "1.0.0",
    "description": "The ORQO REST API: contacts, segments, campaigns, WhatsApp messages, conversations and analytics for one organization. Authenticate with `Authorization: Bearer <token>`. Guides: https://docs.orqo.site"
  },
  "servers": [
    {
      "url": "https://app.orqo.site/api",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "Contacts"
    },
    {
      "name": "Segments"
    },
    {
      "name": "Campaigns"
    },
    {
      "name": "Messages"
    },
    {
      "name": "Conversations"
    },
    {
      "name": "Analytics"
    }
  ],
  "security": [
    {
      "http": []
    }
  ],
  "paths": {
    "/v1/me": {
      "get": {
        "operationId": "retrieve-the-current-user",
        "description": "The user the API token belongs to.",
        "summary": "Retrieve the current user",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "`User`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update-the-current-user",
        "summary": "Update the current user",
        "tags": [
          "Account"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`User`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/organization": {
      "get": {
        "operationId": "retrieve-the-organization",
        "description": "The organization the API token is bound to, with your role in it.",
        "summary": "Retrieve the organization",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "base_currency": {
                          "type": "string"
                        },
                        "role": {
                          "type": "string"
                        },
                        "created_at": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "base_currency",
                        "role",
                        "created_at"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/subscription": {
      "get": {
        "operationId": "retrieve-the-subscription",
        "description": "The organization's current plan, or `\"data\": null` when it has no\ntrial or subscription. Readable even without a subscription.",
        "summary": "Retrieve the subscription",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "No trial or subscription: the organization must subscribe.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "plan": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "slug": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "id",
                                "name",
                                "slug"
                              ]
                            },
                            "billing_cycle": {
                              "type": "string"
                            },
                            "status": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "active",
                                    "inactive"
                                  ]
                                }
                              ]
                            },
                            "renews_at": {
                              "type": "string"
                            },
                            "ends_at": {
                              "type": "string"
                            },
                            "gateway": {
                              "type": "string"
                            },
                            "managed_by_admin": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "plan",
                            "billing_cycle",
                            "status",
                            "renews_at",
                            "ends_at",
                            "gateway",
                            "managed_by_admin"
                          ]
                        }
                      },
                      "required": [
                        "data"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "null"
                        }
                      },
                      "required": [
                        "data"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/subscription/usage": {
      "get": {
        "operationId": "retrieve-plan-usage-limits",
        "summary": "Retrieve plan usage limits",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "plan_name": {
                          "type": "string"
                        },
                        "limits": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "users": {
                              "type": "string"
                            },
                            "storage_mb": {
                              "type": "string"
                            },
                            "storage_gb": {
                              "type": [
                                "number",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "users",
                            "storage_mb",
                            "storage_gb"
                          ]
                        }
                      },
                      "required": [
                        "plan_name",
                        "limits"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/notifications": {
      "get": {
        "operationId": "list-notifications",
        "description": "The current user's in-app notifications, newest first.",
        "summary": "List notifications",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Notification`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Notification"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/notifications/{notification}/read": {
      "post": {
        "operationId": "mark-a-notification-as-read",
        "summary": "Mark a notification as read",
        "tags": [
          "Account"
        ],
        "parameters": [
          {
            "name": "notification",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Notification`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Notification"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/contacts": {
      "get": {
        "operationId": "list-contacts",
        "description": "Newest first. Filter by `search` (name, email or phone), `segment_id`,\n`tag` and `opt_in_whatsapp`.",
        "summary": "List contacts",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Matches first name, last name, email or phone.",
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          },
          {
            "name": "segment_id",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "tag",
            "in": "query",
            "description": "Exact tag name.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "opt_in_whatsapp",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Contact`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create-or-update-a-contact",
        "description": "Contacts are matched like everywhere else in ORQO: by `phone_e164`, or\nby `email` when no phone is given. A new contact is `201`; an existing\none (or a deleted one with that number, which is restored) is updated\nand returned with `200`. `custom_fields` keys must be contact fields\ndefined in Settings. Send an `Idempotency-Key` header to retry safely.",
        "summary": "Create or update a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Any unique string up to 255 characters, such as a UUID. Retrying with the same key returns the first response (with `Idempotent-Replayed: true`) instead of acting twice.",
            "schema": {
              "type": "string"
            },
            "example": "9f1c2a7e-4b8d-4e57-a3f0-6c1d2e3f4a5b"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone_e164": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "E.164 phone number, e.g. `+201001234567`.",
                    "pattern": "^\\+[1-9]\\d{6,14}$"
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "email",
                    "maxLength": 255
                  },
                  "first_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 100
                  },
                  "last_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 100
                  },
                  "country": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "ISO 3166-1 alpha-2 country code.",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "language": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 10
                  },
                  "opt_in_whatsapp": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "custom_fields": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "description": "Values keyed by contact field key (Settings → Contact fields).",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "source": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Defaults to `api`.",
                    "maxLength": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "An existing contact with this phone or email was updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "201": {
            "description": "A new contact was created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/contacts/{id}": {
      "get": {
        "operationId": "retrieve-a-contact",
        "summary": "Retrieve a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Contact`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update-a-contact",
        "description": "Only the fields you send change. A `phone_e164` another contact already\nhas is `422 validation_failed`.",
        "summary": "Update a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "phone_e164": {
                    "type": "string",
                    "pattern": "^\\+[1-9]\\d{6,14}$"
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 255
                  },
                  "first_name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "country": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 2
                  },
                  "language": {
                    "type": "string",
                    "maxLength": 10
                  },
                  "opt_in_whatsapp": {
                    "type": "boolean"
                  },
                  "custom_fields": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 50
                  },
                  "source": {
                    "type": "string",
                    "maxLength": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Contact`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Contact"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete-a-contact",
        "summary": "Delete a contact",
        "tags": [
          "Contacts"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/segments": {
      "get": {
        "operationId": "list-segments",
        "description": "Newest first.",
        "summary": "List segments",
        "tags": [
          "Segments"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Segment`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Segment"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create-a-segment",
        "description": "A dynamic segment is filled from its `rules` right away. Send an `Idempotency-Key` header to retry safely.",
        "summary": "Create a segment",
        "tags": [
          "Segments"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Any unique string up to 255 characters, such as a UUID. Retrying with the same key returns the first response (with `Idempotent-Replayed: true`) instead of acting twice.",
            "schema": {
              "type": "string"
            },
            "example": "9f1c2a7e-4b8d-4e57-a3f0-6c1d2e3f4a5b"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "type": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Defaults to `static`.",
                    "enum": [
                      "static",
                      "dynamic"
                    ]
                  },
                  "rules": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "description": "Filter rules of a dynamic segment.",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`Segment`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Segment"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/segments/{id}": {
      "get": {
        "operationId": "retrieve-a-segment",
        "summary": "Retrieve a segment",
        "tags": [
          "Segments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Segment`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Segment"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/segments/{id}/contacts": {
      "get": {
        "operationId": "list-segment-contacts",
        "description": "Newest first.",
        "summary": "List segment contacts",
        "tags": [
          "Segments"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Contact`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/campaigns": {
      "get": {
        "operationId": "list-campaigns",
        "description": "Newest first. Filter by `channel` and `status`.",
        "summary": "List campaigns",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "whatsapp"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                ""
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Campaign"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create-a-campaign",
        "description": "Creates a draft. Launch it with `POST /campaigns/{id}/launch`. Send an\n`Idempotency-Key` header to retry safely.",
        "summary": "Create a campaign",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Any unique string up to 255 characters, such as a UUID. Retrying with the same key returns the first response (with `Idempotent-Replayed: true`) instead of acting twice.",
            "schema": {
              "type": "string"
            },
            "example": "9f1c2a7e-4b8d-4e57-a3f0-6c1d2e3f4a5b"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "whatsapp"
                    ]
                  },
                  "audience_type": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Defaults to `segment`.",
                    "enum": [
                      "segment",
                      "contact_list",
                      "tag",
                      "csv"
                    ]
                  },
                  "audience_ref": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Segment id, tag name or CSV upload reference, depending on `audience_type`."
                  },
                  "template": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "description": "Approved WhatsApp template: name, language and component parameters.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "payload": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "description": "Extra message payload, such as header media.",
                    "items": {
                      "type": "string"
                    }
                  },
                  "schedule_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time",
                    "description": "ISO 8601 time to send at; omit to send on launch."
                  },
                  "timezone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "IANA time zone, e.g. `Africa/Cairo`.",
                    "maxLength": 64
                  }
                },
                "required": [
                  "name",
                  "channel"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Campaign"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/campaigns/{id}": {
      "get": {
        "operationId": "retrieve-a-campaign",
        "description": "`stats` are recomputed from the recipients on every call.",
        "summary": "Retrieve a campaign",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Campaign"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update-a-campaign",
        "description": "Only draft and paused campaigns can be edited; any other status is\n`409 invalid_state`.",
        "summary": "Update a campaign",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "whatsapp"
                    ]
                  },
                  "audience_type": {
                    "type": "string",
                    "enum": [
                      "segment",
                      "contact_list",
                      "tag",
                      "csv"
                    ]
                  },
                  "audience_ref": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "template": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "string"
                    }
                  },
                  "payload": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "string"
                    }
                  },
                  "schedule_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "timezone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "`Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Campaign"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/campaigns/{id}/launch": {
      "post": {
        "operationId": "launch-a-campaign",
        "description": "Queues the campaign for sending (`202`), now or at `schedule_at`. A\ncampaign that cannot be launched is `422 launch_rejected`. Send an\n`Idempotency-Key` header to retry safely.",
        "summary": "Launch a campaign",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Any unique string up to 255 characters, such as a UUID. Retrying with the same key returns the first response (with `Idempotent-Replayed: true`) instead of acting twice.",
            "schema": {
              "type": "string"
            },
            "example": "9f1c2a7e-4b8d-4e57-a3f0-6c1d2e3f4a5b"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "schedule_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time",
                    "description": "Overrides the campaign's schedule; `null` sends now."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "`Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Campaign"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/campaigns/{id}/pause": {
      "post": {
        "operationId": "pause-a-campaign",
        "description": "Only queued or sending campaigns can be paused; any other status is\n`409 invalid_state`.",
        "summary": "Pause a campaign",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Campaign`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Campaign"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/campaigns/{id}/recipients": {
      "get": {
        "operationId": "list-campaign-recipients",
        "description": "Newest first, with each recipient's delivery status.",
        "summary": "List campaign recipients",
        "tags": [
          "Campaigns"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `CampaignRecipient`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CampaignRecipient"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "send-a-message",
        "description": "Send a WhatsApp text, approved template, interactive message, Flow, or\nmedia message to a contact (`contact_id`) or directly to an E.164\nnumber (`to`). Send an `Idempotency-Key` header (or `client_message_id`)\nto retry safely: a retry returns the original message with\n`Idempotent-Replayed: true`.",
        "summary": "Send a message",
        "tags": [
          "Messages"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Any unique string up to 255 characters, such as a UUID. Retrying with the same key returns the first response (with `Idempotent-Replayed: true`) instead of acting twice.",
            "schema": {
              "type": "string"
            },
            "example": "9f1c2a7e-4b8d-4e57-a3f0-6c1d2e3f4a5b"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/SendMessageRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "`SentMessage`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/SentMessage"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations": {
      "get": {
        "operationId": "list-conversations",
        "description": "Most recently active first. Filter by `channel`, `status` and\n`assigned_to` (a user id).",
        "summary": "List conversations",
        "tags": [
          "Conversations"
        ],
        "parameters": [
          {
            "name": "channel",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                ""
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                ""
              ]
            }
          },
          {
            "name": "assigned_to",
            "in": "query",
            "description": "User id of the assigned agent.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Conversation`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Conversation"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations/{id}": {
      "get": {
        "operationId": "retrieve-a-conversation",
        "summary": "Retrieve a conversation",
        "tags": [
          "Conversations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Conversation`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Conversation"
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations/{id}/messages": {
      "get": {
        "operationId": "list-conversation-messages",
        "description": "Oldest first.",
        "summary": "List conversation messages",
        "tags": [
          "Conversations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Items per page, 1 to 100.",
            "schema": {
              "type": "integer",
              "default": 25
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "`meta.next_cursor` (or `meta.prev_cursor`) of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated set of `Message`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev_cursor": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more",
                        "next_cursor",
                        "prev_cursor"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/analytics/messages": {
      "get": {
        "operationId": "message-volume",
        "description": "Messages per channel between `from` and `to` (dates, `YYYY-MM-DD`;\ndefault the last 30 days, at most 366 days).",
        "summary": "Message volume",
        "tags": [
          "Analytics"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day, `YYYY-MM-DD`. Defaults to 29 days ago.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-01"
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, `YYYY-MM-DD`. Defaults to today.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-22"
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "to": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "from",
                        "to"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/analytics/conversations": {
      "get": {
        "operationId": "conversation-activity",
        "description": "Conversations resolved over time and the channel mix between `from`\nand `to` (same range rules as message volume).",
        "summary": "Conversation activity",
        "tags": [
          "Analytics"
        ],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day, `YYYY-MM-DD`. Defaults to 29 days ago.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-01"
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, `YYYY-MM-DD`. Defaults to today.",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-10-22"
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "over_time": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "channel_mix": {
                          "type": "array",
                          "items": {}
                        }
                      },
                      "required": [
                        "over_time",
                        "channel_mix"
                      ]
                    },
                    "meta": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "to": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "from",
                        "to"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/ValidationFailed"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/analytics/campaigns/{campaignId}/funnel": {
      "get": {
        "operationId": "campaign-funnel",
        "description": "Sent, delivered, read and failed counts of one campaign, delivery over\ntime and the most common failure reasons.",
        "summary": "Campaign funnel",
        "tags": [
          "Analytics"
        ],
        "parameters": [
          {
            "name": "campaignId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "funnel": {
                          "type": "array",
                          "items": {}
                        },
                        "delivery_over_time": {
                          "type": "array",
                          "items": {}
                        },
                        "failed_reasons": {
                          "type": "array",
                          "items": {}
                        }
                      },
                      "required": [
                        "funnel",
                        "delivery_over_time",
                        "failed_reasons"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "http": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Campaign": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "channel": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "audience_type": {
            "type": "string"
          },
          "audience_ref": {
            "type": [
              "string",
              "null"
            ]
          },
          "template": {
            "type": [
              "array",
              "null"
            ],
            "items": {}
          },
          "payload": {
            "type": [
              "array",
              "null"
            ],
            "items": {}
          },
          "schedule_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ]
          },
          "stats": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer"
              },
              "queued": {
                "type": "integer"
              },
              "sent": {
                "type": "integer"
              },
              "delivered": {
                "type": "integer"
              },
              "read": {
                "type": "integer"
              },
              "failed": {
                "type": "integer"
              }
            },
            "required": [
              "total",
              "queued",
              "sent",
              "delivered",
              "read",
              "failed"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "channel",
          "status",
          "audience_type",
          "audience_ref",
          "template",
          "payload",
          "schedule_at",
          "timezone",
          "stats",
          "created_at",
          "updated_at"
        ],
        "title": "Campaign"
      },
      "CampaignRecipient": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "campaign_id": {
            "type": "integer"
          },
          "contact_id": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "provider_message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "error_message": {
            "type": "string"
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "campaign_id",
          "contact_id",
          "status",
          "provider_message_id",
          "error_message",
          "sent_at"
        ],
        "title": "CampaignRecipient"
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "uuid": {
            "type": "string"
          },
          "phone_e164": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "first_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "full_name": {
            "type": "string"
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "language": {
            "type": [
              "string",
              "null"
            ]
          },
          "opt_in_whatsapp": {
            "type": "boolean"
          },
          "custom_fields": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "avatar_url": {
            "type": "string"
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_seen_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "uuid",
          "phone_e164",
          "email",
          "first_name",
          "last_name",
          "full_name",
          "country",
          "language",
          "opt_in_whatsapp",
          "custom_fields",
          "avatar_url",
          "source",
          "last_seen_at",
          "created_at",
          "updated_at"
        ],
        "title": "Contact"
      },
      "Conversation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "channel": {
            "type": "string"
          },
          "channel_account_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "contact_id": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "unread_count": {
            "type": "integer"
          },
          "last_message_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "channel",
          "channel_account_id",
          "contact_id",
          "status",
          "assigned_user_id",
          "unread_count",
          "last_message_at",
          "created_at"
        ],
        "title": "Conversation"
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable, machine-readable error code. Branch on this, never on `message`.",
                "example": "not_found"
              },
              "message": {
                "type": "string",
                "description": "Human-readable explanation. May change without notice.",
                "example": "Contact not found."
              },
              "fields": {
                "type": "object",
                "description": "Validation messages per field (`validation_failed` only).",
                "additionalProperties": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "details": {
                "type": "object",
                "description": "Extra, code-specific context.",
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ],
        "title": "Error"
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "conversation_id": {
            "type": "integer"
          },
          "direction": {
            "type": "string"
          },
          "channel": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "body": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          },
          "provider_message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "sent_by": {
            "type": "string"
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "conversation_id",
          "direction",
          "channel",
          "type",
          "body",
          "status",
          "provider_message_id",
          "sent_by",
          "sent_at",
          "created_at"
        ],
        "title": "Message"
      },
      "Notification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "Notification class name, e.g. `ConversationAssigned`."
          },
          "content": {
            "type": "object",
            "description": "The notification's own fields (title, body, links), by type.\nNot named `data`: that key is the response envelope's.",
            "additionalProperties": {}
          },
          "read_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "type",
          "content",
          "read_at",
          "created_at"
        ],
        "title": "Notification"
      },
      "Segment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "`static` or `dynamic`. @var string"
          },
          "rules": {
            "type": "object",
            "description": "Filter rules of a dynamic segment.",
            "additionalProperties": {}
          },
          "contact_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "rules",
          "contact_count",
          "created_at",
          "updated_at"
        ],
        "title": "Segment"
      },
      "SendMessageRequest": {
        "type": "object",
        "properties": {
          "contact_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\+[1-9]\\d{6,14}$"
          },
          "channel": {
            "type": "string",
            "enum": [
              "whatsapp"
            ]
          },
          "channel_account_id": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "template",
              "interactive",
              "flow",
              "image",
              "video",
              "audio",
              "document",
              "sticker"
            ]
          },
          "client_message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Retrying with the same key never sends twice (scoped to the\nrecipient conversation in this organization).",
            "pattern": "^[A-Za-z0-9._:-]{1,48}$"
          },
          "body": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4096
          },
          "preview_url": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "template_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Backwards-compatible template fields.",
            "maxLength": 128
          },
          "template_language": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 16
          },
          "file": {
            "type": [
              "string",
              "null"
            ],
            "format": "binary",
            "contentMediaType": "application/octet-stream",
            "maxLength": 102400
          },
          "attachment": {
            "type": [
              "string",
              "null"
            ],
            "format": "binary",
            "contentMediaType": "application/octet-stream",
            "maxLength": 102400
          },
          "template_vars": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": [
                "string",
                "null"
              ]
            },
            "maxItems": 100
          },
          "template": {
            "type": "object",
            "description": "Canonical template send shape. Parameter objects are intentionally\nforwarded to Meta so headers, URL/quick-reply/Flow buttons,\ncurrency, date-time and media parameters remain supported.",
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 128
              },
              "language": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 16
              },
              "components": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "maxItems": 20
              }
            }
          },
          "interactive": {
            "type": "object",
            "description": "Meta interactive objects are validated structurally below. The\nallow-list prevents this endpoint becoming an arbitrary Graph API\nproxy while retaining every interactive family Orqo supports.",
            "properties": {
              "type": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "button",
                  "list",
                  "cta_url",
                  "flow",
                  "product",
                  "product_list",
                  "catalog_message",
                  "location_request_message",
                  "address_message"
                ]
              }
            }
          },
          "flow": {
            "type": "object",
            "description": "Developer-friendly Flow form; converted to Meta's interactive\nFlow object by the sender service.",
            "properties": {
              "id": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 128
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 128
              },
              "token": {
                "type": "string",
                "maxLength": 512
              },
              "cta": {
                "type": "string",
                "maxLength": 20
              },
              "action": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "navigate",
                  "data_exchange"
                ]
              },
              "screen": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 128
              },
              "data": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "string"
                }
              },
              "body": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 1024
              },
              "header": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 60
              },
              "footer": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 60
              },
              "mode": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "published",
                  "draft"
                ]
              }
            }
          },
          "media": {
            "type": "object",
            "description": "Media can be an existing Meta media id, a public HTTPS link, or a\nmultipart upload. `attachment` is accepted as an inbox-compatible\nalias for `file`.",
            "properties": {
              "id": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 256
              },
              "link": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri",
                "maxLength": 2048
              },
              "caption": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 1024
              },
              "filename": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 240
              }
            }
          }
        },
        "required": [
          "type"
        ],
        "title": "SendMessageRequest"
      },
      "SentMessage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "provider_message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "WhatsApp message id (`wamid.…`)."
          },
          "status": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "contact_id": {
            "type": "integer"
          },
          "conversation_id": {
            "type": "integer"
          },
          "conversation_uuid": {
            "type": "string"
          },
          "channel_account_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "to": {
            "description": "Recipient phone number in E.164.",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              },
              {}
            ]
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "provider_message_id",
          "status",
          "type",
          "contact_id",
          "conversation_id",
          "conversation_uuid",
          "channel_account_id",
          "to",
          "sent_at"
        ],
        "title": "SentMessage"
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "email_verified_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "role",
          "status",
          "email_verified_at",
          "created_at"
        ],
        "title": "User"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Malformed request, e.g. an invalid Idempotency-Key (`bad_request`, `invalid_idempotency_key`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthenticated": {
        "description": "Missing, invalid or expired API token (`unauthenticated`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "No active subscription (`subscription_required`) or a plan limit is reached (`plan_limit_reached`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "The token may not do this (`forbidden`, `organization_required`, `capability_required`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "The resource does not exist in this organization (`not_found`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "The resource's state does not allow this (`invalid_state`), or the Idempotency-Key clashes (`idempotency_key_reused`, `idempotency_in_progress`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ValidationFailed": {
        "description": "A field is invalid (`validation_failed`); `error.fields` lists the messages per field.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests (`rate_limited`). Wait for `Retry-After` seconds.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
