---
schema_version: "1"
id: 6ad9d8c596121a0b835b0c7bf01ece204e66f5fb723523aa424d6114e42abef3
title: "Step 6: Query Jobs"
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-walkthrough.md
canonical_url: https://developer.salesforce.com/docs/platform/api-asynch/guide/query-walkthrough.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 623488cf9c3d7b022cafe32540637fd62149ee943185eb6c79fe9c6534743096
products:
  - Bulk API 2.0 and Bulk API Developer Guide
  - Platform Developer Content
---

# Step 6: Query Jobs

This Bulk API 2.0 example shows you how to create a query job, monitor its progress, and get the job results.

1.  Create the job.

    **URI**

    ```nolang
    /services/data/v68.0/jobs/query
    ```

    **Example of creating a bulk query job**

    ```nolang
    curl https://MyDomainName.my.salesforce.com/services/data/v68.0/jobs/query -H 'Content-Type: application/json' -H 'Authorization: Bearer 00DE0X0A0M0PeLE!AQcAQH0dMHEXAMPLEzmpkb58urFRkgeBGsxL_QJWwYMfAbUeeG7c1EXAMPLEDUkWe6H34r1AAwOR8B8fLEz6nEXAMPLE' -H "X-PrettyPrint:1" --data-raw '{ "operation" : "query", "query" : "SELECT Id, Name FROM Account" } ' -X POST
    ```

    The response includes the job `id` and shows the job’s state as `UploadComplete`. (You use the job `id` to monitor the job or get its results.)

    **Example response body**

    ```nolang
    {
      "id" : "7986gEXAMPLE4X2OPT",
      "operation" : "query",
      "object" : "Account",
      "createdById" : "0055fEXAMPLEtG4AAM",
      "createdDate" : "2022-01-02T17:38:59.000+0000",
      "systemModstamp" : "T17:38:59.000+0000",
      "state" : "UploadComplete",
      "concurrencyMode" : "Parallel",
      "contentType" : "CSV",
      "apiVersion" : 68.0,
      "lineEnding" : "LF",
      "columnDelimiter" : "COMMA"
    }
    
    ```

2.  Monitor the job’s state using the returned job `id`.

    **URI**

    ```nolang
    /services/data/v68.0/jobs/query/queryJobId
    ```

    **Example of monitoring the state of the query job**

    ```nolang
    curl https://MyDomainName.my.salesforce.com/services/data/v68.0/jobs/query/7986gEXAMPLE4X2OPT -H 'Authorization: Bearer 00DE0X0A0M0PeLE!AQcAQH0dMHEXAMPLEzmpkb58urFRkgeBGsxL_QJWwYMfAbUeeG7c1EXAMPLEDUkWe6H34r1AAwOR8B8fLEz6nEXAMPLE' -H "X-PrettyPrint:1" -X GET
    ```

    **Example response body**

    The response shows the current state of the job. Repeat this step until the state is `JobComplete`.

    ```nolang
    {
      "id" : "7986gEXAMPLE4X2OPT",
      "operation" : "query",
      "object" : "Account",
      "createdById" : "0055fEXAMPLEtG4AAM",
      "createdDate" : "2022-01-02T17:38:59.000+0000",
      "systemModstamp" : "T17:39:00.000+0000",
      "state" : "JobComplete",
      "concurrencyMode" : "Parallel",
      "contentType" : "CSV",
      "apiVersion" : 68.0,
      "jobType" : "V2Query",
      "lineEnding" : "LF",
      "columnDelimiter" : "COMMA",
      "numberRecordsProcessed" : 28,
      "retries" : 0,
      "totalProcessingTime" : 153,
      "isPkChunkingSupported": true
    }
    
    ```

3.  Get the results of the job.

    **URI**

    ```nolang
    /services/data/v68.0/jobs/query/queryJobId/results
    ```

    **Example of getting the results of the job**

    ```nolang
    curl https://MyDomainName.my.salesforce.com/services/data/v68.0/jobs/query/7986gEXAMPLE4X2OPT/results/ -H 'Authorization: Bearer 00DE0X0A0M0PeLE!AQcAQH0dMHEXAMPLEzmpkb58urFRkgeBGsxL_QJWwYMfAbUeeG7c1EXAMPLEDUkWe6H34r1AAwOR8B8fLEz6nEXAMPLE' -H "Content-Type: application/json; charset=UTF-8" -H "Accept: text/csv" -H "X-PrettyPrint:1" -X GET
    ```

    The response shows the results of the SOQL query when you created the query job.

    **Example response body**

    ```nolang
    "Id","Name"
    "0015f00000BCvReAAL","Sample Account for Entitlements"
    "0015f00000BFjNuAAL","University of The Terrific"
    "0015f00000C6beUAAR","Edge Communications"
    "0015f00000C6beVAAR","Burlington Textiles Corp of America"
    "0015f00000C6beWAAR","Pyramid Construction Inc."
    "0015f00000C6beXAAR","Dickenson plc"
    "0015f00000C6beYAAR","Grand Hotels & Resorts Ltd"
    "0015f00000C6beZAAR","United Oil & Gas Corp."
    "0015f00000C6beaAAB","Express Logistics and Transport"
    "0015f00000C6bebAAB","University of Arizona"
    "0015f00000C6becAAB","United Oil & Gas, UK"
    "0015f00000C6bedAAB","United Oil & Gas, Singapore"
    "0015f00000C6beeAAB","GenePoint"
    ```

    This example returns a small result set, and it’s easy to see the complete results. Queries that return larger results spread them across a sequence of result sets. To see the other result sets, use the locator to fetch the next set of results. For more information, see [Get Results for a Query Job](https://developer.salesforce.com/docs/platform/api-asynch/guide/query-get-job-results.md).


