PATCH - Update
The App Data API enables you to create, update, delete and list data you associated to your application. App Data lets you create tables of key/value pairs. It is for application centric data as opposed to user centric data. You can use the data in your targeting queries and/or in a message template.
Request structure
Route
The App Data API exposes a PATCH endpoint that lets you add, update or delete keys and their associated values from a table:
https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME
Here is a valid cURL example:
curl -H "Content-Type: application/json" -H "X-Authorization: BATCH_REST_API_KEY" -X PATCH -d "@payload.json" "https://api.batch.com/1.0/BATCH_API_KEY/app-data/TABLE_NAME"
The TABLE_NAME
value must be a string that only contains letters, numbers or the following characters: _
, -
.
The BATCH_API_KEY
value is either your Live, Dev or SDK Batch API key from the settings page of your app within the dashboard (⚙ Settings → General).
Headers
In order to authenticate with the API, you need to provide your company REST API Key as the value of the X-Authorization
header. You can find it in ⚙ Settings → General.
Patch data
The body of the request must contain a valid JSON payload describing the operations to be executed on the App Data table.
Here is a how a complete JSON payload looks like:
{
"overwrite": true,
"values": {
"aKey1": "value to add",
"aKey2": null // value to delete
}
}
Let's see the parameters in detail.
Id | Description | |
---|---|---|
overwrite | boolean - Required Determines whether all the table data should be overwritten | |
values | object - Required A dictionary of key/value. A value must be a string or null. A null value will delete the associated key. Supports up to 10,000 elements. |
NOTE: In overwrite mode, null values are not supported.
Responses
Success
If the POST to the API endpoint is successful you will receive an HTTP 202 confirmation and an empty json payload.
Failure
If the POST data does not meet the API requirements you will receive an actionable error message. Contact us at support@batch.com if you need further support.
AUTHENTICATION_INVALID
(Http status code: 401, Error code: 10)API_MISUSE
(Http status code: 403, Error code: 12)ROUTE_NOT_FOUND
(Http status code: 404, Error code: 20)MISSING_PARAMETER
(Http status code: 400, Error code: 30)MALFORMED_PARAMETER
(Http status code: 400, Error code: 31)MALFORMED_JSON_BODY
(Http status code: 400, Error code: 32)SERVER_ERROR
(Http status code: 500, Error code: 1)MAINTENANCE_ERROR
(Http status code: 503, Error code: 2)
Processing time
While the indexation of application data is usually done in realtime, we offer no guarantees. If you send a campaign right after the app-data creation, you might end up with missing keys.