Skip to main content
All list endpoints in the Deck API use cursor-based pagination. Each response includes a data array, a has_more flag, and a next_cursor value you pass on subsequent requests to fetch the next page.

Request parameters

ParameterTypeDefaultDescription
limitinteger20Number of results per page. Min 1, max 100.
cursorstringCursor from a previous response. Omit for the first page.
curl "https://api.deck.co/v2/agents?limit=50" \
  -H "Authorization: Bearer sk_live_your_key_here"

Response format

Every list response has the same shape:
data
array
Array of resource objects for the current page.
has_more
boolean
true if there are more results beyond this page. false on the last page.
next_cursor
string or null
An opaque string to pass as the cursor query parameter on the next request. null when there are no more pages.
request_id
string
Unique identifier for the API request.
{
  "data": [
    { "id": "agt_abc...", "object": "agent", "name": "Hotel Reservations" },
    { "id": "agt_def...", "object": "agent", "name": "Expense Reports" }
  ],
  "has_more": true,
  "next_cursor": "eyJpZCI6ImFnZW50X2RlZiJ9",
  "request_id": "req_a1b2c3d4..."
}

Fetching the next page

Pass next_cursor from the previous response as the cursor query parameter:
curl "https://api.deck.co/v2/agents?limit=50&cursor=eyJpZCI6ImFnZW50X2RlZiJ9" \
  -H "Authorization: Bearer sk_live_your_key_here"
Continue until has_more is false.

Paginating through all results

async function fetchAll(endpoint) {
  const results = []
  let cursor = null

  do {
    const url = new URL(`https://api.deck.co/v2/${endpoint}`)
    url.searchParams.set('limit', '100')
    if (cursor) url.searchParams.set('cursor', cursor)

    const res = await fetch(url, {
      headers: { 'Authorization': `Bearer ${process.env.DECK_API_KEY}` },
    })

    const page = await res.json()
    results.push(...page.data)
    cursor = page.next_cursor
  } while (cursor)

  return results
}

const allAgents = await fetchAll('agents')

Filtering and sorting

List endpoints may accept additional query parameters for filtering. Filters are applied server-side before pagination, so the limit applies to filtered results.
curl "https://api.deck.co/v2/task-runs?connection_id=conn_abc123&limit=50" \
  -H "Authorization: Bearer sk_live_your_key_here"
Results are returned in reverse chronological order (newest first) by default.

Cursors are opaque

Cursor values are opaque strings. Do not parse, construct, or store them long-term. They encode internal position state and may change format between API versions.
  • Pass them exactly as received from the API.
  • Do not reuse cursors across different endpoints or filter combinations.
  • If a cursor becomes invalid, the API returns a 400 error with cursor_invalid. Start from the first page.

Stable ordering

Deck guarantees stable ordering within a paginated sequence. If no records are created or deleted between requests, every record appears exactly once across all pages. Records created after you begin paginating may or may not appear depending on their position in the sort order.