RudderStack HTTP API Specification

Detailed technical description of the HTTP Tracking API for recording your event data from any website or application.

The RudderStack HTTP API allows you to track your customer event data from anywhere, and route it to your desired destinations. We recommend using our SDKs for automatic tagging of the identify context, batching the events and retrying functionality. If you cannot use our SDKs, it is possible to send your event data using the HTTP API.

RudderStack HTTP API is compatible with Segment.

RudderStack Data Plane

To send HTTP requests, you should have a RudderStack server configured with your workspace token. Please refer to this section for setting up and running RudderStack. The RudderStack's HTTP server should be accessible from your HTTP client.

Postman Collection

Import the Postman collection and edit the variables source_write_key and data_plane_urlwith your write key and RudderStack data plane URL. Now you can test all supported requests. https://www.getpostman.com/collections/809e6340fd8002a89229

HTTP Authorization

RudderStack uses Basic Authentication for authenticating all HTTP requests. HTTP Basic Authentication requires user name and password.

writeKeyis the user name

"" is the password (empty string)

All popular HTTP clients (eg. curl, Postman, HTTPie) have default support for Basic auth. If yourwriteKey is 1Xk5DChfJAol3xtW7qNnK1apo5p, your HTTP request must have the following HTTP header Authorization: Basic MVhrNURDaGZKQW9sM3h0VzdxTm5LMWFwbzVwOg==

This is a sample basic auth header generator to verify your header.

In order to send the event data to our RudderStack HTTP API, the content-type header must be set to application/json

HTTP Responses

  • Server returns a 200 response for successful API requests.

  • Server returns a 400 response for invalid requests with appropriate error message in the response. Some possible invalid requests include Request size too large Invalid JSON Missing Authorization header Invalid Authorization header

Maximum Allowed Request Size

RudderStack allows a maximum of 32KB message size per call, while the batch endpoint accepts a maximum call size of 500KB per batch, and 32KB per call. If these limits are exceeded, RudderStack responds with a 400 Bad Request.

Identify

The identify call allows you to associate a visiting user to their actions. It also lets you record the traits associated with them.

It is recommended that you call identifyonce during the user's account creation. You can call the method again later when the traits related to that user are changed.

Payload

identify.json
{
"userId": "user123",
"traits": {
"email": "name@domain.com",
"name": "FirstName LastName",
"industry": "Industry"
},
"context": {
"ip": "17.25.1.25"
},
"timestamp": "2020-02-02T00:14:34.358Z"
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/identify -d @identify.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/identify < identify.json

Accepted Fields

Field

Type

Presence

Description

anonymousId

String

Optional

Sets the user ID for cases where there is no unique identifier for the user. Either userId or anonymousId is required.

userId

String

Optional, if anonymousId is already set

Unique identifier for a particular user in your database.

context

Object

Optional

Dictionary of information that provides context about a message. However, it is not directly related to the API call.

integrations

Object

Optional

Dictionary containing the destinations to be either enabled or disabled.

timestamp

Date

Optional

Timestamp of the message's arrival.

traits

Object

Optional

Dictionary of the traits associated with the user, such as nameor email

For more details, please refer to the payload related to the identify call in our spec.

Track

The track call allows you to record the customer events, i.e. the actions that they perform, along with their associated properties.

Payload

track.json
{
"userId": "user123",
"event": "Product Purchased",
"properties": {
"name": "Rubik's Cube",
"revenue": 4.99
},
"context": {
"ip": "14.5.67.21"
},
"timestamp": "2020-02-02T00:23:09.544Z"
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/track -d @track.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/track < track.json

Accepted fields

Field

Type

Presence

Description

anonymousId

String

Optional

Sets the user ID for cases where there is no unique identifier for the user. Either userId or anonymousId is required.

userId

String

Optional, if anonymousId is already set

Unique identifier for a particular user in your database.

context

Object

Optional

Dictionary of information that provides context about a message. However, it is not directly related to the API call.

event

String

Required

Name of the event being performed by the user

properties

Object

Optional

Dictionary of the properties associated with a particular event.

integrations

Object

Optional

Dictionary containing the destinations to be either enabled or disabled.

timestamp

Date

Optional

Timestamp of the message's arrival.

For more details, please refer to the payload related to the track call in our spec.

Page

The page call allows you to record your website's page views, with the additional relevant information about the page being viewed.

Payload

page.json
{
"userId": "user123",
"name": "Track HTTP API",
"timestamp": "2020-02-05T00:22:43.218Z"
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/page -d @page.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/page < page.json

Accepted Fields

Field

Type

Presence

Description

anonymousId

String

Optional

Sets the user ID for cases where there is no unique identifier for the user. Either userId or anonymousId is required.

userId

String

Optional, if anonymousId is already set

Unique identifier for a particular user in your database.

context

Object

Optional

Dictionary of information that provides context about a message. However, it is not directly related to the API call.

integrations

Object

Optional

Dictionary containing the destinations to be either enabled or disabled.

name

String

Required

Name of the page being viewed.

properties

Object

Optional

Dictionary of the properties associated with the page being viewed, such as url and referrer

timestamp

Date

Optional

Timestamp of the message's arrival.

For more details, please refer to the payload related to the page call in our spec.

Screen

The screen call allows you to record whenever a mobile app user sees the screen of their mobile device.

Payload

screen.json
{
"userId": "user123",
"name": "Track HTTP API",
"timestamp": "2020-02-04T00:24:29.248Z"
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/screen -d @screen.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/screen < screen.json

Accepted Fields

Field

Type

Presence

Description

anonymousId

String

Optional

Sets the user ID for cases where there is no unique identifier for the user. Either userId or anonymousId is required.

userId

String

Optional, if anonymousId is already set

Unique identifier for a particular user in your database.

context

Object

Optional

Dictionary of information that provides context about a message. However, it is not directly related to the API call.

integrations

Object

Optional

Dictionary containing the destinations to be either enabled or disabled.

name

String

Required

Name of the screen being viewed.

properties

Object

Optional

Dictionary of the properties associated with the page being viewed, such as url and referrer

timestamp

Date

Optional

Timestamp of the message's arrival.

For more details, please refer to the payload related to the screen call in our spec.

Group

The group call lets you associate a particular identified user with a group, such as a company, organization or an account. It also allows you to record the custom traits associated with that group, such as name of the industry, or the number of employees in the organization.

Payload

group.json
{
"userId": "user123",
"groupId": "group1",
"traits": {
"name": "Company",
"industry": "Industry",
"employees": 123
},
"timestamp": "2020-01-21T00:21:34.208Z"
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/group -d @group.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/group < group.json

Accepted Fields

Field

Type

Presence

Description

anonymousId

String

Optional

Sets the user ID for cases where there is no unique identifier for the user. Either userId or anonymousId is required.

userId

String

Optional, if anonymousId is already set

Unique identifier for a particular user in your database.

context

Object

Optional

Dictionary of information that provides context about a message. However, it is not directly related to the API call.

integrations

Object

Optional

Dictionary containing the destinations to be either enabled or disabled.

groupId

String

Required

Unique identifier of the group, as present in your database.

traits

Object

Optional

Dictionary of the properties or traits associated with the group, such as email or name.

timestamp

Date

Optional

Timestamp of the message's arrival.

Alias

The alias call allows you to associate one user identity with another. This is quite useful in case of some destinations such as Mixpanel (associating anonymousId with an identified user on signup) or Kissmetrics (when user switches IDs).

Payload

alias.json
{
"previousId": "123123123",
"userId": "user123",
"timestamp": "2020-02-02T00:11:15.368Z"
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/alias -d @alias.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/alias < alias.json

Accepted Fields

Field

Type

Presence

Description

userId

String

Optional, if anonymousId is already set

Unique identifier for a particular user in your database.

context

Object

Optional

Dictionary of information that provides context about a message. However, it is not directly related to the API call.

integrations

Object

Optional

Dictionary containing the destinations to be either enabled or disabled.

previousId

String

Required

The previous unique identifier of the user.

traits

Object

Optional

Dictionary of the properties or traits associated with the group, such as email or name.

timestamp

Date

Optional

Timestamp of the message's arrival.

Batch

The batch call allows you to send a series of identify, track, page, group and screen requests in a single batch. This call helps you minimize the number of outbound requests, thus enabling better performance.

As mentioned earlier, RudderStack sets a maximum limit of 500KB per batch request and 32KB per call.

Payload

batch.json
{
"batch": [
{
"type": "identify",
"userId": "user123",
"traits": {
"email": "name@domain.com",
"name": "Name Surname",
"age": 41
},
"timestamp": "2020-02-02T00:20:08.256Z"
},
{
"type": "track",
"userId": "user123",
"event": "Song Liked",
"properties": {
"name": "Revelations",
"artist": "Audioslave"
},
"timestamp": "2012-02-02T00:23:15.484Z"
},
{
"type": "identify",
"userId": "user123",
"traits": {
"email": "name@domain.com",
"name": "Name Surname",
"age": 29
},
"timestamp": "2020-02-06T00:40:18.276Z"
},
{
"type": "track",
"userId": "user123",
"event": "Song Liked",
"properties": {
"name": "Is Cookin'",
"artist": "WWE"
},
"timestamp": "2020-02-06T00:20:10.154Z"
}
],
"context": {
"device": {
"type": "phone",
"name": "Oneplus 7"
}
}
}

Usage

curl
httpie
curl
curl -u <your_write_key>: -X POST https://your-data-plane/v1/batch -d @batch.json --header "Content-Type: application/json"
httpie
http -a <your_write_key>: https://your-data-plane/v1/batch < batch.json

Accepted Fields

Field

Type

Presence

Description

batch

Array

Required

An array of identify, track, page, group and screen calls. It is mandatory that each call has a type property and a valid method name.

context

Object

Optional

This is the same as the context field in case of other calls. However, it is merged with the context (if any) inside each of the items within the batch.

integrations

Object

Optional

This is the same as the integrations field in case of other calls. However, it is merged with the integrations (if any) inside each of the items within the batch.

Historical Imports

RudderStack allows you to import any historical data by simply adding the timestamp argument to any of your API calls. However, this can be done only for the destinations that accept historical, time stamped data, such as Amplitude, Mixpanel, etc.

In case you are tracking current events, it is advisable to leave out the timestamp field. RudderStack will automatically add the timestamps to the event requests.

Contact Us

To know more about the HTTP API spec, please feel free to contact us. You can also start a conversation on our Discord channel, and we will be happy to help you.