Pagination
Every list endpoint returns the same envelope:
{ "results": [{ "id": "0192f3a1-7c2e-7b4d-9a61-400000000001", "title": "Bail - Lot 12" }], "nextPageToken": "eyJrIjoiMDE5MmYzYTEtN2MyZS03YjRkLTlhNjEtNDAwMDAwMDAwMDAxIn0"}Paginated lists
Section titled “Paginated lists”These lists are paginated with an opaque cursor:
| Endpoint | Order |
|---|---|
GET /v1/signature-requests |
Newest first |
GET /v1/registered-mails |
Newest first |
GET /v1/contacts |
By name, or most recently updated (sort=updated) |
| Parameter | Description |
|---|---|
pageSize |
Items per page, 1 to 100, default 25. |
pageToken |
The nextPageToken of the previous page. Omit it for the first page. |
nextPageToken is absent on the last page. Tokens are opaque: do not parse or build them, and keep the same filters while paging (an invalid token answers 422 invalid_page_token).
Other lists (nodes, members, roles, tags, sender accounts, task occurrences of a date range, activity, grants) return every result in one response, without nextPageToken.
Iterate over every page
Section titled “Iterate over every page”token=""while :; do page=$(curl -s -G "$MLT_API_URL/v1/contacts" -H "Authorization: Bearer $MLT_TOKEN" \ --data-urlencode "entityId=$ENTITY_ID" --data-urlencode "pageSize=100" \ ${token:+--data-urlencode "pageToken=$token"}) echo "$page" | jq -c '.results[] | {id, displayName}' token=$(echo "$page" | jq -r '.nextPageToken // empty') [ -z "$token" ] && breakdoneasync function* listAll<T>(path: string, params: Record<string, string>): AsyncGenerator<T> { let pageToken: string | undefined; do { const query = new URLSearchParams({ ...params, pageSize: '100', ...(pageToken ? { pageToken } : {}) }); const response = await fetch(`${process.env.MLT_API_URL}${path}?${query}`, { headers: { Authorization: `Bearer ${token}` }, }); const page = (await response.json()) as { results: T[]; nextPageToken?: string }; yield* page.results; pageToken = page.nextPageToken; } while (pageToken);}
for await (const contact of listAll<{ id: string; displayName: string }>('/v1/contacts', { entityId })) { console.log(contact.id, contact.displayName);}def list_all(path: str, **params): page_token = None while True: query = {**params, "pageSize": 100, **({"pageToken": page_token} if page_token else {})} page = requests.get(f"{api}{path}", params=query, headers=headers).json() yield from page["results"] page_token = page.get("nextPageToken") if not page_token: break
for contact in list_all("/v1/contacts", entityId=entity_id): print(contact["id"], contact["displayName"])function listAll(GuzzleHttp\Client $http, string $path, array $params, array $headers): Generator{ $pageToken = null; do { $query = $params + ['pageSize' => 100] + ($pageToken ? ['pageToken' => $pageToken] : []); $page = json_decode((string) $http->get(getenv('MLT_API_URL') . $path, ['headers' => $headers, 'query' => $query])->getBody(), true); yield from $page['results']; $pageToken = $page['nextPageToken'] ?? null; } while ($pageToken);}
foreach (listAll($http, '/v1/contacts', ['entityId' => $entityId], $headers) as $contact) { echo $contact['id'], ' ', $contact['displayName'], PHP_EOL;}