Paginate large SOQL query results using nextRecordsUrl
domain: developer.salesforce.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.
Steps
Send GET to /services/data/vXX.0/query?q={URL-encoded SOQL} to start the query
Inspect the response: if done is false, a nextRecordsUrl property is present
Fetch the next page by sending GET to the base instance URL + nextRecordsUrl value (it is a relative path)
Repeat until the done field in the response is true
Collect records from the records array across all pages
Known gotchas
queryMore is the SOAP API concept; in REST the continuation is simply a GET to nextRecordsUrl — do not call a separate queryMore endpoint
Session expiry mid-pagination invalidates the cursor; build retry logic around 401 responses
SOQL LIMIT clauses cap the total rows returned, not the page size; page size is controlled by the Salesforce server (typically up to 2000 rows per batch)
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?