Skip to content
Theme
Upload a photo Upload
Theme
Theme
Upload a photo

Developers

Pagination

List endpoints use cursor pagination with limit, cursor, has_more and next_cursor. Loop examples included.

On this page
  1. Parameters
  2. The list response
  3. Paginated endpoints
  4. Read every 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 parameterWhat it does
limitItems per page, from 1 to 100. The default is 20. Over 100 returns 422 validation_failed.
cursorThe next_cursor from the page before. Leave it out for the first page.

The list response#

GET /v1/webhook-endpoints
{
  "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
}
FieldWhat it is
objectAlways "list".
dataThe items on this page, newest first.
has_moretrue when there is another page.
next_cursorPass it as cursor to get the next page. null on the last page.
livemodeWhether 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/ledger
  • GET /v1/webhook-endpoints

Read every page#

PHP
<?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";
}
JavaScript
// 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.

Type at least 2 letters. Use the arrow keys to move and Enter to open.

    Type at least 2 letters. Use the arrow keys to move and Enter to open.