Developers
Pagination
List endpoints use cursor pagination with limit, cursor, has_more and next_cursor. Loop examples included.
On this page
Endpoints that return many items use cursor pagination. You get one page at a time, plus a cursor that points to the next page. Cursors stay correct even when new items arrive while you read.
Parameters#
| Query parameter | What it does |
|---|---|
limit | Items per page, from 1 to 100. The default is 20. Over 100 returns 422 validation_failed. |
cursor | The next_cursor from the page before. Leave it out for the first page. |
The list response#
{
"object": "list",
"data": [
{
"object": "webhook_endpoint",
"id": "we_01JD3XK5Z3Q8W3J9P2R7M4N6T1",
"url": "https://example.com/webhooks/studio",
"description": "My shop backend",
"events": ["*"],
"status": "active",
"livemode": false,
"disabled_at": null,
"created_at": "2026-11-17T09:31:40Z"
}
],
"has_more": false,
"next_cursor": null,
"livemode": false
}
| Field | What it is |
|---|---|
object | Always "list". |
data | The items on this page, newest first. |
has_more | true when there is another page. |
next_cursor | Pass it as cursor to get the next page. null on the last page. |
livemode | Whether these items are live or test. |
Treat cursors as opaque strings. Do not build or change them, and do not store them for long: use them to walk a list now.
Paginated endpoints#
GET /v1/ledgerGET /v1/webhook-endpoints
Read every page#
<?php
/**
* Yields every item of a list endpoint, page by page, following next_cursor.
*
* @return Generator<int, array<string, mixed>>
*/
function studioPages(string $path, string $apiKey, int $limit = 100): Generator
{
$cursor = null;
do {
$query = http_build_query(array_filter(['limit' => $limit, 'cursor' => $cursor]));
$curl = curl_init("https://studio-api.mutexai.net/v1{$path}?{$query}");
curl_setopt_array($curl, [
CURLOPT_HTTPHEADER => ['Authorization: Bearer '.$apiKey, 'Accept: application/json'],
CURLOPT_RETURNTRANSFER => true,
]);
$page = json_decode(curl_exec($curl), true);
curl_close($curl);
yield from $page['data'];
$cursor = $page['has_more'] ? $page['next_cursor'] : null;
} while ($cursor !== null);
}
foreach (studioPages('/webhook-endpoints', getenv('MUTEXAI_API_KEY')) as $endpoint) {
echo $endpoint['id'], ' ', $endpoint['url'], "\n";
}
// Yields every item of a list endpoint, page by page, following next_cursor.
async function* studioPages(path, apiKey, limit = 100) {
let cursor = null;
do {
const query = new URLSearchParams({ limit: String(limit), ...(cursor ? { cursor } : {}) });
const response = await fetch(`https://studio-api.mutexai.net/v1${path}?${query}`, {
headers: { Authorization: `Bearer ${apiKey}`, Accept: 'application/json' },
});
const page = await response.json();
yield* page.data;
cursor = page.has_more ? page.next_cursor : null;
} while (cursor);
}
for await (const entry of studioPages('/ledger', process.env.MUTEXAI_API_KEY)) {
console.log(entry.created_at, entry.type, entry.credits);
}
Still stuck? Email [email protected] with what you tried and, for API problems, the request_id.