Postback API Quickstart

info

An improved option is available using the Data Ingestion API. Learn more about Importing Table Records Using the Data Ingestion API.

The Postback API allows you to create custom webhooks within your applications to upload your data into Treasure Data. Treasure Data’s Postback API provides another option to import data into Treasure Data, when other methods aren’t viable.

Common use cases for Postback API might be a security limitation of an external system or inability to install a binary file.

For instance, if you want to import single records into Treasure Data where the import is triggered by an external application, Postback API allows you to include webhooks in your applications that will insert a record into a Treasure Data database when you can’t install a jar file such as TD Logger to send data into TD.

Another example could be a web based application or environment where the TD JavaScript SDK is not an option.

Setup

Instructions

Sending a Request

To send data via the postback API is very simple. Add your TD API key as a header, put the database and table in the URL, and include your data in the post request body.

It is recommended that you send your data as a JSON payload.

Parameter Description
database Specify destination database name in URL. Only alphabets/numbers or _ are allowed.
table Specify destination table name in URL. Only alphabets/numbers or _ are allowed.

Sample Request

Copy
Copied
curl -i -X POST 'https://in.treasuredata.com/postback/v3/event/db_test/table_1' -H 'Content-Type: application/json' -H 'X-TD-Write-Key: 123/abcdef•••••••••••••••••••••••0123456789' -d '{"email":"firstname.lastname@business.com","telephone":"555-555-5540"}'

HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 15 Jun 2023 00:23:32 GMT
Strict-Transport-Security: max-age=31536000
Content-Length: 2
Connection: keep-alive

{}%

Further Reading