# Search tickets

`POST /tickets/search`

> This is a subset of the full specification, limited to the `POST /tickets/search` operation.
>
> You can find the full specification here: /_bundle/docs/references/@2.12/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.12'
  description: This is a subset of the full specification, limited to the `POST /tickets/search` operation. Components more than 3 `$ref` hops away are not included.
  contact:
    name: Intercom Developer Hub
    url: https://developers.intercom.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
servers:
  - url: https://api.intercom.io
    description: The production API server
  - url: https://api.eu.intercom.io
    description: The european API server
  - url: https://api.au.intercom.io
    description: The australian API server
security:
  - bearerAuth: []
tags:
  - name: Tickets
    description: Everything about your tickets
paths:
  /tickets/search:
    post:
      summary: Search tickets
      operationId: searchTickets
      parameters:
        - name: Intercom-Version
          in: header
          schema:
            $ref: '#/components/schemas/intercom_version'
      tags:
        - Tickets
      description: |-
        You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want.

        To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`.

        This will accept a query object in the body which will define your filters.

        **Optimizing search queries**

        Search queries can be complex, so optimizing them can help the performance of your search.
        Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize
        pagination to limit the number of results returned. The default is `20` results per page.
        See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param.

        ### Nesting & Limitations

        You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
        There are some limitations to the amount of multiples there can be:

        - There's a limit of max 2 nested filters
        - There's a limit of max 15 filters for each AND or OR group

        ### Accepted Fields

        Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`).
        The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result.

        | Field | Type |
        | --- | --- |
        | id | String |
        | created_at | Date (Unix timestamp in seconds) |
        | updated_at | Date (Unix timestamp in seconds) |
        | title | String |
        | description | String |
        | category | String |
        | ticket_type_id | String |
        | contact_ids | String |
        | teammate_ids | String |
        | admin_assignee_id | String |
        | team_assignee_id | String |
        | open | Boolean |
        | state | String |
        | snoozed_until | Date (Unix timestamp in seconds) |
        | ticket_attribute.{id} | String or Boolean or Date (Unix timestamp in seconds) or Float or Integer |

        ### Accepted Operators

        **Searching based on `created_at`**

        You may use the `<=` or `>=` operators to search by `created_at`.

        The table below shows the operators you can use to define how you want to search for the value.  The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type  (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates).

        | Operator | Valid Types | Description |
        | --- | --- | --- |
        | = | All | Equals |
        | != | All | Doesn't Equal |
        | IN | All | In  Shortcut for `OR` queries  Values most be in Array |
        | NIN | All | Not In  Shortcut for `OR !` queries  Values must be in Array |
        | > | Integer  Date (Unix timestamp in seconds) | Greater (or equal) than |
        | < | Integer  Date (Unix timestamp in seconds) | Lower (or equal) than |
        | ~ | String | Contains |
        | !~ | String | Doesn't Contain |
        | ^ | String | Starts With |
        | $ | String | Ends With |
      responses:
        '200':
          description: successful
          content:
            application/json:
              examples:
                successful:
                  value:
                    type: ticket.list
                    pages:
                      type: pages
                      page: 1
                      per_page: 5
                      total_pages: 1
                    total_count: 1
                    tickets:
                      - type: ticket
                        id: '166'
                        ticket_id: '18'
                        ticket_attributes:
                          _default_title_: attribute_value
                          _default_description_: null
                        ticket_state:
                          type: ticket_state
                          id: '2817'
                          category: submitted
                          internal_label: Submitted
                          external_label: Submitted
                        ticket_type:
                          type: ticket_type
                          id: '48'
                          name: my-ticket-type-35
                          description: my ticket type description is awesome.
                          icon: 🦁
                          workspace_id: this_is_an_id704_that_should_be_at_least_
                          archived: false
                          created_at: 1736201985
                          updated_at: 1736201985
                          is_internal: false
                          ticket_type_attributes:
                            type: list
                            data:
                              - type: ticket_type_attribute
                                id: '87'
                                workspace_id: this_is_an_id704_that_should_be_at_least_
                                name: _default_title_
                                description: ola
                                data_type: string
                                input_options: null
                                order: 0
                                required_to_create: true
                                required_to_create_for_contacts: false
                                visible_on_create: true
                                visible_to_contacts: false
                                default: false
                                ticket_type_id: 48
                                archived: false
                                created_at: 1736201986
                                updated_at: 1736201986
                              - type: ticket_type_attribute
                                id: '88'
                                workspace_id: this_is_an_id704_that_should_be_at_least_
                                name: _default_description_
                                description: ola
                                data_type: string
                                input_options: null
                                order: 0
                                required_to_create: true
                                required_to_create_for_contacts: false
                                visible_on_create: true
                                visible_to_contacts: false
                                default: false
                                ticket_type_id: 48
                                archived: false
                                created_at: 1736201986
                                updated_at: 1736201986
                          category: Back-office
                        contacts:
                          type: contact.list
                          contacts:
                            - type: contact
                              id: 677c57026abd011ad17ff5c7
                              external_id: a3796621-c64d-45d3-9491-49f6aaf4047a
                        admin_assignee_id: '0'
                        team_assignee_id: '0'
                        created_at: 1736201987
                        updated_at: 1736201988
                        ticket_parts:
                          type: ticket_part.list
                          ticket_parts:
                            - type: ticket_part
                              id: '61'
                              part_type: ticket_state_updated_by_admin
                              ticket_state: submitted
                              previous_ticket_state: submitted
                              created_at: 1736201987
                              updated_at: 1736201987
                              author:
                                id: '991266828'
                                type: admin
                                name: Ciaran534 Lee
                                email: admin534@email.com
                              attachments: []
                              redacted: false
                          total_count: 1
                        open: true
                        linked_objects:
                          type: list
                          data: []
                          total_count: 0
                          has_more: false
                        category: Back-office
                        is_shared: false
              schema:
                $ref: '#/components/schemas/ticket_list'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/search_request'
            examples:
              successful:
                summary: successful
                value:
                  query:
                    operator: AND
                    value:
                      - field: created_at
                        operator: '>'
                        value: '1306054154'
                  pagination:
                    per_page: 5
components:
  schemas:
    cursor_pages:
      title: Cursor based pages
      type: object
      description: |
        Cursor-based pagination is a technique used in the Intercom API to navigate through large amounts of data.
        A "cursor" or pointer is used to keep track of the current position in the result set, allowing the API to return the data in small chunks or "pages" as needed.
      nullable: true
      properties:
        type:
          type: string
          description: the type of object `pages`.
          example: pages
          enum:
            - pages
        page:
          type: integer
          description: The current page
          example: 1
        next:
          $ref: '#/components/schemas/starting_after_paging'
        per_page:
          type: integer
          description: Number of results per page
          example: 2
        total_pages:
          type: integer
          description: Total number of pages
          example: 13
    intercom_version:
      description: Intercom API version.</br>By default, it's equal to the version set in the app package.
      type: string
      example: '2.12'
      default: '2.12'
      enum:
        - '1.0'
        - '1.1'
        - '1.2'
        - '1.3'
        - '1.4'
        - '2.0'
        - '2.1'
        - '2.2'
        - '2.3'
        - '2.4'
        - '2.5'
        - '2.6'
        - '2.7'
        - '2.8'
        - '2.9'
        - '2.10'
        - '2.11'
        - '2.12'
        - Preview
    linked_object_list:
      title: Linked Objects
      type: object
      description: An object containing metadata about linked conversations and linked tickets. Up to 1000 can be returned.
      properties:
        type:
          type: string
          description: Always list.
          enum:
            - list
          example: list
        total_count:
          type: integer
          description: The total number of linked objects.
          example: 100
        has_more:
          type: boolean
          description: Whether or not there are more linked objects than returned.
          example: false
        data:
          type: array
          description: An array containing the linked conversations and linked tickets.
          items:
            $ref: '#/components/schemas/linked_object'
    multiple_filter_search_request:
      title: Multiple Filter Search Request
      description: Search using Intercoms Search APIs with more than one filter.
      type: object
      properties:
        operator:
          type: string
          enum:
            - AND
            - OR
          description: An operator to allow boolean inspection between multiple fields.
          example: AND
        value:
          oneOf:
            - type: array
              description: Add mutiple filters.
              title: multiple filter search request
              items:
                $ref: '#/components/schemas/multiple_filter_search_request'
            - type: array
              description: Add a single filter field.
              title: single filter search request
              items:
                $ref: '#/components/schemas/single_filter_search_request'
    search_request:
      description: Search using Intercoms Search APIs.
      type: object
      title: Search data
      properties:
        query:
          oneOf:
            - $ref: '#/components/schemas/single_filter_search_request'
              title: Single filter search request
            - $ref: '#/components/schemas/multiple_filter_search_request'
              title: multiple filter search request
        pagination:
          $ref: '#/components/schemas/starting_after_paging'
      required:
        - query
    single_filter_search_request:
      title: Single Filter Search Request
      description: Search using Intercoms Search APIs with a single filter.
      type: object
      properties:
        field:
          type: string
          description: The accepted field that you want to search on.
          example: created_at
        operator:
          type: string
          enum:
            - '='
            - '!='
            - IN
            - NIN
            - <
            - <=
            - '>'
            - '>='
            - '~'
            - '!~'
            - ^
            - $
          description: |-
            The accepted operators you can use to define how you want to search for the value. Operator support depends on the field's data type. The breakdown below is for Contacts search; the other search endpoints that share this schema accept a different set per field:
            - `string` fields: `=`, `!=`, `IN`, `NIN`, `~`, `!~`, `^`, `$`
            - `tag_id`: `=` and `!=` only. Every other operator returns an error.
            - `boolean` fields: `=`, `!=`, `IN`, `NIN`
            - `integer` fields: `=`, `!=`, `IN`, `NIN`, `<`, `>`, `<=`, `>=`
            - `date` fields (all standard timestamp attributes and date custom attributes): `=`, `<`, `>` only. `!=`, `<=`, `>=`, `IN`, and `NIN` are not supported and return an error.
          example: '>'
        value:
          oneOf:
            - type: string
            - type: integer
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: integer
          description: The value that you want to search on.
          example: '73732934'
          nullable: true
    starting_after_paging:
      title: 'Pagination: Starting After'
      type: object
      nullable: true
      properties:
        per_page:
          type: integer
          description: The number of results to fetch per page.
          example: 2
        starting_after:
          type: string
          description: The cursor to use in the next request to get the next page of results.
          nullable: true
          example: your-cursor-from-response
    ticket:
      title: Ticket
      type: object
      x-tags:
        - Tickets
      description: Tickets are how you track requests from your users.
      nullable: true
      properties:
        type:
          type: string
          description: Always ticket
          enum:
            - ticket
          default: ticket
          example: ticket
        id:
          type: string
          description: The unique identifier for the ticket which is given by Intercom.
          example: '1295'
        ticket_id:
          type: string
          description: The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries.
          example: '1390'
        category:
          type: string
          description: Category of the Ticket.
          enum:
            - Customer
            - Back-office
            - Tracker
          example: Customer
        ticket_attributes:
          $ref: '#/components/schemas/ticket_custom_attributes'
        ticket_state:
          $ref: '#/components/schemas/ticket_state'
        ticket_type:
          $ref: '#/components/schemas/ticket_type'
        contacts:
          $ref: '#/components/schemas/ticket_contacts'
        admin_assignee_id:
          type: string
          description: The id representing the admin assigned to the ticket.
          example: '1295'
        team_assignee_id:
          type: string
          description: The id representing the team assigned to the ticket.
          example: '1295'
        created_at:
          type: integer
          format: date-time
          description: The time the ticket was created as a UTC Unix timestamp.
          example: 1663597223
        updated_at:
          type: integer
          format: date-time
          description: The last time the ticket was updated as a UTC Unix timestamp.
          example: 1663597260
        open:
          type: boolean
          description: Whether or not the ticket is open. If false, the ticket is closed.
          example: true
        snoozed_until:
          type: integer
          format: date-time
          description: The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed.
          example: 1663597260
        linked_objects:
          $ref: '#/components/schemas/linked_object_list'
        ticket_parts:
          $ref: '#/components/schemas/ticket_parts'
        is_shared:
          type: boolean
          description: Whether or not the ticket is shared with the customer.
          example: true
    ticket_contacts:
      title: Contacts
      type: object
      x-tags:
        - Tickets
      description: The list of contacts affected by a ticket.
      properties:
        type:
          type: string
          description: always contact.list
          enum:
            - contact.list
          example: contact.list
        contacts:
          type: array
          description: The list of contacts affected by this ticket.
          items:
            $ref: '#/components/schemas/contact_reference'
    ticket_custom_attributes:
      title: Ticket Attributes
      type: object
      description: An object containing the different attributes associated to the ticket as key-value pairs. For the default title and description attributes, the keys are `_default_title_` and `_default_description_`.
      additionalProperties:
        anyOf:
          - type: string
            nullable: true
          - type: number
          - type: boolean
          - type: array
          - $ref: '#/components/schemas/file_attribute'
      example:
        _default_title_: Found a bug
        _default_description_: The button's not working
    ticket_list:
      title: Ticket List
      type: object
      description: Tickets are how you track requests from your users.
      properties:
        type:
          type: string
          description: Always ticket.list
          enum:
            - ticket.list
          example: ticket.list
        tickets:
          type: array
          description: The list of ticket objects
          items:
            $ref: '#/components/schemas/ticket'
        total_count:
          type: integer
          description: A count of the total number of objects.
          example: 12345
        pages:
          $ref: '#/components/schemas/cursor_pages'
    ticket_parts:
      title: Ticket Parts
      type: object
      description: A list of Ticket Part objects for each note and event in the ticket. There is a limit of 500 parts.
      properties:
        type:
          type: string
          description: ''
          enum:
            - ticket_part.list
          example: ticket_part.list
        ticket_parts:
          title: Tickt Parts
          type: array
          description: A list of Ticket Part objects for each ticket. There is a limit of 500 parts.
          items:
            $ref: '#/components/schemas/ticket_part'
        total_count:
          type: integer
          description: ''
          example: 2
    ticket_state:
      title: Ticket State
      type: object
      x-tags:
        - Tickets
      description: A ticket state, used to define the state of a ticket.
      nullable: true
      properties:
        type:
          type: string
          description: String representing the object's type. Always has the value `ticket_state`.
          example: ticket_state
        id:
          type: string
          description: The id of the ticket state
          example: '12'
        category:
          type: string
          description: The category of the ticket state
          example: in_progress
          enum:
            - submitted
            - in_progress
            - waiting_on_customer
            - resolved
        internal_label:
          type: string
          description: The state the ticket is currently in, in a human readable form - visible in Intercom
          example: With Dev Team
        external_label:
          type: string
          description: The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal.
          example: In Progress
    ticket_type:
      title: Ticket Type
      type: object
      x-tags:
        - Tickets
      description: A ticket type, used to define the data fields to be captured in a ticket.
      nullable: true
      properties:
        type:
          type: string
          description: String representing the object's type. Always has the value `ticket_type`.
          example: ticket_type
        id:
          type: string
          description: The id representing the ticket type.
          example: '1295'
        category:
          type: string
          description: Category of the Ticket Type.
          enum:
            - Customer
            - Back-office
            - Tracker
          example: Customer
        name:
          type: string
          description: The name of the ticket type
          example: Bug
        description:
          type: string
          description: The description of the ticket type
          example: A bug that has been reported.
        icon:
          type: string
          description: The icon of the ticket type
          example: 🐞
        workspace_id:
          type: string
          description: The id of the workspace that the ticket type belongs to.
          example: ecahpwf5
        ticket_type_attributes:
          $ref: '#/components/schemas/ticket_type_attribute_list'
        ticket_states:
          title: Ticket States
          type: object
          description: A list of ticket states associated with a given ticket type.
          properties:
            type:
              type: string
              description: String representing the object's type. Always has the value `list`.
              example: list
            data:
              type: array
              description: A list of ticket states associated with a given ticket type.
              items:
                $ref: '#/components/schemas/ticket_state'
        archived:
          type: boolean
          description: Whether the ticket type is archived or not.
          example: false
        created_at:
          type: integer
          format: timestamp
          description: The date and time the ticket type was created.
        updated_at:
          type: integer
          format: timestamp
          description: The date and time the ticket type was last updated.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
```
