---
schema_version: "1"
id: e1fed5c6527d2490a66e2d25b8662d419b8828c3d7372ac99e8a3b14bda41e14
title: Abort a Query Job
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-asynch/guides/api-bulk-v2/bulk-query/query-abort-job.md
canonical_url: https://developer.salesforce.com/docs/platform/api-asynch/guide/query-abort-job.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 354f4003632e5289131c58190a95f4ca85e0c4188b70115ffe10c354d3e65874
products:
  - Bulk API 2.0 and Bulk API Developer Guide
  - Platform Developer Content
---

# Abort a Query Job

Aborts a query job.

**note:** - To abort a job, you must be the job’s creator or have the Manage Data Integrations permission.
- You can only abort jobs that are in the following states:

  - `UploadComplete`
  - `InProgress`

## Syntax

**URI:** `/services/data/vXX.X/jobs/query/queryJobId`

**Available since release:**

This resource is available in API version 47.0 and later.

**Formats:** JSON

**HTTP methods:** PATCH

**Authentication:** Authorization: Bearer token

**Request body**

The request body must be the following:

```nolang
{
  "state": "Aborted"
}
```

**Request parameters:**

| Parameter    | Description                            | Required or Optional |
| ------------ | -------------------------------------- | -------------------- |
| `queryJobId` | The ID of the query job to be deleted. | Required             |

**Response Body**

If the request is successful, the status code is 200 (OK). The response body has the state `Aborted`. For example:

```nolang
{
   "id" : "750R000000146UvIAI",
   "operation" : "query",
   "object" : "Account",
   "createdById" : "005R0000000GiwjIAC",
   "createdDate" : "2018-12-18T16:15:31.000+0000",
   "systemModstamp" : "2018-12-18T16:15:32.000+0000",
   "state" : "Aborted",
   "concurrencyMode" : "Parallel",
   "contentType" : "CSV",
   "apiVersion" : 46.0
}
```

**Response Parameters:**

| Parameter         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id`              | The unique ID for this job.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `operation`       | The type of query. Possible values are:<ul><li>`query`—Returns data that hasn’t been deleted or archived. For more information, see [query()](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_query.htm) in _SOAP API Developer Guide_.</li><li>`queryAll`—Returns records that have been deleted because of a merge or delete, and returns information about archived Task and Event records. For more information, see [queryAll()](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_queryall.htm) in _SOAP API Developer Guide_.</li></ul> |
| `object`          | The object type being queried.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `createdById`     | The ID of the user who created the job.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `createdDate`     | The UTC date and time when the job was created.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `systemModstamp`  | The UTC date and time when the API last updated the job information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `state`           | The current state of processing for the job. Possible values are: <ul><li>`UploadComplete`—The job is ready to be processed and Salesforce has put the job in the queue.</li><li>`InProgress`—Salesforce is processing the job.</li><li>`Aborted`—The job has been aborted. See [Abort a Query Job](https://developer.salesforce.com/docs/platform/api-asynch/guide/query-abort-job.md).</li><li>`JobComplete`—Salesforce has finished processing the job.</li><li>`Failed`—The job failed.</li></ul>                                                                                                                                                                        |
| `concurrencyMode` | Reserved for future use. How the request is processed. Currently only parallel mode is supported. (When other modes are added, the API chooses the mode automatically. The mode isn’t user configurable.)                                                                                                                                                                                                                                                                                                                                                                                                    |
| `contentType`     | The format that is used for the results. Currently the only supported value is `CSV`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `apiVersion`      | The API version that the job was created in.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

**Response Body - For an Unsuccessful Request**

If the request fails, the server returns a non-200 status, and the request body shows details of the error. For example:

```nolang
HTTP/1.1 400 Bad Request
[{
	"errorCode": "INVALIDJOBSTATE",
	"message": "Aborting already Completed Job not allowed"
}]
```

## Example

This example aborts the job with ID `750R000000146UvIAI`:

```nolang
curl  --request PATCH \
--header "Authorization: Bearer token" \
--header "Content-Type: application/json" \
--data '{
  "state": "Aborted"
}' \
https://instance.salesforce.com/services/data/vXX.X/jobs/query/750R000000146UvIAI
```

The response is:

```nolang
{
  "id": "750R000000146UvIAI",
  "operation": "query",
  "object": "Account",
  "createdById": "005R0000000GiwjIAC",
  "createdDate": "2018-12-18T20:51:39.000+0000",
  "systemModstamp": "2018-12-18T20:51:41.000+0000",
  "state": "Aborted",
  "concurrencyMode": "Parallel",
  "contentType": "CSV",
  "apiVersion": 46.0
}
```
