---
operation: Bot.contactsConnection
kind: query
graphql_type: Bot
role: Agent
reference_url: https://chatfuel.com/pt/docs/public-api/contacts#como-pesquisar-e-ler-contatos
lang: pt
---

# Bot.contactsConnection

Paginated search, up to 500 per page, optionally filtered by a segment and sorted by an attribute.

```graphql
contactsConnection(platforms: [Platform!]!, first: Int!, before: ContactSearchCursor, after: ContactSearchCursor, segment: SegmentInput, orderBy: ContactSearchOrderByInput): ContactConnection!
```

- Kind: query (field of `Bot`, read through `bot(id:)`)
- Role: Agent
- Reference: [Referência da API de contatos › Como pesquisar e ler contatos](https://chatfuel.com/pt/docs/public-api/contacts#como-pesquisar-e-ler-contatos)

---

The reference section that defines it, from [Referência da API de contatos](https://chatfuel.com/pt/docs/public-api/contacts#como-pesquisar-e-ler-contatos):

## Como pesquisar e ler contatos [#como-pesquisar-e-ler-contatos]

```graphql
type Bot {
  # Agent. One contact by ID.
  contact(id: ContactID!): Contact!
  # Agent. Paginated search, up to 500 per page, optionally filtered by a segment and sorted by an attribute.
  contactsConnection(
    platforms: [Platform!]!          # whatsapp, instagram, facebook, tiktok, widget
    first: Int!
    before: ContactSearchCursor
    after: ContactSearchCursor
    segment: SegmentInput
    orderBy: ContactSearchOrderByInput   # { orderBy: <attribute name>, direction: Asc | Desc }
  ): ContactConnection!
  # Agent. Number of contacts matching the platforms and segment.
  contactsCount(platforms: [Platform!]!, segment: SegmentInput): Int!
  contactsTotalCount(platforms: [Platform!]!, segment: SegmentInput): Int!
}
```

`Contact` é uma interface; os contatos do WhatsApp são `WhatsappContact`, com um campo `phone` extra, e há tipos semelhantes para os outros canais. Todo contato tem:

```graphql
query Contact($botID: BotID!, $contactID: ContactID!) {
  bot(id: $botID) {
    contact(id: $contactID) {
      id
      name
      note
      updatedAt
      salesStageV2              # New, Sorting, Ready, WorkingOn, Won, Lost
      lastConversationMessageTime
      unreadMessagesCount
      unhandledSwitchToHuman    # handed to a human and not opened yet
      assignee {
        ... on PublicUserAccount { id name accountType }
        ... on FuelyAIAssignee { __typename }
      }
      attributes(names: ["email", "city"]) {
        attr { name type }
        value {
          ... on BotAttributeValueString { stringValue }
          ... on BotAttributeValueDouble { doubleValue }
          ... on BotAttributeValueBoolean { booleanValue }
          ... on BotAttributeValueDatetime { datetimeValue }
        }
      }
      ... on WhatsappContact { phone }
    }
  }
}
```

---

Other operations on the same page:

- [`Bot.contact`](https://chatfuel.com/docs/api/v1/operations/Bot.contact?lang=pt): One contact by ID.
- [`Bot.contactsCount`](https://chatfuel.com/docs/api/v1/operations/Bot.contactsCount?lang=pt): Number of contacts matching the platforms and segment.
- [`Bot.contactsTotalCount`](https://chatfuel.com/docs/api/v1/operations/Bot.contactsTotalCount?lang=pt)

Before the first request: [Autenticação e tokens da Public API](https://chatfuel.com/docs/api/v1/page?path=public-api/authentication&lang=pt), [Como fazer requisições à Public API](https://chatfuel.com/docs/api/v1/page?path=public-api/requests&lang=pt), [Erros e códigos de erro da Public API](https://chatfuel.com/docs/api/v1/page?path=public-api/errors&lang=pt).
