Datablit HTTP API source

Datablit provide HTTP API to ingest events into datablit, evaluate rule and get experiment variant.

Prerequisites

  1. Datablit console account
  2. A Datablit project
  3. A source of type http_api

Events ingestion

Datablit provide segment style batch API to ingest events in Datablit.

Steps

  1. Copy source api_key from Datablit console > Event > [Select a project]
  2. 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

FieldTypeRequiredDescription
anonymousIdstringnoA 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
messageIdstringnoA unique identifier for each message, If client do not pass this datablit server will add uuid
typestringyesType of event, it can be identity or track
userIdstringnoUnique identifier for the user in your database. A userId or an anonymousId is required
contextmap<string, any>noDictionary of extra information that provides useful context about a message, but is not directly related to the API call like ip address or locale
originalTimestampstringyesTime on the client device when call was invoked OR The timestamp value manually passed in through server-side libraries.
eventstringnoName of the action that a user has performed.
propertiesmap<string, any>noFree-form dictionary of properties of the event, like revenue, product_id etc
traitsmap<string, any>noFree-form dictionary of traits of the user, like email or name.
sentAtmap<string, any>noTime on client device when call was sent. OR sentAt value manually passed in.
timestampstringnoCalculated 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

  1. Copy rule key from datablit console > Event > [Select a project] > Rule
  2. Copy source api_key
  3. 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

FieldTypeRequiredDescription
keystringyesRule key, that you want to execute. Get this from datablit console
entityIdstringyesEntity identifier value for which you want to evalute this rule. This could be user_id, device_id etc. value
paramsmap<string, any>noOptional 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

  1. Copy experiment id from Datablit console > Event > [Select a project]> Experiment
  2. Copy source api_key
  3. 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

FieldTypeRequiredDescription
expIdstringyesExperiment identifier, Get this from datablit console
entityIdstringyesEntity identifier value for which you want to get variant. This could be user_id, device_id etc. value