openapi: 3.0.3
info:
  title: TimelinesAI Public API
  description: |
    The TimelinesAI Public API enables programmatic access to your WhatsApp communications. Send messages, manage chats, handle labels, upload files, and configure webhooks—all through a simple REST interface.

    ## Getting Started

    1. **Get your API token** from the [Public API page](https://app.timelines.ai/integrations/api/) in your TimelinesAI workspace
    2. **Add the token** to your request headers as `Authorization: Bearer YOUR_TOKEN`
    3. **Start making requests** to the endpoints below

    ## Rate Limits & Credits

    | Action | Credit Cost |
    |--------|-------------|
    | Send text message | 1 credit |
    | Send message with attachment | 2 credits |
    | Failed message (refunded) | 0 credits |

    Messages are sent with a ~2 second delay between each to avoid WhatsApp spam detection. Contact support@timelines.ai to customize this on Business plans.

    ## Message Formatting

    Use `\n` for line breaks in message text.
  version: 1.2.0
  contact:
    name: TimelinesAI Support
    email: support@timelines.ai
    url: https://timelines.ai
  x-logo:
    url: https://app.timelines.ai/static/logo.svg
    altText: TimelinesAI Logo
servers:
  - url: https://app.timelines.ai/integrations/api
    description: Production
  - url: https://staging.app.timelines.ai/integrations/api
    description: Staging
tags:
  - name: Chats
    description: Manage WhatsApp chats and conversations
  - name: Messages
    description: Send and retrieve messages
  - name: Labels
    description: Organize chats with labels
  - name: Notes
    description: Add internal notes to chats
  - name: Files
    description: Upload and manage file attachments
  - name: WhatsApp Accounts
    description: View connected WhatsApp accounts
  - name: Webhooks
    description: Configure real-time event notifications
paths:
  /chats:
    get:
      tags:
        - Chats
      summary: List chats
      description: |
        Retrieve all chats in your workspace with optional filtering. Results are paginated (50 per page) and ordered by most recent message, then alphabetically by name.
      x-mint:
        metadata:
          title: List all chats
          description: Get a filtered list of WhatsApp chats from your workspace
      parameters:
        - in: query
          name: label
          schema:
            type: string
          description: Filter by labels (comma-separated). Returns chats with ANY of the specified labels.
          example: customer,lead,vip
        - in: query
          name: whatsapp_account_id
          schema:
            type: string
          description: Filter by WhatsApp account IDs in WID format (comma-separated)
          example: 972501111111@s.whatsapp.net
        - in: query
          name: group
          schema:
            type: boolean
          description: Filter by chat type. `true` for groups, `false` for direct chats.
        - in: query
          name: responsible
          schema:
            type: string
          description: Filter by assigned team members (email addresses, comma-separated)
          example: john@company.com,jane@company.com
        - in: query
          name: name
          schema:
            type: string
          description: Filter by chat name (case-insensitive substring match, comma-separated)
          example: acme,sales
        - in: query
          name: read
          schema:
            type: boolean
          description: Filter by read status. `true` for read, `false` for unread.
        - in: query
          name: closed
          schema:
            type: boolean
          description: Filter by closed status. `true` for closed, `false` for open.
        - in: query
          name: chatgpt_autoresponse_enabled
          schema:
            type: boolean
          description: Filter by AI auto-response status
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          description: Page number (50 items per page)
          example: 1
        - in: query
          name: created_after
          schema:
            type: string
            format: date-time
          description: Filter chats created after this timestamp (ISO 8601)
          example: "2024-01-01T00:00:00Z"
        - in: query
          name: created_before
          schema:
            type: string
            format: date-time
          description: Filter chats created before this timestamp (ISO 8601)
          example: "2024-12-31T23:59:59Z"
      responses:
        "200":
          description: List of chats matching the filter criteria
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatListResponse"
              example:
                status: ok
                data:
                  has_more_pages: true
                  chats:
                    - id: 123456
                      name: John Doe
                      phone: "+14155551234"
                      is_group: false
                      whatsapp_account_id: "972501111111@s.whatsapp.net"
                      responsible: "agent@company.com"
                      closed: false
                      read: true
        "404":
          $ref: "#/components/responses/NotFound"

  /chats/{chat_id}:
    get:
      tags:
        - Chats
      summary: Get chat details
      description: Retrieve detailed information about a specific chat
      parameters:
        - $ref: "#/components/parameters/chat_id"
      responses:
        "200":
          description: Chat details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatInfoResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    patch:
      tags:
        - Chats
      summary: Update chat
      description: Update chat properties like name, assignment, or status
      parameters:
        - $ref: "#/components/parameters/chat_id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ChatDetails"
            example:
              name: "John Doe - VIP"
              responsible: "senior.agent@company.com"
              closed: false
      responses:
        "200":
          description: Updated chat details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChatInfoResponse"
        "404":
          $ref: "#/components/responses/NotFound"

  /chats/{chat_id}/messages:
    get:
      tags:
        - Messages
      summary: Get chat messages
      description: |
        Retrieve message history for a specific chat. Results are paginated (50 per page) and ordered by timestamp (newest first).
      parameters:
        - $ref: "#/components/parameters/chat_id"
        - in: query
          name: from_me
          schema:
            type: boolean
          description: Filter by message direction. `true` for sent, `false` for received.
        - in: query
          name: after
          schema:
            type: string
          description: Filter messages after this date/time (ISO format)
          example: "2024-01-17 10:35"
        - in: query
          name: before
          schema:
            type: string
          description: Filter messages before this date/time (ISO format)
          example: "2024-01-19 15:30"
        - in: query
          name: after_message
          schema:
            type: string
          description: Get messages after this message UID (for pagination)
          example: d8cc5a02-b676-4956-8710-3ee56330f356
      responses:
        "200":
          description: List of messages
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageListResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    post:
      tags:
        - Messages
      summary: Send message to chat
      description: |
        Send a message to an existing chat. The chat's WhatsApp account is used automatically.
        
        **Credit usage:** 1 credit for text, 2 credits for text + attachment.
      parameters:
        - $ref: "#/components/parameters/chat_id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Message"
            examples:
              text_only:
                summary: Text message
                value:
                  text: "Hello! How can I help you today?"
              with_attachment:
                summary: Message with file
                value:
                  text: "Here's the document you requested"
                  file_uid: "afa9d4dd-978d-4a14-aa1b-bd65c272e645"
              with_label:
                summary: Message with auto-label
                value:
                  text: "Thank you for your interest!"
                  label: "contacted"
      responses:
        "200":
          description: Message queued for sending
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageSendResponse"
              example:
                status: ok
                data:
                  message_uid: "a5bbb005-37f2-402c-96fa-e479a2e09b02"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "403":
          $ref: "#/components/responses/AccessDenied"
        "404":
          $ref: "#/components/responses/NotFound"

  /chats/{chat_id}/voice_message:
    post:
      tags:
        - Messages
      summary: Send voice message
      description: Send an audio file as a WhatsApp voice note. Supports OGG, OGA, and MP3 formats.
      parameters:
        - $ref: "#/components/parameters/chat_id"
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: Audio file (ogg, oga, or mp3)
      responses:
        "200":
          description: Voice message queued
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageSendResponse"

  /chats/{chat_id}/labels:
    get:
      tags:
        - Labels
      summary: Get chat labels
      description: List all labels assigned to a chat
      parameters:
        - $ref: "#/components/parameters/chat_id"
      responses:
        "200":
          description: List of labels
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LabelsModifyResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    post:
      tags:
        - Labels
      summary: Replace chat labels
      description: Replace all labels on a chat with a new set
      parameters:
        - $ref: "#/components/parameters/chat_id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LabelsList"
            example:
              labels:
                - vip
                - enterprise
      responses:
        "200":
          description: Updated labels
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LabelsModifyResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      tags:
        - Labels
      summary: Add chat labels
      description: Add labels to a chat without removing existing ones
      parameters:
        - $ref: "#/components/parameters/chat_id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LabelsList"
            example:
              labels:
                - follow-up
      responses:
        "200":
          description: Updated labels
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LabelsModifyResponse"
        "404":
          $ref: "#/components/responses/NotFound"

  /chats/{chat_id}/notes:
    post:
      tags:
        - Notes
      summary: Add note to chat
      description: Add an internal note to a chat (visible only to your team, not sent to WhatsApp)
      parameters:
        - $ref: "#/components/parameters/chat_id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/NoteInfo"
            example:
              text: "Customer prefers morning calls. Follow up next week."
      responses:
        "200":
          description: Note created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NoteModifyResponse"
        "404":
          $ref: "#/components/responses/NotFound"

  /messages/{message_uid}:
    get:
      tags:
        - Messages
      summary: Get message details
      description: Retrieve detailed information about a specific message including delivery status
      parameters:
        - $ref: "#/components/parameters/message_uid"
      responses:
        "200":
          description: Message details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageInfoResponse"
        "404":
          $ref: "#/components/responses/NotFound"

  /messages/{message_uid}/status_history:
    get:
      tags:
        - Messages
      summary: Get message status history
      description: Track the delivery lifecycle of a message (queued → sent → delivered → read)
      parameters:
        - $ref: "#/components/parameters/message_uid"
      responses:
        "200":
          description: Status history
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageStatusHistoryResponse"
        "404":
          $ref: "#/components/responses/NotFound"

  /messages:
    post:
      tags:
        - Messages
      summary: Send message to phone number
      description: |
        Send a message to any WhatsApp phone number. A chat will be created automatically if one doesn't exist.
        
        If no WhatsApp account is specified, the most recently connected account is used.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MessageToPhone"
            example:
              phone: "+14155551234"
              text: "Hi! This is a message from our team."
              whatsapp_account_id: "972501111111@s.whatsapp.net"
      responses:
        "200":
          description: Message queued
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageSendResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "403":
          $ref: "#/components/responses/AccessDenied"

  /messages/to_jid:
    post:
      tags:
        - Messages
      summary: Send message to JID
      description: |
        Send a message using the WhatsApp JID (Jabber ID). Useful for groups or when you have the JID from webhooks.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MessageToJID"
            example:
              jid: "120363123456789012@g.us"
              text: "Hello group!"
      responses:
        "200":
          description: Message queued
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageSendResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "403":
          $ref: "#/components/responses/AccessDenied"

  /messages/to_chat_name:
    post:
      tags:
        - Messages
      summary: Send message by chat name
      description: |
        Send a message to a chat identified by its name in TimelinesAI. Chat names are unique within a workspace.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MessageToChatName"
            example:
              chat_name: "John Doe"
              text: "Following up on our conversation..."
      responses:
        "200":
          description: Message queued
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MessageSendResponse"
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "403":
          $ref: "#/components/responses/AccessDenied"
        "404":
          $ref: "#/components/responses/NotFound"

  /whatsapp_accounts:
    get:
      tags:
        - WhatsApp Accounts
      summary: List WhatsApp accounts
      description: Get all WhatsApp accounts connected to your workspace
      responses:
        "200":
          description: List of connected accounts
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WhatsappAccountsResponse"

  /files:
    get:
      tags:
        - Files
      summary: List uploaded files
      description: Get all files uploaded to your workspace, optionally filtered by filename
      parameters:
        - $ref: "#/components/parameters/filename"
      responses:
        "200":
          description: List of files
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileListResponse"
    post:
      tags:
        - Files
      summary: Upload file from URL
      description: Upload a file by providing a publicly accessible URL. TimelinesAI will download and store it.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FileUploadJson"
            example:
              url: "https://example.com/document.pdf"
              filename: "proposal.pdf"
      responses:
        "200":
          description: File uploaded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileInfoResponse"

  /files/{file_uid}:
    get:
      tags:
        - Files
      summary: Get file details
      description: Get file information including a temporary download URL
      parameters:
        - $ref: "#/components/parameters/file_uid"
      responses:
        "200":
          description: File details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileInfoResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    delete:
      tags:
        - Files
      summary: Delete file
      description: Permanently delete an uploaded file
      parameters:
        - $ref: "#/components/parameters/file_uid"
      responses:
        "200":
          description: File deleted
        "404":
          $ref: "#/components/responses/NotFound"

  /files_upload:
    post:
      tags:
        - Files
      summary: Upload file (multipart)
      description: Upload a file directly using multipart form data
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/FileUploadForm"
      responses:
        "200":
          description: File uploaded
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FileInfoResponse"

  /webhooks:
    get:
      tags:
        - Webhooks
      summary: List webhooks
      description: Get all webhook subscriptions configured for your workspace
      responses:
        "200":
          description: List of webhooks
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookListResponse"
    post:
      tags:
        - Webhooks
      summary: Create webhook
      description: |
        Subscribe to real-time events. Supported events include:
        - `message:received:new` - New incoming message
        - `message:sent:new` - Message sent successfully
        - `chat:created` - New chat created
        
        See the [full event list](https://app.timelines.ai/integrations/webhooks_v2/swagger) for all options.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Webhook"
            example:
              event_type: "message:received:new"
              url: "https://your-app.com/webhooks/timelines"
              enabled: true
      responses:
        "200":
          description: Webhook created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookInfoResponse"

  /webhooks/{webhook_id}:
    get:
      tags:
        - Webhooks
      summary: Get webhook
      description: Get details of a specific webhook subscription
      parameters:
        - $ref: "#/components/parameters/webhook_id"
      responses:
        "200":
          description: Webhook details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookInfoResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    put:
      tags:
        - Webhooks
      summary: Update webhook
      description: Update webhook URL, event type, or enabled status
      parameters:
        - $ref: "#/components/parameters/webhook_id"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/WebhookUpdate"
            example:
              enabled: false
      responses:
        "200":
          description: Webhook updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WebhookInfoResponse"
        "404":
          $ref: "#/components/responses/NotFound"
    delete:
      tags:
        - Webhooks
      summary: Delete webhook
      description: Permanently delete a webhook subscription
      parameters:
        - $ref: "#/components/parameters/webhook_id"
      responses:
        "200":
          description: Webhook deleted
        "404":
          $ref: "#/components/responses/NotFound"

components:
  parameters:
    chat_id:
      in: path
      name: chat_id
      schema:
        type: integer
      required: true
      description: Unique chat ID (found in chat URL or webhook payloads)
      example: 123456
    message_uid:
      in: path
      name: message_uid
      schema:
        type: string
        format: uuid
      required: true
      description: Unique message identifier
      example: a5bbb005-37f2-402c-96fa-e479a2e09b02
    filename:
      in: query
      name: filename
      schema:
        type: string
      required: false
      description: Filter by filename (partial match, case-insensitive)
      example: pdf
    file_uid:
      in: path
      name: file_uid
      schema:
        type: string
        format: uuid
      required: true
      description: Unique file identifier
      example: 90d353e6-44c1-48ff-b15b-69b7721e5450
    webhook_id:
      in: path
      name: webhook_id
      schema:
        type: string
      required: true
      description: Webhook subscription ID
      example: "7654321"

  responses:
    BadRequestError:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            status: error
            message: "Invalid phone number format"
    UnauthorizedError:
      description: Missing or invalid API token
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            status: error
            message: "Invalid or expired token"
    AccessDenied:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            status: error
            message: "Access denied"
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ErrorResponse"
          example:
            status: error
            message: "Chat not found"

  schemas:
    ChatDetails:
      type: object
      properties:
        name:
          type: string
          description: Chat display name (must be unique in workspace)
          example: John Doe
        responsible:
          type: string
          description: Team member email to assign, or empty string to unassign
          example: agent@company.com
        closed:
          type: boolean
          description: Close or reopen the chat
          example: false
        read:
          type: boolean
          description: Mark as read or unread
          example: true
        chatgpt_autoresponse_enabled:
          type: boolean
          description: Enable/disable AI auto-response
          example: false

    Message:
      type: object
      properties:
        text:
          type: string
          description: Message text (use \n for line breaks)
          example: "Hello! How can I help?"
        file_uid:
          type: string
          description: Attachment file UID (upload first via /files)
          example: afa9d4dd-978d-4a14-aa1b-bd65c272e645
        label:
          type: string
          description: Auto-apply this label to the chat
          example: contacted
        attachment_template_id:
          type: integer
          description: Template ID for attachment
          example: 123456

    MessageToPhone:
      type: object
      required:
        - phone
      properties:
        phone:
          type: string
          description: Recipient phone in international format
          example: "+14155551234"
        text:
          type: string
          description: Message text
          example: "Hello from TimelinesAI!"
        file_uid:
          type: string
          description: Attachment file UID
        whatsapp_account_id:
          type: string
          description: Sending account (WID format). Uses default if omitted.
          example: "972501111111@s.whatsapp.net"
        label:
          type: string
          description: Auto-apply label to chat

    MessageToJID:
      type: object
      required:
        - jid
      properties:
        jid:
          type: string
          description: WhatsApp JID (e.g., phone@s.whatsapp.net or group@g.us)
          example: "120363123456789012@g.us"
        text:
          type: string
          description: Message text
        file_uid:
          type: string
          description: Attachment file UID
        whatsapp_account_id:
          type: string
          description: Sending account (WID format)

    MessageToChatName:
      type: object
      required:
        - chat_name
      properties:
        chat_name:
          type: string
          description: Exact chat name as shown in TimelinesAI
          example: "John Doe"
        text:
          type: string
          description: Message text
        file_uid:
          type: string
          description: Attachment file UID
        whatsapp_account_id:
          type: string
          description: Sending account (WID format)

    LabelsList:
      type: object
      properties:
        labels:
          type: array
          items:
            type: string
          description: List of label names
          example: ["vip", "enterprise"]

    NoteInfo:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Note content (internal only, not sent to WhatsApp)
          example: "Customer prefers email communication"

    FileUploadJson:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          description: Publicly accessible file URL
          example: "https://example.com/document.pdf"
        filename:
          type: string
          description: Override detected filename
          example: "proposal.pdf"
        mime_type:
          type: string
          description: Override detected MIME type
          example: "application/pdf"

    FileUploadForm:
      type: object
      required:
        - file
      properties:
        file:
          type: string
          format: binary
          description: File content
        filename:
          type: string
          description: Filename
        mime_type:
          type: string
          description: MIME type

    Webhook:
      type: object
      required:
        - event_type
        - url
      properties:
        event_type:
          type: string
          description: Event to subscribe to
          example: "message:received:new"
        url:
          type: string
          description: HTTPS endpoint to receive webhooks
          example: "https://your-app.com/webhooks/timelines"
        enabled:
          type: boolean
          description: Whether webhook is active
          default: true

    WebhookUpdate:
      type: object
      properties:
        event_type:
          type: string
          description: Event type
        url:
          type: string
          description: Webhook URL
        enabled:
          type: boolean
          description: Enable/disable webhook

    # Response schemas
    ChatListResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: object
          properties:
            has_more_pages:
              type: boolean
            chats:
              type: array
              items:
                $ref: "#/components/schemas/ChatInfo"

    ChatInfoResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          $ref: "#/components/schemas/ChatInfo"

    ChatInfo:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        phone:
          type: string
        is_group:
          type: boolean
        whatsapp_account_id:
          type: string
        responsible:
          type: string
        closed:
          type: boolean
        read:
          type: boolean

    MessageListResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: object
          properties:
            has_more_pages:
              type: boolean
            messages:
              type: array
              items:
                $ref: "#/components/schemas/MessageInfo"

    MessageInfoResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          $ref: "#/components/schemas/MessageInfo"

    MessageInfo:
      type: object
      properties:
        uid:
          type: string
        text:
          type: string
        from_me:
          type: boolean
        timestamp:
          type: string
          format: date-time
        status:
          type: string

    MessageStatusHistoryResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: array
          items:
            type: object
            properties:
              status:
                type: string
              timestamp:
                type: string
                format: date-time

    MessageSendResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: object
          properties:
            message_uid:
              type: string
              format: uuid

    LabelsModifyResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          $ref: "#/components/schemas/LabelsList"

    NoteModifyResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: object
          properties:
            message_uid:
              type: string

    WhatsappAccountsResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              phone:
                type: string
              name:
                type: string
              connected:
                type: boolean

    FileListResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: array
          items:
            $ref: "#/components/schemas/FileInfo"

    FileInfoResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          $ref: "#/components/schemas/FileInfo"

    FileInfo:
      type: object
      properties:
        uid:
          type: string
        filename:
          type: string
        mime_type:
          type: string
        size:
          type: integer
        download_url:
          type: string

    WebhookListResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          type: array
          items:
            $ref: "#/components/schemas/WebhookInfo"

    WebhookInfoResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        data:
          $ref: "#/components/schemas/WebhookInfo"

    WebhookInfo:
      type: object
      properties:
        id:
          type: integer
        event_type:
          type: string
        url:
          type: string
        enabled:
          type: boolean
        errors_counter:
          type: integer

    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          enum: [ok, error]
        message:
          type: string

  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        Get your API token from [TimelinesAI Settings](https://app.timelines.ai/integrations/api/)

security:
  - bearerAuth: []