Skip to main content

Overview

All Flextell list endpoints use cursor-based pagination. Instead of page numbers, you pass a cursor value from the previous response to fetch the next set of results. This approach is stable even when records are added or removed between requests.

Response structure

Every list endpoint returns a data array and a meta object:
{
  "data": [
    { "id": "res_001", "name": "First result" },
    { "id": "res_002", "name": "Second result" }
  ],
  "meta": {
    "cursor": "cursor_eyJpZCI6InJlc18wMDIifQ",
    "has_more": true,
    "total": 84
  }
}

Meta fields

FieldTypeDescription
cursorstringAn opaque string to pass as the cursor parameter in your next request. null when there are no more pages.
has_morebooleantrue if there are additional results beyond this page.
totalnumberThe total number of results across all pages.

Request parameters

ParameterTypeDefaultMaxDescription
limitnumber20100Number of results to return per page.
cursorstringCursor from the previous response’s meta.cursor. Omit on the first request.

Example: fetching pages

First request

Omit the cursor parameter to start from the beginning:
curl --request GET \
  --url "https://dev.flextell.ai/api/resources?limit=20" \
  --header "Authorization: Bearer <your_token>" \
  --header "Accept: application/json"
Response:
{
  "data": [
    { "id": "res_001", "name": "First result" },
    { "id": "res_002", "name": "Second result" }
  ],
  "meta": {
    "cursor": "cursor_eyJpZCI6InJlc18wMDIifQ",
    "has_more": true,
    "total": 84
  }
}

Next request

Pass meta.cursor from the previous response as the cursor query parameter:
curl --request GET \
  --url "https://dev.flextell.ai/api/resources?limit=20&cursor=cursor_eyJpZCI6InJlc18wMDIifQ" \
  --header "Authorization: Bearer <your_token>" \
  --header "Accept: application/json"
Continue passing the new cursor value on each request until has_more is false.
Cursor values are opaque strings — do not parse or construct them manually. Always use the exact value returned in meta.cursor.

Fetching all pages automatically

Use a loop that continues until has_more is false:
async function fetchAllResources(token) {
  const results = [];
  let cursor = null;

  do {
    const url = new URL('https://dev.flextell.ai/api/resources');
    url.searchParams.set('limit', '100');
    if (cursor) {
      url.searchParams.set('cursor', cursor);
    }

    const response = await fetch(url.toString(), {
      headers: {
        'Authorization': `Bearer ${token}`,
        'Accept': 'application/json',
      },
    });

    if (!response.ok) {
      throw new Error(`Request failed with status ${response.status}`);
    }

    const { data, meta } = await response.json();

    results.push(...data);
    cursor = meta.has_more ? meta.cursor : null;
  } while (cursor !== null);

  return results;
}
Set limit to 100 (the maximum) when fetching all pages to minimize the number of requests.
Fetching all pages can result in many API requests for large datasets. If you only need a subset of results, use filtering parameters on the endpoint instead of paginating through everything.