Datablit HTTP API source
Datablit provide HTTP API to ingest events into datablit, evaluate rule and get experiment variant.
Prerequisites
- Datablit console account
- A Datablit project
- A source of type http_api
Events ingestion
Datablit provide segment style batch API to ingest events in Datablit.
Steps
- Copy source api_key from Datablit console > Event > [Select a project]
- Now use following curl to send event. You can translate this to your language eg. go, python, js etc
Sample curl
curl
curl --location 'https://staging-event.datablit.com/v1/batch' \
--header 'apiKey: <your_api_key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"sentAt": "2025-02-24T05:13:03.708Z",
"batch": [
{
"anonymousId": "b67cd1a3-9ad1-4df8-8ceb-cfc7e542b56e",
"messageId": "b5f60cba-7f30-4d41-9901-589601e1e539",
"type": "track",
"userId": "user1",
"context": null,
"originalTimestamp": "2025-10-13T02:24:03.708Z",
"event": "PRODUCT_PREVIEW",
"properties": {
"product_id": "12345"
},
"traits": null
},
{
"anonymousId": "b67cd1a3-9ad1-4df8-8ceb-cfc7e542b56e",
"messageId": "b5f60cba-7f30-4d41-9901-589601e1e539",
"type": "identify",
"userId": "user1",
"traits": {
"email": "user1@gmail.com",
"name": "User1"
},
"context": null,
"originalTimestamp": "2025-09-20T05:13:03.708Z"
}
]
}'Payload details
| Field | Type | Required | Description |
|---|---|---|---|
| anonymousId | string | no | A pseudo-unique substitute for a User ID, for cases when you don’t have an absolutely unique identifier. A userId or an anonymousId is required |
| messageId | string | no | A unique identifier for each message, If client do not pass this datablit server will add uuid |
| type | string | yes | Type of event, it can be identity or track |
| userId | string | no | Unique identifier for the user in your database. A userId or an anonymousId is required |
| context | map<string, any> | no | Dictionary of extra information that provides useful context about a message, but is not directly related to the API call like ip address or locale |
| originalTimestamp | string | yes | Time on the client device when call was invoked OR The timestamp value manually passed in through server-side libraries. |
| event | string | no | Name of the action that a user has performed. |
| properties | map<string, any> | no | Free-form dictionary of properties of the event, like revenue, product_id etc |
| traits | map<string, any> | no | Free-form dictionary of traits of the user, like email or name. |
| sentAt | map<string, any> | no | Time on client device when call was sent. OR sentAt value manually passed in. |
| timestamp | string | no | Calculated by Datablit to correct client-device clock skew using the following formula: receivedAt - (sentAt - originalTimestamp). Here receivedAt is time at which server received this batch |
Note: All timestamps are ISO-8601 date strings, and are in the UTC timezone
Rules API
You can use following API to evaluate a rule.
Steps
- Copy rule key from datablit console > Event > [Select a project] > Rule
- Copy source api_key
- Pass these in following curl.
Sample curl
curl
curl --location 'https://staging-console.datablit.com/api/1.0/rule/eval' \
--header 'apiKey: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
"key" : "disable_cod",
"entityId" : "1",
"params" : {}
}'Payload details
| Field | Type | Required | Description |
|---|---|---|---|
| key | string | yes | Rule key, that you want to execute. Get this from datablit console |
| entityId | string | yes | Entity identifier value for which you want to evalute this rule. This could be user_id, device_id etc. value |
| params | map<string, any> | no | Optional params that you can pass while calling this api. Only needed if you are using this in rule definition |
Experiments API
You can use datablit experiments api to get variant for given entity.
Steps
- Copy experiment id from Datablit console > Event > [Select a project]> Experiment
- Copy source api_key
- Pass these in following curl.
Sample curl
curl
curl --location 'https://staging-console.datablit.com/api/1.0/experiment/variant?expId=01K7T83YWG4XA20565VT1PXD04&entityId=user4' \
--header 'apiKey: <your_api_key>'Query params detail
| Field | Type | Required | Description |
|---|---|---|---|
| expId | string | yes | Experiment identifier, Get this from datablit console |
| entityId | string | yes | Entity identifier value for which you want to get variant. This could be user_id, device_id etc. value |