{
  "openapi": "3.1.0",
  "info": {
    "title": "Amivu API",
    "version": "1.0.0",
    "summary": "Integrate once. Talk on any channel.",
    "description": "The Amivu API turns your product into a participant in your customers'\nconversations — on WhatsApp, on the website chat, and on the channels that\ncome after — through one unified surface.\n\nYou never call a channel directly. You address a **conversation**, and the\nconversation knows which channel it runs on. That is what makes the code you\nwrite today keep working when your customer connects a new channel tomorrow.",
    "contact": {
      "name": "Amivu",
      "url": "https://developers.amivu.com.br"
    }
  },
  "servers": [
    {
      "url": "https://api.amivu.com.br/v1",
      "description": "Production and sandbox share one address. The environment comes from the key: `amivu_live_…` touches real data, `amivu_test_…` touches an isolated sandbox."
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "tags": [
    {
      "name": "contacts"
    },
    {
      "name": "conversations"
    },
    {
      "name": "messages"
    },
    {
      "name": "uploads"
    },
    {
      "name": "attachments"
    },
    {
      "name": "channels"
    },
    {
      "name": "users"
    },
    {
      "name": "teams"
    },
    {
      "name": "tags"
    },
    {
      "name": "custom-fields"
    },
    {
      "name": "webhooks"
    }
  ],
  "paths": {
    "/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "List contacts",
        "description": "Returns the organization's contacts, newest first. Filter by `email`, `phone` or `external_id` to find a specific person without paging through the whole base.",
        "tags": ["contacts"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "contacts:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "exclusiveMinimum": false,
              "maximum": 100,
              "exclusiveMaximum": false,
              "default": 25
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 254
            }
          },
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          {
            "name": "query",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "tag_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^tag_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
            }
          },
          {
            "name": "created_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "created_before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createContact",
        "summary": "Create a contact",
        "description": "Creates a contact. When `external_id` is provided and already exists, the existing contact is returned unchanged — which makes CRM synchronisation safe to re-run.",
        "tags": ["contacts"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "contacts:write",
        "x-amivu-idempotent": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "first_name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254
                  },
                  "phone": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 32
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "avatar_url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  },
                  "tags": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "string",
                      "pattern": "^tag_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                    }
                  },
                  "custom_fields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 500
                    }
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{contact_id}": {
      "get": {
        "operationId": "getContact",
        "summary": "Retrieve a contact",
        "description": "Returns a single contact, with its tags and custom fields.",
        "tags": ["contacts"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "contacts:read",
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `contact_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateContact",
        "summary": "Update a contact",
        "description": "Updates the given fields. Sending `tags` REPLACES the contact's tags; sending `null` in a custom field clears it.",
        "tags": ["contacts"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "contacts:write",
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `contact_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "first_name": {
                    "type": "string",
                    "maxLength": 80,
                    "nullable": true
                  },
                  "last_name": {
                    "type": "string",
                    "maxLength": 120,
                    "nullable": true
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254,
                    "nullable": true
                  },
                  "phone": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 32,
                    "nullable": true
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "nullable": true
                  },
                  "avatar_url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500,
                    "nullable": true
                  },
                  "tags": {
                    "type": "array",
                    "maxItems": 50,
                    "items": {
                      "type": "string",
                      "pattern": "^tag_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                    }
                  },
                  "custom_fields": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 500,
                      "nullable": true
                    }
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteContact",
        "summary": "Delete a contact",
        "description": "Deletes the contact and, in cascade, the conversations and messages exchanged with that person. This cannot be undone.",
        "tags": ["contacts"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "contacts:write",
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `contact_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations": {
      "get": {
        "operationId": "listConversations",
        "summary": "List conversations",
        "description": "Returns conversations, newest first, filterable by status, channel and assignee.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "exclusiveMinimum": false,
              "maximum": 100,
              "exclusiveMaximum": false,
              "default": 25
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["open", "pending", "closed"]
            }
          },
          {
            "name": "channel_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^chn_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
            }
          },
          {
            "name": "channel_type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["whatsapp", "instagram", "messenger", "email", "webchat"]
            }
          },
          {
            "name": "contact_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^cnt_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
            }
          },
          {
            "name": "assigned_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^usr_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
            }
          },
          {
            "name": "team_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^team_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
            }
          },
          {
            "name": "tag_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^tag_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          {
            "name": "created_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "created_before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Conversation"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createConversation",
        "summary": "Open a conversation",
        "description": "Opens a conversation with a contact. When `external_id` is provided and already exists, the existing conversation is returned — so a retry does not split the history in two.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:write",
        "x-amivu-idempotent": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact_id": {
                    "type": "string",
                    "pattern": "^cnt_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                  },
                  "channel_id": {
                    "type": "string",
                    "pattern": "^chn_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "required": ["contact_id"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}": {
      "get": {
        "operationId": "getConversation",
        "summary": "Retrieve a conversation",
        "description": "Returns a single conversation.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:read",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateConversation",
        "summary": "Update a conversation",
        "description": "Updates status, `external_id` or `metadata`.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": ["open", "pending", "closed"]
                  },
                  "external_id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "nullable": true
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/close": {
      "post": {
        "operationId": "closeConversation",
        "summary": "Close a conversation",
        "description": "Marks the conversation as resolved and stamps the time it happened.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/reopen": {
      "post": {
        "operationId": "reopenConversation",
        "summary": "Reopen a conversation",
        "description": "Brings a closed conversation back to `open`.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/assign": {
      "post": {
        "operationId": "assignConversation",
        "summary": "Assign a conversation",
        "description": "Assigns the conversation to an agent or a team. The agent must belong to this organization — assigning across organizations is refused.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_id": {
                    "type": "string",
                    "pattern": "^usr_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                  },
                  "team_id": {
                    "type": "string",
                    "pattern": "^team_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/unassign": {
      "post": {
        "operationId": "unassignConversation",
        "summary": "Unassign a conversation",
        "description": "Removes the current assignee.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "conversations:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/messages": {
      "get": {
        "operationId": "listMessages",
        "summary": "List messages in a conversation",
        "description": "Returns the conversation's messages, newest first.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "messages:read",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "exclusiveMinimum": false,
              "maximum": 100,
              "exclusiveMaximum": false,
              "default": 25
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["inbound", "outbound"]
            }
          },
          {
            "name": "created_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "created_before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/notes": {
      "get": {
        "operationId": "listNotes",
        "summary": "List internal notes",
        "description": "Returns the conversation's internal notes. Notes are never delivered to the contact — they are a different entity from messages, with no send path at all.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "notes:read",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Note"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createNote",
        "summary": "Write an internal note",
        "description": "Adds an internal note. It stays inside Amivu.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "notes:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 5000
                  }
                },
                "required": ["body"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/tags": {
      "post": {
        "operationId": "addConversationTag",
        "summary": "Tag a conversation",
        "description": "Applies a tag to the conversation's CONTACT — the only tag link the domain has. The tag follows the person across every conversation, filter and broadcast.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "tags:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tag_id": {
                    "type": "string",
                    "pattern": "^tag_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                  }
                },
                "required": ["tag_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/conversations/{conversation_id}/tags/{tag_id}": {
      "delete": {
        "operationId": "removeConversationTag",
        "summary": "Remove a tag from a conversation",
        "description": "Removes the tag from the conversation's contact.",
        "tags": ["conversations"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "tags:write",
        "parameters": [
          {
            "name": "conversation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `conversation_01K7ZF…`."
          },
          {
            "name": "tag_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `tag_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/messages": {
      "post": {
        "operationId": "sendMessage",
        "summary": "Send a message",
        "description": "Sends a message through the conversation's channel. The channel is derived from the conversation — there is no per-channel endpoint. Capabilities are checked before anything is written: a channel that does not support the type refuses with `unsupported_message_type` and nothing is recorded. Text and media are sent: for `image`, `video`, `audio` and `document`, upload the file first with `POST /uploads` and pass its `attachment_id`. `template` is part of the schema but is not sent yet — it is refused with `unsupported_message_type` on every channel.",
        "tags": ["messages"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "messages:write",
        "x-amivu-idempotent": true,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "description": "Message to send through the conversation's channel.",
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "conversation_id": {
                        "type": "string",
                        "pattern": "^conv_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                      },
                      "type": {
                        "type": "string",
                        "enum": ["text"]
                      },
                      "text": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 4096
                      },
                      "metadata": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "required": ["conversation_id", "type", "text"]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "conversation_id": {
                        "type": "string",
                        "pattern": "^conv_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                      },
                      "type": {
                        "type": "string",
                        "enum": ["image", "video", "audio", "document"]
                      },
                      "attachment_id": {
                        "type": "string",
                        "pattern": "^att_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                      },
                      "text": {
                        "type": "string",
                        "maxLength": 1024
                      },
                      "metadata": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "required": ["conversation_id", "type", "attachment_id"]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "conversation_id": {
                        "type": "string",
                        "pattern": "^conv_[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$"
                      },
                      "type": {
                        "type": "string",
                        "enum": ["template"]
                      },
                      "template": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 120
                          },
                          "language": {
                            "type": "string",
                            "minLength": 2,
                            "maxLength": 16
                          },
                          "variables": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string",
                              "maxLength": 1000
                            },
                            "default": {}
                          }
                        },
                        "required": ["name", "language"]
                      },
                      "metadata": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "required": ["conversation_id", "type", "template"]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/uploads": {
      "post": {
        "operationId": "createUpload",
        "summary": "Upload an attachment",
        "description": "Uploads a file to be sent as media with `POST /messages`. The body is `multipart/form-data` with the file in `file`; the returned `att_…` id is valid for the organization and environment of the key that uploaded it, until `expires_at`, and can be sent to as many conversations as you like within that window. The same media types and size limit apply as when an agent attaches a file in the inbox. `Idempotency-Key` is ignored here: uploading twice only creates a second attachment that expires unused.",
        "tags": ["uploads"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "messages:write",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["file"],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The file, up to 16 MB. Accepted types — image (image/jpeg, image/png, image/webp); audio (audio/aac, audio/mp4, audio/mpeg, audio/amr, audio/ogg); document (application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/plain); video (video/mp4, video/3gpp)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Attachment"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/attachments/{attachment_id}/content": {
      "get": {
        "operationId": "downloadAttachment",
        "summary": "Download an attachment",
        "description": "Returns the file behind an attachment — the one in `attachment.url` of a message, including media RECEIVED from the contact (what `message.received` carries), or a file uploaded with `POST /uploads` while it is valid. The body is the raw bytes, with `Content-Type`, `Content-Disposition` (the original file name) and `Cache-Control: private`. Only attachments of the key's organization and environment are reachable; anything else is `attachment_not_found`.",
        "tags": ["attachments"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "messages:read",
        "parameters": [
          {
            "name": "attachment_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `attachment_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/messages/{message_id}": {
      "get": {
        "operationId": "getMessage",
        "summary": "Retrieve a message",
        "description": "Returns a message and its delivery state. `status` may be `null` — that is information, not absence of it: the channel does not report receipts.",
        "tags": ["messages"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "messages:read",
        "parameters": [
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `message_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/channels": {
      "get": {
        "operationId": "listChannels",
        "summary": "List channels",
        "description": "Returns the connected channels and what each one can do. Read `capabilities` before sending — it is generated from the implementation, not from the provider's brochure.",
        "tags": ["channels"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "channels:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Channel"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/channels/{channel_id}": {
      "get": {
        "operationId": "getChannel",
        "summary": "Retrieve a channel",
        "description": "Returns one channel, with its capability matrix.",
        "tags": ["channels"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "channels:read",
        "parameters": [
          {
            "name": "channel_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `channel_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Channel"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "operationId": "listUsers",
        "summary": "List agents",
        "description": "Returns the organization's agents.",
        "tags": ["users"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "users:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "exclusiveMinimum": false,
              "maximum": 100,
              "exclusiveMaximum": false,
              "default": 25
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/users/{user_id}": {
      "get": {
        "operationId": "getUser",
        "summary": "Retrieve an agent",
        "description": "Returns one agent.",
        "tags": ["users"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "users:read",
        "parameters": [
          {
            "name": "user_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `user_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams": {
      "get": {
        "operationId": "listTeams",
        "summary": "List teams",
        "description": "Returns the organization's teams.",
        "tags": ["teams"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "teams:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Team"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTeam",
        "summary": "Create a team",
        "description": "Creates a team.",
        "tags": ["teams"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "teams:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  }
                },
                "required": ["name"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Team"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{team_id}": {
      "get": {
        "operationId": "getTeam",
        "summary": "Retrieve a team",
        "description": "Returns one team.",
        "tags": ["teams"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "teams:read",
        "parameters": [
          {
            "name": "team_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `team_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Team"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/teams/{team_id}/users": {
      "get": {
        "operationId": "listTeamUsers",
        "summary": "List a team's agents",
        "description": "Returns the agents that belong to the team.",
        "tags": ["teams"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "teams:read",
        "parameters": [
          {
            "name": "team_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `team_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tags": {
      "get": {
        "operationId": "listTags",
        "summary": "List tags",
        "description": "Returns the organization's tags.",
        "tags": ["tags"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "tags:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tag"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTag",
        "summary": "Create a tag",
        "description": "Creates a tag.",
        "tags": ["tags"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "tags:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                  }
                },
                "required": ["name"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/tags/{tag_id}": {
      "patch": {
        "operationId": "updateTag",
        "summary": "Update a tag",
        "description": "Renames the tag or changes its colour.",
        "tags": ["tags"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "tags:write",
        "parameters": [
          {
            "name": "tag_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `tag_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  },
                  "color": {
                    "type": "string",
                    "pattern": "^#[0-9a-fA-F]{6}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tag"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteTag",
        "summary": "Delete a tag",
        "description": "Deletes the tag; it disappears from every contact that had it.",
        "tags": ["tags"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "tags:write",
        "parameters": [
          {
            "name": "tag_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `tag_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/custom-fields": {
      "get": {
        "operationId": "listCustomFields",
        "summary": "List custom fields",
        "description": "Returns the custom field catalogue. The `key` of each field is what appears in `contact.custom_fields`, and it never changes after creation.",
        "tags": ["custom-fields"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "custom_fields:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomField"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCustomField",
        "summary": "Create a custom field",
        "description": "Creates a custom field definition.",
        "tags": ["custom-fields"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "custom_fields:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "key": {
                    "type": "string",
                    "pattern": "^[a-z][a-z0-9_]{0,79}$"
                  },
                  "scope": {
                    "type": "string",
                    "enum": ["contact", "organization"],
                    "default": "contact"
                  },
                  "value": {
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "required": ["name"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomField"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "summary": "List webhook endpoints",
        "description": "Returns the endpoints registered for THIS key's environment. Secrets come masked.",
        "tags": ["webhooks"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "webhooks:read",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhook",
        "summary": "Register a webhook endpoint",
        "description": "Registers an endpoint. The signing secret comes in full in this response and never again — store it before you move on. The endpoint's environment is taken from the API key, not from the body.",
        "tags": ["webhooks"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "webhooks:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 240
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 40,
                    "items": {
                      "type": "string",
                      "enum": [
                        "message.received",
                        "message.sent",
                        "message.delivered",
                        "message.read",
                        "message.failed",
                        "conversation.created",
                        "conversation.updated",
                        "conversation.assigned",
                        "conversation.closed",
                        "conversation.reopened",
                        "contact.created",
                        "contact.updated",
                        "tag.added",
                        "tag.removed"
                      ]
                    }
                  },
                  "environment": {
                    "type": "string",
                    "enum": ["live", "test"],
                    "default": "live"
                  },
                  "enabled": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": ["url", "events"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{webhook_id}": {
      "get": {
        "operationId": "getWebhook",
        "summary": "Retrieve a webhook endpoint",
        "description": "Returns one endpoint, with the secret masked.",
        "tags": ["webhooks"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "webhooks:read",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `webhook_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateWebhook",
        "summary": "Update a webhook endpoint",
        "description": "Updates the URL, description, subscribed events or enabled state. Re-enabling clears the failure counter.",
        "tags": ["webhooks"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "webhooks:write",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `webhook_01K7ZF…`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 500
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 240,
                    "nullable": true
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 40,
                    "items": {
                      "type": "string",
                      "enum": [
                        "message.received",
                        "message.sent",
                        "message.delivered",
                        "message.read",
                        "message.failed",
                        "conversation.created",
                        "conversation.updated",
                        "conversation.assigned",
                        "conversation.closed",
                        "conversation.reopened",
                        "contact.created",
                        "contact.updated",
                        "tag.added",
                        "tag.removed"
                      ]
                    }
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook endpoint",
        "description": "Deletes the endpoint and its delivery history.",
        "tags": ["webhooks"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "webhooks:write",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `webhook_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{webhook_id}/deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "summary": "List deliveries",
        "description": "Returns one row per ATTEMPT, newest first. Attempts of the same event share `event_id` — which is also what you should deduplicate on when receiving.",
        "tags": ["webhooks"],
        "security": [
          {
            "ApiKey": []
          }
        ],
        "x-amivu-scope": "webhooks:read",
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Amivu id, e.g. `webhook_01K7ZF…`."
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string",
                      "enum": ["list"]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "has_more": {
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": ["has_more", "next_cursor"]
                    }
                  },
                  "required": ["object", "data", "pagination"]
                }
              }
            },
            "headers": {
              "X-Amivu-Request-Id": {
                "description": "The identifier of this request. Quote it to support.",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Requests left in the current window.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "4XX": {
            "description": "The request was refused. See `error.code`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "5XX": {
            "description": "Something went wrong on our side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Send your key as `Authorization: Bearer amivu_live_…`. Keys carry scopes; a route refuses with `insufficient_scope` when the scope is missing."
      }
    },
    "schemas": {
      "Contact": {
        "type": "object",
        "description": "A person on the other side of a conversation.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["contact"]
          },
          "id": {
            "type": "string",
            "example": "cnt_01K7ZFA5X8Q2M4N6P8R0T2V4W6"
          },
          "name": {
            "type": "string"
          },
          "first_name": {
            "type": "string",
            "nullable": true
          },
          "last_name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "example": "+5511999999999",
            "nullable": true
          },
          "external_id": {
            "type": "string",
            "example": "customer_8291",
            "nullable": true
          },
          "avatar_url": {
            "type": "string",
            "format": "uri",
            "nullable": true
          },
          "tags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Tag"
            }
          },
          "custom_fields": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "name",
          "first_name",
          "last_name",
          "email",
          "phone",
          "external_id",
          "avatar_url",
          "tags",
          "custom_fields",
          "metadata",
          "created_at",
          "updated_at"
        ]
      },
      "Conversation": {
        "type": "object",
        "description": "A thread with one contact, on one channel.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["conversation"]
          },
          "id": {
            "type": "string",
            "example": "conv_01K7ZFA5X8Q2M4N6P8R0T2V4W6"
          },
          "status": {
            "type": "string",
            "enum": ["open", "pending", "closed"]
          },
          "contact_id": {
            "type": "string"
          },
          "channel": {
            "$ref": "#/components/schemas/ChannelRef",
            "nullable": true
          },
          "assigned_user_id": {
            "type": "string",
            "nullable": true
          },
          "team_id": {
            "type": "string",
            "nullable": true
          },
          "external_id": {
            "type": "string",
            "nullable": true
          },
          "last_message_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "closed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "status",
          "contact_id",
          "channel",
          "assigned_user_id",
          "team_id",
          "external_id",
          "last_message_at",
          "closed_at",
          "metadata",
          "created_at",
          "updated_at"
        ]
      },
      "Message": {
        "type": "object",
        "description": "One message, in either direction.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["message"]
          },
          "id": {
            "type": "string",
            "example": "msg_01K7ZFA5X8Q2M4N6P8R0T2V4W6"
          },
          "conversation_id": {
            "type": "string"
          },
          "contact_id": {
            "type": "string"
          },
          "channel": {
            "$ref": "#/components/schemas/ChannelRef",
            "nullable": true
          },
          "direction": {
            "type": "string",
            "enum": ["inbound", "outbound"]
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "video",
              "audio",
              "document",
              "template",
              "location",
              "contact",
              "interactive"
            ]
          },
          "text": {
            "type": "string",
            "nullable": true
          },
          "attachment": {
            "$ref": "#/components/schemas/Attachment",
            "nullable": true
          },
          "template": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true
          },
          "status": {
            "description": "Delivery state. `null` means the channel does not report receipts — it is information, not a missing value.",
            "nullable": true,
            "type": "string",
            "enum": ["queued", "sent", "delivered", "read", "failed"]
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "nullable": true
          },
          "sent_by_user_id": {
            "type": "string",
            "nullable": true
          },
          "sent_by_ai": {
            "type": "boolean"
          },
          "external_id": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "conversation_id",
          "contact_id",
          "channel",
          "direction",
          "type",
          "text",
          "attachment",
          "template",
          "status",
          "error",
          "sent_by_user_id",
          "sent_by_ai",
          "external_id",
          "created_at"
        ]
      },
      "ChannelRef": {
        "type": "object",
        "description": "A pointer to the channel a conversation runs on.",
        "properties": {
          "id": {
            "type": "string",
            "example": "chn_01K7ZFA5X8Q2M4N6P8R0T2V4W6"
          },
          "type": {
            "type": "string",
            "enum": ["whatsapp", "instagram", "messenger", "email", "webchat"]
          },
          "provider": {
            "type": "string",
            "enum": ["meta", "whatsapp_web", "amivu"]
          }
        },
        "required": ["id", "type", "provider"]
      },
      "Channel": {
        "type": "object",
        "description": "A connected channel and what it can do.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["channel"]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["whatsapp", "instagram", "messenger", "email", "webchat"]
          },
          "provider": {
            "type": "string",
            "enum": ["meta", "whatsapp_web", "amivu"]
          },
          "status": {
            "type": "string",
            "enum": ["pending", "connected", "disconnected", "disabled"]
          },
          "display_number": {
            "type": "string",
            "nullable": true
          },
          "capabilities": {
            "$ref": "#/components/schemas/ChannelCapabilities"
          },
          "connected_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "name",
          "type",
          "provider",
          "status",
          "display_number",
          "capabilities",
          "connected_at",
          "created_at"
        ]
      },
      "ChannelCapabilities": {
        "type": "object",
        "description": "What this connection actually supports. Generated from the implementation.",
        "properties": {
          "text": {
            "type": "boolean"
          },
          "image": {
            "type": "boolean"
          },
          "video": {
            "type": "boolean"
          },
          "audio": {
            "type": "boolean"
          },
          "document": {
            "type": "boolean"
          },
          "template": {
            "type": "boolean"
          },
          "buttons": {
            "type": "boolean"
          },
          "location": {
            "type": "boolean"
          },
          "delivery_receipts": {
            "type": "boolean"
          },
          "read_receipts": {
            "type": "boolean"
          },
          "session_window": {
            "type": "boolean"
          }
        },
        "required": [
          "text",
          "image",
          "video",
          "audio",
          "document",
          "template",
          "buttons",
          "location",
          "delivery_receipts",
          "read_receipts",
          "session_window"
        ]
      },
      "Attachment": {
        "type": "object",
        "description": "A file attached to a message.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["attachment"]
          },
          "id": {
            "type": "string"
          },
          "filename": {
            "type": "string",
            "nullable": true
          },
          "content_type": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "nullable": true
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "filename",
          "content_type",
          "size",
          "url",
          "expires_at",
          "created_at"
        ]
      },
      "Tag": {
        "type": "object",
        "description": "A label that follows a contact everywhere.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["tag"]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "example": "#6b7280"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["object", "id", "name", "color", "created_at"]
      },
      "Note": {
        "type": "object",
        "description": "An internal note. Never delivered to the contact.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["note"]
          },
          "id": {
            "type": "string"
          },
          "conversation_id": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "author_user_id": {
            "type": "string",
            "nullable": true
          },
          "author_name": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "conversation_id",
          "body",
          "author_user_id",
          "author_name",
          "created_at"
        ]
      },
      "User": {
        "type": "object",
        "description": "An agent, as they exist in THIS organization.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["user"]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": ["owner", "admin", "supervisor", "agent", "viewer"]
          },
          "team_id": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["object", "id", "name", "email", "role", "team_id", "created_at"]
      },
      "Team": {
        "type": "object",
        "description": "A group of agents.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["team"]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "member_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["object", "id", "name", "member_count", "created_at"]
      },
      "CustomField": {
        "type": "object",
        "description": "A custom field definition.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["custom_field"]
          },
          "id": {
            "type": "string"
          },
          "key": {
            "type": "string",
            "example": "erp_id"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": ["text"]
          },
          "scope": {
            "type": "string",
            "enum": ["contact", "organization"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["object", "id", "key", "name", "type", "scope", "created_at"]
      },
      "WebhookEndpoint": {
        "type": "object",
        "description": "Where Amivu delivers your events.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["webhook_endpoint"]
          },
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          },
          "environment": {
            "type": "string",
            "enum": ["live", "test"]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "secret": {
            "type": "string",
            "description": "Full only when the endpoint is created or its secret rotated; masked otherwise.",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "object",
          "id",
          "url",
          "description",
          "enabled",
          "environment",
          "events",
          "secret",
          "created_at",
          "updated_at"
        ]
      },
      "WebhookDelivery": {
        "type": "object",
        "description": "One delivery ATTEMPT.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["webhook_delivery"]
          },
          "id": {
            "type": "string"
          },
          "webhook_id": {
            "type": "string"
          },
          "event_id": {
            "type": "string",
            "description": "Stable across attempts. Deduplicate on this."
          },
          "event_type": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "attempt": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": ["pending", "succeeded", "failed"]
          },
          "response_status": {
            "type": "integer",
            "nullable": true
          },
          "duration_ms": {
            "type": "integer",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "delivered_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "next_retry_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "required": [
          "object",
          "id",
          "webhook_id",
          "event_id",
          "event_type",
          "url",
          "attempt",
          "status",
          "response_status",
          "duration_ms",
          "error",
          "created_at",
          "delivered_at",
          "next_retry_at"
        ]
      },
      "Deleted": {
        "type": "object",
        "description": "Confirmation that a resource is gone.",
        "properties": {
          "object": {
            "type": "string",
            "enum": ["deleted"]
          },
          "id": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "enum": [true]
          }
        },
        "required": ["object", "id", "deleted"]
      },
      "Error": {
        "type": "object",
        "description": "Every error has this shape. `request_id` is what support asks for.",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["type", "code", "message", "request_id"],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "invalid_request_error",
                  "validation_error",
                  "authentication_error",
                  "permission_error",
                  "conflict_error",
                  "rate_limit_error",
                  "api_error"
                ]
              },
              "code": {
                "type": "string",
                "example": "conversation_not_found"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": "string"
              },
              "request_id": {
                "type": "string",
                "example": "req_01K7ZFA5X8Q2M4N6P8R0T2V4W6"
              },
              "retry_after": {
                "type": "integer"
              },
              "doc_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  },
  "x-amivu-scopes": [
    {
      "name": "contacts:read",
      "description": "Ler contatos, incluindo etiquetas e campos personalizados."
    },
    {
      "name": "contacts:write",
      "description": "Criar, atualizar e remover contatos."
    },
    {
      "name": "conversations:read",
      "description": "Ler conversas e seus metadados."
    },
    {
      "name": "conversations:write",
      "description": "Abrir conversas, atribuir, encerrar e reabrir."
    },
    {
      "name": "messages:read",
      "description": "Ler mensagens e o estado de entrega delas."
    },
    {
      "name": "messages:write",
      "description": "Enviar mensagens de texto e mídia nas conversas, e subir os anexos delas. Modelo aprovado ainda não sai pela API."
    },
    {
      "name": "channels:read",
      "description": "Listar canais conectados e as capacidades de cada um."
    },
    {
      "name": "users:read",
      "description": "Listar os atendentes da organização."
    },
    {
      "name": "teams:read",
      "description": "Listar times e seus integrantes."
    },
    {
      "name": "teams:write",
      "description": "Criar e atualizar times."
    },
    {
      "name": "tags:read",
      "description": "Listar etiquetas."
    },
    {
      "name": "tags:write",
      "description": "Criar, atualizar e remover etiquetas; aplicá-las a conversas."
    },
    {
      "name": "notes:read",
      "description": "Ler notas internas de uma conversa."
    },
    {
      "name": "notes:write",
      "description": "Escrever notas internas."
    },
    {
      "name": "templates:read",
      "description": "Listar modelos de mensagem aprovados."
    },
    {
      "name": "templates:write",
      "description": "Gerenciar modelos de mensagem."
    },
    {
      "name": "webhooks:read",
      "description": "Listar endpoints de webhook e as entregas deles."
    },
    {
      "name": "webhooks:write",
      "description": "Criar, atualizar e remover endpoints de webhook."
    },
    {
      "name": "custom_fields:read",
      "description": "Ler o catálogo de campos personalizados."
    },
    {
      "name": "custom_fields:write",
      "description": "Criar e atualizar campos personalizados."
    },
    {
      "name": "analytics:read",
      "description": "Ler relatórios agregados de atendimento."
    },
    {
      "name": "audit_logs:read",
      "description": "Ler a trilha de auditoria da organização."
    }
  ],
  "x-amivu-webhook-events": [
    {
      "name": "message.received",
      "description": "Uma mensagem do contato chegou por qualquer canal."
    },
    {
      "name": "message.sent",
      "description": "Uma mensagem sua foi aceita pelo canal."
    },
    {
      "name": "message.delivered",
      "description": "O canal confirmou a entrega no aparelho do contato."
    },
    {
      "name": "message.read",
      "description": "O contato leu a mensagem — só nos canais que reportam leitura."
    },
    {
      "name": "message.failed",
      "description": "O canal recusou a mensagem, com o motivo em `data.message.error`."
    },
    {
      "name": "conversation.created",
      "description": "Uma conversa foi aberta."
    },
    {
      "name": "conversation.updated",
      "description": "Status, canal ou dados da conversa mudaram."
    },
    {
      "name": "conversation.assigned",
      "description": "A conversa passou a ter (ou deixou de ter) responsável."
    },
    {
      "name": "conversation.closed",
      "description": "A conversa foi encerrada."
    },
    {
      "name": "conversation.reopened",
      "description": "Uma conversa encerrada voltou a ficar aberta."
    },
    {
      "name": "contact.created",
      "description": "Um contato foi criado, pela API ou por um canal."
    },
    {
      "name": "contact.updated",
      "description": "Os dados de um contato mudaram."
    },
    {
      "name": "tag.added",
      "description": "Uma etiqueta foi aplicada a um contato ou conversa."
    },
    {
      "name": "tag.removed",
      "description": "Uma etiqueta foi retirada."
    }
  ],
  "x-amivu-error-codes": [
    {
      "code": "missing_api_key",
      "status": 401,
      "description": "O cabeçalho Authorization não veio."
    },
    {
      "code": "invalid_api_key",
      "status": 401,
      "description": "A chave não existe ou foi digitada errada."
    },
    {
      "code": "revoked_api_key",
      "status": 401,
      "description": "A chave foi revogada no painel."
    },
    {
      "code": "expired_api_key",
      "status": 401,
      "description": "A chave passou da data de expiração."
    },
    {
      "code": "insufficient_scope",
      "status": 403,
      "description": "A chave não carrega o escopo exigido."
    },
    {
      "code": "environment_mismatch",
      "status": 403,
      "description": "O recurso pertence ao outro ambiente."
    },
    {
      "code": "subscription_required",
      "status": 403,
      "description": "A organização está sem assinatura ativa."
    },
    {
      "code": "contact_not_found",
      "status": 404,
      "description": "Contato inexistente nesta organização."
    },
    {
      "code": "conversation_not_found",
      "status": 404,
      "description": "Conversa inexistente nesta organização."
    },
    {
      "code": "message_not_found",
      "status": 404,
      "description": "Mensagem inexistente nesta organização."
    },
    {
      "code": "channel_not_found",
      "status": 404,
      "description": "Canal inexistente nesta organização."
    },
    {
      "code": "tag_not_found",
      "status": 404,
      "description": "Etiqueta inexistente nesta organização."
    },
    {
      "code": "team_not_found",
      "status": 404,
      "description": "Time inexistente nesta organização."
    },
    {
      "code": "user_not_found",
      "status": 404,
      "description": "Atendente inexistente nesta organização."
    },
    {
      "code": "webhook_not_found",
      "status": 404,
      "description": "Endpoint de webhook inexistente."
    },
    {
      "code": "delivery_not_found",
      "status": 404,
      "description": "Entrega de webhook inexistente."
    },
    {
      "code": "attachment_not_found",
      "status": 404,
      "description": "Anexo inexistente ou expirado."
    },
    {
      "code": "resource_not_found",
      "status": 404,
      "description": "A rota existe, o recurso não."
    },
    {
      "code": "unknown_endpoint",
      "status": 404,
      "description": "Não existe rota para este método e caminho."
    },
    {
      "code": "invalid_id_format",
      "status": 422,
      "description": "O identificador não tem o prefixo esperado."
    },
    {
      "code": "invalid_cursor",
      "status": 422,
      "description": "O cursor não corresponde a nenhum registro."
    },
    {
      "code": "invalid_body",
      "status": 400,
      "description": "O corpo não é JSON válido."
    },
    {
      "code": "unsupported_message_type",
      "status": 422,
      "description": "O canal desta conversa não suporta este tipo."
    },
    {
      "code": "attachment_type_mismatch",
      "status": 422,
      "description": "O anexo não é do tipo pedido em `type` — um PDF não sai como `image`."
    },
    {
      "code": "channel_not_connected",
      "status": 422,
      "description": "O canal existe mas não está conectado."
    },
    {
      "code": "contact_without_address",
      "status": 422,
      "description": "O contato não tem endereço para este canal."
    },
    {
      "code": "duplicate_contact",
      "status": 409,
      "description": "Já existe contato com este telefone, e-mail ou external_id."
    },
    {
      "code": "idempotency_key_reuse",
      "status": 409,
      "description": "A mesma chave de idempotência com corpo diferente."
    },
    {
      "code": "idempotency_in_progress",
      "status": 409,
      "description": "A requisição anterior com esta chave ainda está em curso."
    },
    {
      "code": "rate_limit_exceeded",
      "status": 429,
      "description": "Excedeu o limite de requisições da organização."
    },
    {
      "code": "payload_too_large",
      "status": 413,
      "description": "O corpo ou o arquivo passou do limite."
    },
    {
      "code": "unsupported_media_type",
      "status": 415,
      "description": "O tipo MIME não é aceito — no upload, fora da lista de mídia que o envio aceita."
    },
    {
      "code": "internal_error",
      "status": 500,
      "description": "Falha inesperada. O request_id identifica a ocorrência."
    }
  ],
  "x-amivu-pagination": {
    "default_limit": 25,
    "max_limit": 100
  }
}
