---
schema_version: "1"
id: 4ab12a7a9fe3145e4c091f1573200e4ce371796f16a98d32056b0c1c815f8e09
title: QueryAll
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/resources/resources-queryall.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/resources-queryall.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: cdd249af2349c5d8a0e49b512159d8138605e76b6aeb530cd2ab1134fb562cea
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# QueryAll

Executes the specified SOQL query. Unlike the Query resource, QueryAll returns records that are soft deleted due to a merge or delete. After these records are permanently removed from the recycle bin, you can no longer query them. QueryAll also returns information about archived task and event records. This resource is available in REST 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. However, to optimize performance, the returned batch can include fewer records than the limit or what's set in the request, based on the size and complexity of records queried. If the total number of results exceeds the limit or the requested number of results, the response contains a batch of results, a `false` value for `done`, and a query locator. The query locator can be used with the [QueryAll More Results](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-queryall-more-results.md) resource to retrieve the next batch of records.

Although the `nextRecordsUrl` has `query` in the URL, it still provides the remaining results from the initial QueryAll request. The remaining results include deleted records that matched the initial query.

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`).

## Syntax

**URI:** `/services/data/vXX.X/queryAll?q=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`.|

## Example

**Example Response Body**

```nolang
{
  "totalSize": 3222,
  "done": false,
  "nextRecordsUrl": "/services/data/v68.0/query/01gRO0000016PIAYA2-500",
  "records": [
    {
      "attributes": {
        "type": "Contact",
        "url": "/services/data/v68.0/sobjects/Contact/003RO0000035WQgYAM"
      },
      "Id": "003RO0000035WQgYAM",
      "Name": "John Smith"
    },
    ...
  ]
}
```

## Resources for Executing SOQL Queries

-   To run a query that includes deleted items, see [Execute a SOQL Query that Includes Deleted Items](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_queryall.htm).
-   To increase the batch size of query results, use the query identifier described in [Execute a SOQL Query](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm) or use the [Query Options Header](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_queryoptions.htm).
-   For more information about SOQL generally, see the [SOQL and SOSL Reference](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_sosl_intro.htm).

