Knowledge Center

Knowledge Center > API > Aggregate Query API (AQuA) > Post Query > Export Deleted Data

Export Deleted Data

You can export deleted records using AQuA API. This REST API submits a request to export deleted records. An additional column is added to the export, containing the deleted state of the record in each row.

Export Deleted Data

AQuA API supports the exporting of deleted data in Stateful mode, version 1.1. Not all API objects support exporting deleted records. The following API objects do not support the exporting of deleted records:

  • PaymentTransactionLog
  • RefundTransactionLog
  • RevenueScheduleItemInvoiceItemAdjustment
  • AccountingCode
Limited Support

The following has limited support:

RatePlan datasource: This datasource does not support deleted columns if the query references columns from other joined datasources.  The following correct select statement will return deleted Rate Plans:

Correct: select Id , Name from RatePlan

Incorrect: select Id , Name Product.ID from RatePlan

Request

Environment Request
API Sandbox (US Data Center) POST https://apisandbox.zuora.com/apps/api/batch-query/
Production (US Data Center) POST https://www.zuora.com/apps/api/batch-query/
API Sandbox (EU Data Center) POST https://rest.sandbox.eu.zuora.com/v1/batch-query/
Production (EU Data Center) POST https://rest.eu.zuora.com/v1/batch-query/

Request Parameters

format

The supported values are csv, zip and gzip. The default value is csv.

version

The API version you want to use. Supported versions:

  • 1.2 Supports both modes
  • 1.1 Supports both modes
  • 1.0 Default. Supports Stateless mode only

See Stateless and Stateful Modes for more information.

Must be set to version 1.1 to export deleted data.

name

The name of the job. 32 character limit.

encrypted

If enabled, you must supply the formatting (zip or unzip) first and decrypt it to get the actual contents.
Supported values are: pgp and none. 

partner

Required to export deleted data.

The partner field indicates the unique ID of a data integration partner.

It must be used together with "project" field to uniquely identify a data integration target.  

For example, if a continuous AQuA session is to retrieve data incrementally for a

Salesforce.com Org 00170000011K3Ub, you can use partner as "Salesforce", and "project" as "00170000011K3Ub." 

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

Submit a request at Zuora Global Support to obtain a partner ID.

project

Required to export deleted data.

The project field contains the unique ID of a data integration project for a particular partner.  This field  must be used together with partner field to uniquely identify a data integration target.

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

queries

A JSON Array object that contains a list of query objects. The list of query objects are name and query.

name

The name of the job. 32 character limit.

query

A ZOQL query or Export ZOQL query. Values can be zoql or zoqlexport.

test

type

The job execution type. The value is always "query."

apiVersion

The API version for the query. If an API version is not specified, the latest version is used by default. Using the latest WSDL version is most useful for reporting use cases. For integration purposes, specify the WSDL version to ensure consistent query behavior, i.e., what is supported and included in the response returned by the API.

As of API version 69 and later, Zuora changed the format of certain fields. See Date Field Changes in the SOAP API for more information and a list of affected fields.

deleted

Required to export deleted data.

This indicates that the AQuA incremental load will retrieve deleted records.

column

Name of the Column in the extracted file that points to the deleted records. 

format

Can be set to either “Numeric” or “Boolean.” If set to Numeric, deleted records are marked as 1. If set to Boolean, deleted records are marked as “true.”

Response Parameters

batches

A JSON array object that contains a list of batch objects.

deleted

This indicates that the AQuA incremental load will retrieve deleted records.

column

Name of the Column in the extracted file that points to the deleted records. 

format

Can be set to either “Numeric” or “Boolean.” If set to Numeric, deleted records are marked as 1. If set to Boolean, deleted records are marked as “true.”

full

Indicates a full or ncremental load. True = Full and False = Incremental.

name

The name of the job. 32 character limit.

query

A ZOQL query or Export ZOQL query. Values can be zoql or zoqlexport.

status

The job status. Status types are:

  • Submitted: The job was successfully submitted upon successful validation of the JSON request.
  • Executing: The job is being processed.
  • Completed: The query was executed successfully. Click completed to download a gzip archive of the results.
  • Error: There are some validation errors in the JSON input, and the job ID will not be available.
  • Aborted: The execution stopped because one of the queries failed. Check the error code and error messages for more details.
  • Pending: The job is extracting data from the database.

recordCount

The actual number of records retrieved.

apiVersion

The API version for the query. If an API version is not specified, the latest version is used by default. Using the latest WSDL version is most useful for reporting use cases. For integration purposes, specify the WSDL version to ensure consistent query behavior, i.e., what is supported and included in the response returned by the API.

As of API version 69 and later, Zuora changed the format of certain fields. See Date Field Changes in the SOAP API for more information and a list of affected fields.

batchType

The kind of batch job being submitted. Possible values are zoql or zoqlexport.

batchId

A 32-character ID of the query batch.

project

The project field contains the unique ID of a data integration project for a particular partner.  This field  must be used together with partner field to uniquely identify a data integration target.

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

partner

The partner field indicates the unique ID of a data integration partner.

It must be used together with "project" field to uniquely identify a data integration target.  

For example, if a continuous AQuA session is to retrieve data incrementally for a

Salesforce.com Org 00170000011K3Ub, you can use partner as "Salesforce", and "project" as "00170000011K3Ub." 

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

Submit a request at Zuora Global Support to obtain a partner ID.

name

The name of the job. 32 character limit.

id

The job ID created for the AQuA API request. The job ID can be used for querying for the query status.
The ID exists only if the JSON request can be parsed and validated successfully. Otherwise, the job ID is null.

version

The API version you want to use. Supported versions:

  • 1.2 Supports both modes
  • 1.1 Supports both modes
  • 1.0 Default. Supports Stateless mode only

See Stateless and Stateful Modes for more information.

format

The supported values are csv, zip and gzip. The default value is csv.

startTime

The start time of the query. 

status

The job status. Status types are:

  • Submitted: The job was successfully submitted upon successful validation of the JSON request.
  • Executing: The job is being processed.
  • Completed: The query was executed successfully. Click completed to download a gzip archive of the results.
  • Error: There are some validation errors in the JSON input, and the job ID will not be available.
  • Aborted: The execution stopped because one of the queries failed. Check the error code and error messages for more details.
  • Pending: The job is extracting data from the database.

encrypted

If enabled, you must supply the formatting (zip or unzip) first and decrypt it to get the actual contents.
Supported values are: pgp and none. 

JSON Example

Example 1

This example shows how deleted records are not extracted for a full load, making the MyDeleted column = 0 or False for all the records.

  1. Submit a full load JSON request with the deleted column as numeric.

HTTP request:

POST https://www.zuora/apps/api/batch-query/

POST https://apisandbox.zuora.com/apps/api/batch-query/

Download File:

Account.MyDeleted,Account: ID,Account: Name,Account: Account Balance,Account: Tax Exempt Status,
Account: Auto Pay,Account: Currency,Bill To: ID,Sold To: ID 
0,40288187485e400101485e426c6f0d2c,name1410330684509,77.86,,false,USD,40288187485e400101485e426c760d2d,40288187485e400101485e426c7c0d2e 
0,40288187485e400101485e426f770da8,name1410330685288,77.86,,false,USD,40288187485e400101485e426f7e0da9,
40288187485e400101485e426f840daa 
0,40288187485e400101485e4271fd0e08,name1410330685934,77.86,,false,USD,
40288187485e400101485e4272040e09,40288187485e400101485e42720a0e0a 
0,40288187485e400101485e42748e0e68,
name1410330686592,77.86,,false,USD,40288187485e400101485e4274990e69,40288187485e400101485e4274a00e6a 
0,40288187485e400101485e42772d0ec8,name1410330687262,77.86,,false,USD,40288187485e400101485e4277350ec9,
40288187485e400101485e42773b0eca 
0,40288187485e400101485e4279bb0f28,name1410330687915,77.86,,false,USD,
40288187485e400101485e4279c20f29,40288187485e400101485e4279c90f2a 
0,40288187485e400101485e427c4e0f88,name1410330688575,77.86,,false,USD,40288187485e400101485e427c550f89,40288187485e400101485e427c5b0f8a 
0,40288187485e400101485e427ed60fe8,name1410330689222,77.86,,false,USD,40288187485e400101485e427edc0fe9,
40288187485e400101485e427ee20fea 
0,40288187485e400101485e4281821048,name1410330689905,77.86,,false,USD,
40288187485e400101485e42818d1049,40288187485e400101485e428193104a 
0,40288187485e400101485e42841e10a8,name1410330690570,77.86,,false,USD,40288187485e400101485e42842610a9,40288187485e400101485e42842c10aa 
0,40288187485e400101485e42bfc81108,name1410330705849,0,,false,USD,40288187485e400101485e42bfcf1109,
40288187485e400101485e42bfd5110a

Example 2

This example show how to delete an existing account and create a new account before an incremental load. This results in two records. The deleted account record has the deleted flag = 1 or True, and the newly created account record has the deleted flag = 0.

1. Submit an incremental JSON request.

HTTP request:

POST https://www.zuora/apps/api/batch-query/

POST https://apisandbox.zuora.com/apps/api/batch-query/

JSON request:

{
    "format": "csv",
    "version": "1.1",
    "name": "Example",
    "encrypted": "none",
    "partner": "salesforce",
    "project": "00170000011K3Ub",
    "queries": [
        {
            "name": "Account",
            "query": "select Id,Name,Balance,TaxExemptStatus,AutoPay,Currency, BillToContact.Id, SoldToContact.Id  from  Account",
            "type": "zoqlexport",
            "apiVersion": "20.0",
            "deleted": {
                "column": "MyDeleted",
                "format": "Numeric"
            }
        }
    ]
}

JSON response:

{
    "batches": [
        {
            "deleted": {
                "column": "MyDeleted",
                "format": "Numeric"
            },
            "full": false,
            "name": "Account",
            "query": "select Id,Name,Balance,TaxExemptStatus,AutoPay,Currency, BillToContact.Id, SoldToContact.Id  from  Account",
            "status": "pending",
            "recordCount": 0,
            "apiVersion": "20.0",
            "batchType": "zoqlexport",
            "batchId": "4028818748597d2f01485fbe4d8d05db"
        }
    ],
    "project": "00170000011K3Ub",
    "partner": "salesforce",
    "name": "Example",
    "id": "4028818748597d2f01485fbe4d8805da",
    "version": "1.1",
    "format": "CSV",
    "status": "submitted",
    "encrypted": "none"
}
  1. Get the job details

HTTP request:

GET https://www.zuora.com/apps/api/batch-query/jobs/4028818748597d2f01485fbe4d8805da

GET https://apisandbox.zuora.com/apps/api/batch-query/jobs/4028818748597d2f01485fbe4d8805da

JSON response:

{
    "batches": [
        {
            "deleted": {
                "column": "MyDeleted",
                "format": "Numeric"
            },
            "full": false,
            "name": "Account",
            "message": "",
            "query": "select Id,Name,Balance,TaxExemptStatus,AutoPay,Currency, BillToContact.Id, SoldToContact.Id  from  Account",
            "status": "completed",
            "recordCount": 2,
            "apiVersion": "20.0",
            "fileId": "4028818748597d2f01485fbe4e1105dd",
            "batchType": "zoqlexport",
            "batchId": "4028818748597d2f01485fbe4d8d05db"
        }
    ],
    "project": "00170000011K3Ub",
    "partner": "salesforce",
    "name": "Example",
    "id": "4028818748597d2f01485fbe4d8805da",
    "version": "1.1",
    "format": "CSV",
    "startTime": "2014-09-10 06:26:20",
    "status": "completed",
    "encrypted": "none"
  1. Retrieve the download file.

HTTP request:

GET https://www.zuora.com/apps/api/file/4028818748597d2f01485fbe4e1105dd

GET https://apisandbox.zuora.com/apps/api/file/4028818748597d2f01485fbe4e1105dd

Download file:

Account.MyDeleted,Account: ID,Account: Name,Account: Account Balance,Account: Tax Exempt Status,
Account: Auto Pay,Account: Currency,Bill To: ID,Sold To: ID 
0,4028818748597d2f01485fbe171805d4,testIncremenatlLoad,0,No,false,USD,4028818748597d2f01485fbe172a05d5,
4028818748597d2f01485fbe172a05d5 
1,40288187485e400101485e42841e10a8,name1410330690570,77.86,,false,USD,,
Last modified
19:01, 2 Aug 2017

Tags

Classifications

(not set)