> This page is for Docs.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://zuora.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://zuora.ferndocs.com/_mcp/server.

# Post Query

> Learn how to use the Submit an aggregate query job API operation to submit aggregated ZOQL and Export ZOQL queries, with examples in JSON and cURL.

Learn how to use the Submit an aggregate query job API operation to submit aggregated ZOQL and Export ZOQL queries, with examples in JSON and cURL.

Use the [Submit an aggregate query job](https://www.zuora.com/developer/api-references/api/operation/POST_BatchQueryJob/) API operation to submit an aggregated list of ZOQL and Export ZOQL queries.

The following section provides JSON and cURL examples to use this API operation.

HTTP request:

`POST` `https://rest.zuora.com/v1/batch-query/`

`POST` `https://rest.apisandbox.zuora.com/v1/batch-query/`

* JSON Full Load example

  * JSON request:

    ```json
    {
    "format" : "csv",
    "version" : "1.1",
    "name" : "Example",
    "encrypted" : "none",
    "useQueryLabels" : "true",
    "partner" : "salesforce",
    "project" : "00170000011K3Ub",
    "dateTimeUtc" : "true",
    "queries"  : [ {
        "name" : "AccountingPeriod",
        "query" : "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod",
        "type" : "zoqlexport"
      }]
    }
    ```
  * JSON response (Full load):

    ```json
    {
    "encrypted": "none",
    "partner": "salesforce",
    "useLastCompletedJobQueries": false,
    "project": "00170000011k3ub",
    "batches": [
        { 
            "localizedStatus": "pending",
            "apiVersion": "91.0",
            "full": false,
            "recordCount": 0,
            "batchId": "2c92c0f966cd4f580166ec0ac8a75bb8",
            "batchType": "zoqlexport",
            "status": "pending",
            "name": "AccountingPeriod",
            "query": "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod" 
            }
        ],
    "status": "submitted",
    "name": "Example",
    "id": "2c92c0f966cd4f580166ec0ac89d5bb7",
    "version": "1.1",
    "format": "CSV"
    }
    ```
* JSON Incremental Load example

  * JSON request:

    ```json
    {
    "format" : "csv",
    "version" : "1.1",
    "name" : "Example",
    "encrypted" : "none",
    "useQueryLabels" : "true",
    "partner" : "salesforce",
    "project" : "00170000011K3Ub",
    "dateTimeUtc" : "true",
    "queries"  : [ {
        "name" : "AccountingPeriod",
        "query" : "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod",
        "type" : "zoqlexport"
      }]
    }
    ```
  * JSON response (Incremental load):

    ```json
    {
    "encrypted": "none",
    "partner": "salesforce",
    "useLastCompletedJobQueries": false,
    "project": "00170000011k3ub",
    "batches": [
        {
            "localizedStatus": "pending",
            "apiVersion": "91.0",
            "full": false,
            "recordCount": 0,
            "batchId": "2c92c0f966cd4f580166ec0ac8a75bb8",
            "batchType": "zoqlexport",
            "status": "pending",
            "name": "AccountingPeriod",
            "query": "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod"
            }
        ],
    "status": "submitted",
    "name": "Example",
    "id": "2c92c0f966cd4f580166ec0ac89d5bb7",
    "version": "1.1",
    "format": "CSV"
    }
    ```
* CURL example

  > **Note**
  >
  > When processing a request through a curl shell script, you must enclose the field value in nested single double single quotes, such as Invoice.Status=`'"'Posted'"'`

  * JSON request:

    ```
    USER_NAME="ZUORA_API_USERNAME"
    PASSWORD="PASSWORD"
    BASE_URL="https://www.zuora.com/apps"

    echo 
    echo "============= Posting the Aqua Job ===========" 
    echo 
    curl -i -k -u $USER_NAME:$PASSWORD -H "Content-Type:application/json" -H "Accept:application/json" -d '
    {
    "format" : "csv", 
    "version" : "1.1", 
    "name" : "Example", 
    "encrypted" : "none", 
    "useQueryLabels" : "true",
    "partner" : "salesforce", 
    "project" : "00170000011K3Ub", 
    "dateTimeUtc" : "true",
    "queries" : [ { 
      "name" : "Invoice", 
      "query" : "select Invoice.Amount, Invoice.Balance, Invoice.InvoiceDate, Invoice.InvoiceNumber from Invoice where ( Invoice.Status='"'Posted'"')", 
      "type" : "zoqlexport" 
     }] 
    } 
     ' -X POST $BASE_URL/api/batch-query/  
    ```
  * Curl response:

    ```
    HTTP/1.1 200 OK 
    Content-Type: application/json 
    Date: Fri, 05 Sep 2014 11:27:54 GMT 
    Transfer-Encoding: chunked 
    Connection: Keep-Alive
    {
    "encrypted": "none",
    "partner": "salesforce",
    "useLastCompletedJobQueries": false,
    "project": "00170000011k3ub",
    "batches": [
        {
            "localizedStatus": "pending",
            "apiVersion": "91.0",
            "full": false,
            "recordCount": 0,
            "batchId": "2c92c0f966cd4f580166ec0ac8a75bb8",
            "batchType": "zoqlexport",
            "status": "pending",
            "name": "AccountingPeriod",
            "query": "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod"
            }
        ],
    "status": "submitted",
    "name": "Example",
    "id": "2c92c0f966cd4f580166ec0ac89d5bb7",
    "version": "1.1",
    "format": "CSV"
    }
    ```