> ## Documentation Index
> Fetch the complete documentation index at: https://timelines.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Messages

> Search messages by text across the chats this token can see.



## OpenAPI

````yaml get /search
openapi: 3.0.3
info:
  title: Timelines Public API
  description: >
    # Timelines Public API


    _Some API calls may utilize message sending quota or be subject to message
    sending rate limits as described below._


    ### Credit Utilization 
      - Sending a message via API consumes 1 credit from message sending quota.
      - Sending a message with non-empty text and attachment consumes 2 credits from message sending quota.
      - If a message cannot be sent (invalid or not connected to WhatsApp number, WhatsApp server error), message sending quota will be restored (usually within a couple of hours).
    ### Message sending rate
      - Messages will be sent with random delay of about 2 seconds between each two messages (to avoid WhatsApp spam detection mechanisms). Contact support@timelines.ai if you want to modify delay for your workspace (available on Business plan only).
      - If you exceed message sending frequency, messages be queued and sent out with delay. Each queued message will consume a message sending credit, so the number of queued messages cannot exceed the available quota.
      
    ### Authorization:
      - Copy API token from [Public API page](https://app.timelines.ai/integrations/api/) in your TimelinesAI account.
      - Put the token in *Authorization* header of request as follows:
      ```
      Authorization: Bearer 4d2d0239-e28c-4f4a-8a4d-3a3ca40056b8
      ```
            
    ### Message formatting:
      - use "\n" for line breaks

    ### Input strings:
      - String fields must not contain the NUL character (U+0000).
  version: 1.3.0
servers:
  - url: https://app.timelines.ai/integrations/api
    description: Public API root URL
security:
  - bearerAuth: []
paths:
  /search:
    get:
      summary: Search messages by text across the workspace.
      description: >-
        Finds messages whose text or comment contains every word of `text`, the
        same match as the Messages search in the app. Words match whole; the
        last word also matches as a prefix, so "dalto ne" finds "Dalto Neto".
        The sender, the recipient and the chat name are not searched. Only chats
        available to the token are searched. The result is paginated, page size
        is 20 messages, ordered from the newest. To get the next page, pass the
        `uid` of the last message of the previous page as `before_message`.
      parameters:
        - in: query
          name: text
          required: true
          schema:
            type: string
          description: >-
            words to search for. Any characters are accepted; punctuation such
            as `&`, `|`, `!`, quotes, `:` and `+` is not an error
          example: dalto ne
        - in: query
          name: before_message
          schema:
            type: string
          description: >-
            uid of the last message of the previous page, to get the next page
            (excluding the specified message itself). Omit it or leave it blank
            for the first page
          example: d8cc5a02-b676-4956-8710-3ee56330f356
      responses:
        '200':
          description: Success. No match is an empty `messages` list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageSearchResponse'
        '400':
          description: '`text` is missing or blank, or `before_message` is not a message uid'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                text_required:
                  summary: text is missing or blank
                  value:
                    status: error
                    message: text is required
                    error_code: validation_error
                    errors:
                      - fields:
                          - text
                        msg: text is required
                before_message_invalid:
                  summary: before_message is not a message uid
                  value:
                    status: error
                    message: before_message is not a message uid
                    error_code: validation_error
                    errors:
                      - fields:
                          - before_message
                        msg: before_message is not a message uid
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/AccessDenied'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    MessageSearchResponse:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          example: ok
          enum:
            - ok
            - error
        data:
          $ref: '#/components/schemas/MessageSearchData'
    ErrorResponse:
      required:
        - message
        - status
      type: object
      properties:
        message:
          type: string
        status:
          type: string
          example: error
          enum:
            - ok
            - error
        error_code:
          type: string
          description: >-
            Stable, machine-readable error code. Use this for branching in
            client integrations.
          example: validation_error
          enum:
            - missing_credentials
            - invalid_token
            - member_not_found
            - permission_denied
            - insufficient_scope
            - plan_feature_unavailable
            - quota_exceeded
            - rate_limit_exceeded
            - validation_error
            - not_found
            - account_inactive
            - template_not_approved
            - template_wrong_waba
            - template_variables_mismatch
            - service_window_closed
            - not_supported
            - internal_error
            - account_already_connected
            - member_has_connected_account
            - member_has_phone_link_in_progress
            - number_pairing_in_progress
            - member_has_qr_connection_in_progress
            - connected_accounts_limit_reached
            - user_id_required
            - number_not_allowed
        errors:
          type: array
          description: >-
            Per-field validation diagnostics for request-schema (body/params)
            validation failures. Present only when the request failed schema
            validation; absent on business-rule `validation_error` rejections
            (which carry `message` and `error_code` only) and on
            auth/authorization/quota errors.
          items:
            $ref: '#/components/schemas/ValidationError'
    MessageSearchData:
      type: object
      description: one page of the search result
      required:
        - has_more_pages
        - messages
      properties:
        has_more_pages:
          type: boolean
          description: >-
            true if more matches exist; pass the uid of the last message as
            `before_message` to get them
          example: false
        messages:
          type: array
          description: matching messages, newest first, at most 20
          items:
            $ref: '#/components/schemas/MessageInfo'
          example:
            - uid: d8cc5a02-b676-4956-8710-3ee56330f356
              chat_id: 12345
              timestamp: 2024-01-17 10:35:12 +0000
              received_timestamp: 2024-01-17 10:35:12 +0000
              sender_phone: '+14155552671'
              sender_name: Paulo Dalto Neto
              recipient_phone: '+14155550123'
              recipient_name: John Doe
              from_me: false
              text: Contract for Paulo Dalto Neto is ready
              status: Read
              origin: WhatsApp
              has_attachment: false
              message_type: whatsapp
              data: {}
              created_by: ''
              reactions: {}
    ValidationError:
      type: object
      required:
        - fields
        - msg
      properties:
        fields:
          type: array
          items:
            type: string
          description: >-
            Path of the offending field, as a list of keys/indexes from the
            request root.
          example:
            - url
        msg:
          type: string
          description: Validator message for that field.
          example: must be a valid http(s) URL
    MessageInfo:
      type: object
      required:
        - uid
        - chat_id
        - timestamp
        - received_timestamp
        - sender_phone
        - sender_name
        - recipient_phone
        - recipient_name
        - from_me
        - status
        - origin
        - has_attachment
        - message_type
        - data
        - created_by
      properties:
        uid:
          type: string
          example: de919486-0c93-409d-ae66-c2bbb544faca
        chat_id:
          example: '1000001'
          type: integer
        timestamp:
          description: message creation timestamp, WhatsApp message time
          example: 2023-06-18 15:19:23 +0300
          type: string
        received_timestamp:
          description: >-
            message creation timestamp in TimelinesAI, in ISO format with
            timezone
          example: 2023-06-18 14:39:25 +0300
          type: string
        sender_phone:
          example: '+972540000001'
          type: string
        sender_name:
          example: John Doe
          type: string
        recipient_phone:
          example: '+972540000002'
          type: string
        recipient_name:
          example: Kate Smith
          type: string
        from_me:
          example: true
          type: boolean
        text:
          example: Hello, Kate👍
          type: string
          description: >
            Message body text. `null` for attachment-only messages and for call
            / event messages. For a transcribed voice note, `text` carries the
            transcript and `text_is_transcript` is true — a non-null `text` no
            longer means the message has no audio.
        text_is_transcript:
          type: boolean
          description: >
            True when `text` is a voice-note transcript. False for every other
            message. Omitted while WhatsApp calling is off for the workspace.
          example: false
        attachment_url:
          example: https://acme.com/logo.png
          type: string
        attachment_filename:
          example: logo.png
          type: string
        status:
          example: Read
          type: string
          description: >
            Delivery status, one of: `Sending`, `Sent`, `Delivered`, `Read`,
            `Failed`, `Pending`. For call messages, a call status (e.g.
            `answered`, `missed`) is returned instead.
        origin:
          example: Public API
          type: string
          description: >
            Human-readable origin of the message, e.g. `Public API`, `Shared
            Inbox`, `Mass Messaging`, `Chrome Extension`, `synced from
            WhatsApp`, `Webhook`. Additional values are possible (e.g. from OIDC
            / connected third-party apps), so treat this as an open-ended,
            display-only string rather than an exhaustive enum.
        has_attachment:
          example: true
          type: boolean
        message_type:
          example: Note
          type: string
          description: >
            Type of message: one of `whatsapp`, `whatsapp_call`, `note`,
            `email`, `summary`.
        reactions:
          $ref: '#/components/schemas/MessageReactionsObject'
        data:
          example:
            key1: value1
            key2: value2
          type: object
          description: >
            Free-form metadata object whose contents vary by `message_type` (for
            example, call status, or scheduled-event start/end times). Shape is
            not stable across message types.
        created_by:
          example: Kate Smith
          type: string
          description: >
            Display name of the team member who created the message; empty
            string for messages not created by a member (e.g. synced or inbound
            messages).
        failure_reason:
          description: >
            Present when `status` is `Failed`. Currently populated only for WABA
            messages (`GET /waba/messages/{message_uid}`); `null`/absent
            otherwise.
          allOf:
            - $ref: '#/components/schemas/MessageFailureReason'
        referral:
          description: >
            The Meta click-to-WhatsApp ad or organic post the message came from.
            Returned only by the WABA message calls (`GET
            /waba/chats/{chat_id}/messages`, `GET /waba/messages/{message_uid}`,
            `POST /waba/messages`, `POST /waba/chats/{chat_id}/messages`);
            absent elsewhere. `null` when the message carried no referral, for
            messages we sent, and when the workspace plan does not include ad
            attribution.
          nullable: true
          allOf:
            - $ref: '#/components/schemas/WabaMessageReferral'
    MessageReactionsObject:
      type: object
      required:
        - users
        - reactions
        - total
      properties:
        users:
          type: array
          items:
            $ref: '#/components/schemas/MessageReactionUser'
        reactions:
          type: object
          additionalProperties:
            type: integer
          example:
            👍: 2
            ❤️: 5
        total:
          type: integer
          example: 7
      example:
        users:
          - name: John Doe
            phone: '+972540000001'
            reaction: 👍
            current: true
          - name: Kate Smith
            phone: '+972540000002'
            reaction: 👍
            current: false
        reactions:
          👍: 2
        total: 2
    MessageFailureReason:
      type: object
      nullable: true
      required:
        - code
        - title
        - details
      properties:
        code:
          oneOf:
            - type: integer
            - type: string
        title:
          type: string
        details:
          type: string
    WabaMessageReferral:
      type: object
      required:
        - message_uid
        - source_id
        - headline
        - source_url
        - source_type
        - timestamp
      properties:
        message_uid:
          type: string
          description: The `uid` of the message that carried the referral.
          example: de919486-0c93-409d-ae66-c2bbb544faca
        source_id:
          type: string
          description: Meta ad id (or post id); empty string when Meta does not send one.
          example: '120208471234567890'
        headline:
          type: string
          nullable: true
          description: Ad headline; `null` when Meta does not send one.
          example: Summer sale
        source_url:
          type: string
          nullable: true
          description: Link to the ad or post; `null` when Meta does not send one.
          example: https://fb.me/summer-sale
        source_type:
          type: string
          description: '`ad` or `post`, as Meta sends it.'
          example: ad
        timestamp:
          type: string
          description: Same value and format as the message `timestamp`.
          example: 2023-06-18 15:19:23 +0300
    MessageReactionUser:
      type: object
      required:
        - name
        - phone
        - reaction
        - current
      properties:
        name:
          example: John Doe
          type: string
        phone:
          example: '+972540000001'
          type: string
        reaction:
          type: string
          example: 👍
        current:
          type: boolean
          description: >-
            True if the reaction was placed by the workspace's own WhatsApp
            account (the "current" side of the conversation). False if placed by
            anyone else - the remote contact in a 1:1 conversation, or another
            participant in a group chat.
          example: true
  responses:
    UnauthorizedError:
      description: Access token is missing or invalid
    AccessDenied:
      description: Access denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Specified entities not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.