---
title: "List contacts"
description: "Returns a paginated list of contacts, sorted by first name by default."
version: "v2"
---

> Documentation Index
> Fetch the complete documentation index at: https://dev.messageport.com.au/llms.txt
> Use this file to discover all available pages before exploring further.

Path: MessagePort API › Contacts

`GET /v2/contacts`

Returns a paginated list of contacts, sorted by first name by default.

## Authentication

- `basicAuth`, http, header `Authorization`

## Query parameters

- `search` (`listContacts.query.search`; string, optional) — Search term.
- `sort_by` (`listContacts.query.sort_by`; string, optional) — Field to sort by.
  - one of `"id"`, `"firstname"`, `"surname"`, `"created"`; default `"firstname"`
- `sort_order` (`listContacts.query.sort_order`; string, optional) — Sort direction.
  - one of `"asc"`, `"desc"`; default `"asc"`
- `per_page` (`listContacts.query.per_page`; integer, optional) — Results per page.
  - min 10; max 200; default `50`
- `page` (`listContacts.query.page`; integer, optional) — Page number. Prefer following `links.next` until it is `null`.
  - min 1; default `1`
- `with_global` (`listContacts.query.with_global`; boolean, optional) — Include global (account-wide) contacts in the results.
  - default `false`

## Code samples

### cURL

```bash
curl --request GET \
  --url https://app.messageport.com.au/api/v2/contacts \
  --header 'Authorization: Basic <credentials>'
```

### TypeScript

```typescript
const url = 'https://app.messageport.com.au/api/v2/contacts';
const options = {method: 'GET', headers: {Authorization: 'Basic <credentials>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://app.messageport.com.au/api/v2/contacts"

headers = {"Authorization": "Basic <credentials>"}

response = requests.get(url, headers=headers)

print(response.text)
```

## Responses

### 200

A page of contacts.

#### Example

```json
{
  "data": [
    {
      "id": 4040,
      "user": 5678,
      "firstname": "Sam",
      "surname": "Taylor",
      "email": "sam@example.com",
      "number": "+61412345678",
      "metadata": null,
      "groups": [
        {
          "id": 512,
          "name": "Customers"
        }
      ],
      "updated": "2024-03-11T02:14:07Z",
      "created": "2024-02-02T23:51:19Z"
    }
  ],
  "links": {
    "first": "https://app.messageport.com.au/api/v2/contacts?page=1",
    "last": "https://app.messageport.com.au/api/v2/contacts?page=8",
    "prev": null,
    "next": "https://app.messageport.com.au/api/v2/contacts?page=2"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 8,
    "path": "https://app.messageport.com.au/api/v2/contacts",
    "per_page": 50,
    "to": 50,
    "total": 400
  }
}
```

- `data` (`listContacts.response.200.data`; array<object>, optional)
  - `id` (`listContacts.response.200.data.id`; integer, optional)
  - `user` (`listContacts.response.200.data.user`; integer, optional) — ID of the user that owns the contact.
  - `account` (`listContacts.response.200.data.account`; integer, optional) — Account ID. Only present on global contacts.
  - `firstname` (`listContacts.response.200.data.firstname`; string | null, optional)
  - `surname` (`listContacts.response.200.data.surname`; string | null, optional)
  - `email` (`listContacts.response.200.data.email`; string | null, optional)
  - `number` (`listContacts.response.200.data.number`; string, optional)
  - `metadata` (`listContacts.response.200.data.metadata`; object | null, optional)
  - `groups` (`listContacts.response.200.data.groups`; array<object>, optional)
    - `id` (`listContacts.response.200.data.groups.id`; integer, optional)
    - `name` (`listContacts.response.200.data.groups.name`; string, optional)
  - `notes` (`listContacts.response.200.data.notes`; array<object>, optional) — Notes on the contact. Only returned when getting or updating a single contact.
    - `id` (`listContacts.response.200.data.notes.id`; integer, optional)
    - `content` (`listContacts.response.200.data.notes.content`; string, optional)
    - `created_at` (`listContacts.response.200.data.notes.created_at`; string, optional)
      - format `date-time`
    - `updated_at` (`listContacts.response.200.data.notes.updated_at`; string, optional)
      - format `date-time`
  - `updated` (`listContacts.response.200.data.updated`; string, optional)
    - format `date-time`
  - `created` (`listContacts.response.200.data.created`; string, optional)
    - format `date-time`
- `links` (`listContacts.response.200.links`; object, optional) — Links to other pages. `next` is `null` on the last page.
  - example `{"first":"https://app.messageport.com.au/api/v2/contacts?page=1","last":"https://app.messageport.com.au/api/v2/contacts?page=8","prev":null,"next":"https://app.messageport.com.au/api/v2/contacts?page=2"}`
  - `first` (`listContacts.response.200.links.first`; string | null, optional)
    - format `uri`
  - `last` (`listContacts.response.200.links.last`; string | null, optional)
    - format `uri`
  - `prev` (`listContacts.response.200.links.prev`; string | null, optional)
    - format `uri`
  - `next` (`listContacts.response.200.links.next`; string | null, optional)
    - format `uri`
- `meta` (`listContacts.response.200.meta`; object, optional) — Position in the result set. Read `per_page` rather than assuming a page size.
  - example `{"current_page":1,"from":1,"last_page":8,"path":"https://app.messageport.com.au/api/v2/contacts","per_page":50,"to":50,"total":400}`
  - `current_page` (`listContacts.response.200.meta.current_page`; integer, optional)
  - `from` (`listContacts.response.200.meta.from`; integer | null, optional)
  - `last_page` (`listContacts.response.200.meta.last_page`; integer, optional)
  - `path` (`listContacts.response.200.meta.path`; string, optional)
    - format `uri`
  - `per_page` (`listContacts.response.200.meta.per_page`; integer, optional)
  - `to` (`listContacts.response.200.meta.to`; integer | null, optional)
  - `total` (`listContacts.response.200.meta.total`; integer, optional)
  - `links` (`listContacts.response.200.meta.links`; array<object>, optional) — Page links for building pagination controls.
    - `url` (`listContacts.response.200.meta.links.url`; string | null, optional)
    - `label` (`listContacts.response.200.meta.links.label`; string, optional)
    - `active` (`listContacts.response.200.meta.links.active`; boolean, optional)

### 401

Missing, malformed or invalid API credentials.

#### Example

```json
{
  "message": "Unauthenticated."
}
```

- `message` (`listContacts.response.401.message`; string, required)

### 422

The request failed validation. `errors` lists the messages for each invalid field.

#### Example

```json
{
  "message": "The messages field is required.",
  "errors": {
    "messages": [
      "The messages field is required."
    ]
  }
}
```

- `message` (`listContacts.response.422.message`; string, optional)
- `errors` (`listContacts.response.422.errors`; map<array<string>>, optional)


Source: https://dev.messageport.com.au/api/contacts/list/index.md
