Skip to main content
Foil uses cursor-based pagination on the list endpoints for sessions, fingerprints, and API keys. Cursors are opaque - don’t parse them, construct them, or rely on their format. They’re stable across process restarts and safe to persist in your own database if you want to resume a long iteration. Two list endpoints don’t paginate. GET /v1/organizations/{organizationId}/webhooks/endpoints takes no query parameters and returns every endpoint. GET /v1/organizations/{organizationId}/events accepts limit, type, and endpoint_id, but it has no cursor, so it returns at most one page and always reports has_more as false. See Request parameters.

Response envelope

Every list response has the same shape:
Endpoints that return one resource wrap it in a data envelope instead: { "data": { ... }, "meta": { "request_id": "req_..." } }.

Request parameters

The sessions, fingerprints, and API keys list endpoints accept these two query parameters: The list endpoints don’t support offset. A request that includes it returns 422; use cursor instead. Foil ignores other query parameters that an endpoint doesn’t define. See the per-resource filter sections below for the filter parameters.

Iterating

The canonical pattern: call the endpoint, process data, and loop while has_more is true, passing next_cursor forward.

Auto-pagination in the SDKs

Every server SDK has an iterator for sessions and fingerprints that runs the cursor loop for you. Use it when you want to walk the entire result set without managing state.
The iterators request one page at a time and yield items as they go, so they’re safe to use on result sets that wouldn’t fit in memory. They make the same number of requests as manual iteration and count against the same rate limits. They don’t retry: if a page request fails, the iterator raises the error, and it doesn’t expose the cursor it reached. For long iterations that must resume after a failure, page manually and persist next_cursor. The Go iterator stops at the first error that your callback returns.

Filters and sorting

Filter parameters layer on top of the standard pagination params. They narrow the result set but don’t change the envelope shape.

Sessions

GET /v1/sessions returns one row per session, ordered by the time of its latest decision, newest first. A search value that starts with sid_, evt_, or vid_ matches a session ID, event ID, or visitor ID exactly, ignoring case. A 32-character hexadecimal value matches a legacy session ID or event ID exactly. Any other value is a case-insensitive substring match against the session ID, event ID, visitor ID, client_user_id, page URL, user agent, and IP address.

Fingerprints

GET /v1/fingerprints returns one row per visitor fingerprint. The default order is most recently seen first. A fingerprint cursor is tied to the sort value of the request that returned it. Pass the same sort with every request in an iteration. A cursor used with a different sort returns 422.

API keys

Events

Events are ordered newest first. The endpoint returns a single page. Combining filters and pagination is supported: pass the filters once, and carry the cursor forward as normal. The server applies filters before paginating, so limit controls page size of the filtered result set.

Caveats

  • Don’t construct cursors. They’re opaque tokens - the server may change their encoding. To find a specific session or visitor, use the search parameter instead.
  • Cursor lifetimes. Cursors remain valid as long as the underlying result set does - a cursor minted today is valid until the records it points into expire. Stored sessions and visitor fingerprints are not currently expired on a fixed window.
  • Result stability under concurrent writes. Sessions, and fingerprints in the default order, are ordered newest first, so records created or updated after you start iterating land ahead of your cursor and don’t appear in later pages. A session that receives a new decision during an iteration moves to the front of the ordering. The list endpoints have no time filters. To audit a fixed window, iterate from the newest record and stop when latest_decision.evaluated_at falls before the start of the window.
  • Ordering. Each list endpoint documents its default sort in Filters and sorting. Don’t assume an order that isn’t explicitly documented.

What’s next

Authentication

Key types and scopes.

Errors

Envelope shape, status codes, retry semantics.

Sessions

The most common list endpoint.

Fingerprints

Visitor fingerprint lookup.