Export Deleted Data
This article describes how to export deleted data in stateful mode. To export deleted data in stateless mode, see Extract deleted data in each query.
Zuora highly recommends you use the stateless mode instead of the stateful mode to extract bulk data. See Bulk data extraction from Zuora using AQuA for best practices.
Starting with version 1.1, the AQuA API supports the exporting of deleted records in Stateful mode.
In Stateful mode, the first request executes queries against all data in the database and returns all data that satisfies the query criteria. Deleted records are not included in the export.
Subsequent requests execute the queries against incremental data created or updated since the previous AQuA session. Subsequent requests can also execute the queries against data that has been deleted since the previous AQuA session. To include deleted records in an export, set the deleted
field in the request body when making the request.
When you export data that includes deleted records, the export has an additional column that indicates whether each record is a deleted record. You can specify the name and format of this additional column.
Limitations
- The following API objects do not support the exporting of deleted records:
- PaymentTransactionLog
- RefundTransactionLog
- AccountingCode
- AccountingPeriod
- Processed Usage
- You cannot extract the records that were both created and deleted during the same interval between two consecutive incremental AQuA queries.
Request
Environment | Request |
---|---|
Production for US Cloud Data Center 2 |
POST https://rest.zuora.com/v1/batch-query/ |
API Sandbox for US Cloud Data Center 2 | POST https://rest.apisandbox.zuora.com/v1/batch-query/ |
US Performance Test | POST https://rest.pt1.zuora.com/v1/batch-query/ |
Production for US Cloud Data Center 1 | POST https://rest.na.zuora.com/v1/batch-query/ |
API Sandbox for US Cloud Data Center 1 | POST https://rest.sandbox.na.zuora.com/v1/batch-query/ |
Central Sandbox for US Cloud Data Center | POST https://rest.test.zuora.com/v1/batch-query/ |
Production for EU Cloud Data Center | POST https://rest.eu.zuora.com/v1/batch-query/ |
Sandbox for EU Cloud Data Center | POST https://rest.sandbox.eu.zuora.com/v1/batch-query/ |
Central Sandbox for EU Cloud Data Center | POST https://rest.test.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:
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. |
|||||||||||||||
partner |
Required to export deleted data. The partner field indicates the unique ID of a data integration partner. The dropdown list of this field displays partner IDs for the past thirty days. 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. Zuora highly recommends you use the stateless mode instead of the stateful mode to extract bulk data. See Bulk data extraction from Zuora using AQuA for best practices. 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. The dropdown list of this field displays project IDs for the past thirty days. 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.
|
Response Parameters
batches |
A JSON array object that contains a list of batch objects.
|
|||||||||||||||||||||||
project |
The project field contains the unique ID of a data integration project for a particular partner. The dropdown list of this field displays project IDs for the past thirty days. 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. The dropdown list of this field displays partner IDs for the past thirty days. 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. Zuora highly recommends you use the stateless mode instead of the stateful mode to extract bulk data. See Bulk data extraction from Zuora using AQuA for best practices. 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. |
|||||||||||||||||||||||
version |
The API version you want to use. Supported versions:
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:
|
|||||||||||||||||||||||
encrypted |
If enabled, you must supply the formatting (zip or unzip) first and decrypt it to get the actual contents. |
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.
- Submit a full load JSON request with the deleted column as numeric.
HTTP request:
POST https://rest.zuora.com/v1/batch-query/
POST https://apisandbox.zuora.com/v1/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/v1/batch-query/
POST https://apisandbox.zuora.com/v1/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" }
- Get the job details
HTTP request:
GET https://www.zuora.com/v1/batch-query/jobs/4028818748597d2f01485fbe4d8805da
GET https://apisandbox.zuora.com/v1/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"
- Retrieve the download file.
HTTP request:
GET https://www.zuora.com/v1/file/4028818748597d2f01485fbe4e1105dd
GET https://apisandbox.zuora.com/v1/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,,