Newer Version Available
QueryAll
Executes the specified SOQL query. Unlike the Query resource, QueryAll returns records
that are deleted because of a merge or delete. QueryAll also returns information about
archived task and event records. QueryAll is available in API version 29.0 and
later.
When a QueryAll request is executed, up to 2,000 records can be returned at a time in a synchronous request. If the number of results exceeds this limit, the response contains the first set of 2,000 results, a false value for done, and a query locator. The query locator can be used with the QueryAll More Results resource to retrieve the next batch of records.
Although the nextRecordsUrl has query in the URL, it still provides remaining results from the initial QueryAll request. The remaining results include deleted records that matched the initial query.
- URI
- /services/data/vXX.X/queryAll?q=SOQL_query
- Formats
- JSON, XML
- HTTP Method
- GET
- Authentication
- Authorization: Bearer token
- Parameters
-
Parameter Description q A SOQL query. To create a valid URI, replace spaces with a plus sign + in the query string. For example: SELECT+Name+FROM+MyObject. - Response body
- The response contains the total number of records returned by the QueryAll request (totalSize), a boolean indicating whether there are no more results (done), the URI of the next set of records (nextRecordsUrl), and an array of query result records (records).
- Example response body
-
1{ 2 "totalSize": 3222, 3 "done": false, 4 "nextRecordsUrl": "/services/data/v56.0/query/01gRO0000016PIAYA2-500", 5 "records": [ 6 { 7 "attributes": { 8 "type": "Contact", 9 "url": "/services/data/v56.0/sobjects/Contact/003RO0000035WQgYAM" 10 }, 11 "Id": "003RO0000035WQgYAM", 12 "Name": "John Smith" 13 }, 14 ... 15 ] 16}
Resources for Executing SOQL Queries
- To run a query that includes deleted items, see Execute a SOQL Query that Includes Deleted Items.
- To retrieve more query results beyond the initial returned results, see Retrieving the Remaining SOQL Query Results in Execute a SOQL Query that Includes Deleted Items.
- To increase the batch size of query results, use the query identifier, described in Execute a SOQL Query or use the Query Options Header.
- For more information about SOQL generally, see the SOQL and SOSL Reference.