Events API Docs

The Event Collection API enables users to track and record events via a simple HTTP POST request to /collect/event endpoint. This facilitates insights into user interactions and behavior for analytics

Base URL

The base URL for making requests to the Event Collection API is:

API Endpoints:

Endpoint: /collect/event

Method: POST

Description: The /collect/event endpoint is used to collect and store events in the system. Clients can send event data as JSON in the request body. The server will process the incoming event data and store it for further analysis.

Request Body:

The request body must contain a JSON object representing the event data. The JSON object can include the following properties:

  • messageBody ([Event], required): An array containing one or more event objects, each representing an individual event.

  • messageheader (Object, optional): A key-value pair object containing additional headers for the event collection.

* Example Request: (HTTP request RAW) *

POST /collect/event HTTP/1.1
Host: example.com
Content-Type: application/json
{
  "messageBody": 
  [
		{
			...properties
		},
		{
			...properties
		}
  ],
  "messageHeaders": 
	        {
		        ...headers
	        }
}

Response:

  • Status Code: 201 OK

  • Content-Type: application/json

Example Response:

[
	{
		"headers": {},
		"value": "{\"pingId\": \"c523aa41-9f0f-4fc2-bc96-5a8ff5520b78\"}" 
	}
]
Error Handling:

If there's an issue with the request or the server cannot process the event data, an appropriate error response will be returned.

Example Error Response:

{
  "error": "Bad Request",
  "message": "invalid event type",
	"statusCode": 400
}

Error Codes:

The API may return various HTTP status codes to indicate the success or failure of a request. Here are some of the common status codes:

ERROR CODEDESCRIPTION

201 OK

The request was successful, and the event data was collected.

400 Bad Request

The request was malformed or had invalid parameters.

429 Too Many Requests

The client has exceeded the rate limit for the /collect/event endpoint.

500 Internal Server Error

An unexpected server error occurred.

Rate Limits:

To maintain fair usage and prevent abuse, rate limits are imposed on the /collect/event endpoint. If a client surpasses the permitted number of requests within a specific time window, the API will respond with a rate-limiting error.

Example Response Headers:

HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1672766785

Rate Limit Headers:

Rate Limit NameDescription

X-RateLimit-Limit

The maximum number of requests allowed within the current time window.

X-RateLimit-Remaining

The number of remaining requests allowed within the current time window.

X-RateLimit-Reset

The time at which the rate limit will be reset (usually in UTC timestamp).

Last updated