Send an event

Use this endpoint to send an event from your server or use javascript events to call the API.

API at a glance

Description: This API allows you to send an event from your server or use JavaScript events to call the API. Events track user actions and behaviors on your platform.

Authentication & testing

Testing the API on this page

How to try it here

  • Use your User API Key as the Username (leave Password blank).
  • User API Key Location
  • Select the appropriate API endpoint based on your Blueshift region.
  • API - Select Region
  • Enter the necessary parameters and click Try It to run the request.
Authentication using Base64 encoding

Note for developers

API requests require authentication using HTTP Basic Authentication with an API key. The API key serves as the username, while the password field should be left empty. The format to encode is: your_api_key: (note the trailing colon).

This string must be Base64-encoded and included in the request's Authorization header as follows:

Authorization: Basic encoded_value

You can generate the encoded value using a trusted Base64 encoder.


Postman collection

Try it with Postman: Explore the API using Blueshift's Postman collection.


Things to know before you start

  • Required identifier fields: Ensure that you provide values for at least one of the following fields: customer_id, event, device_id, cookie or email.
  • Best practice: If possible, provide values for more than one of these identifier fields.
  • Anonymous users: For anonymous users, specify at least the value for the cookie.
  • Event naming rules: Ensure that the event name does not contain periods (.), whitespaces, is not a numeric value, and contains no more than 64 characters.
  • Mobile apps: If you use the event API to identify a user from a mobile app, ensure that you also include device_id and device_token parameters. However, we recommend using Blueshift's SDK for mobile apps. See Android SDK and iOS SDK.
  • Use case: Best for tracking user interactions, behaviors, and custom events from your server or web application.

Request parameters

Check out the request parameters

Body parameters

Note: You must provide at least one of: customer_id, event, device_id, cookie, or email.

ParameterTypeRequiredDescription
eventstring✅ YesSpecify the name of the event (e.g., identify, view, add_to_cart, purchase, search, custom event names).
customer_idstring❌ NoSpecify the customer ID.
emailstring❌ NoSpecify the user's email address.
device_idstring❌ NoSpecify the UUID of the device.
cookiestring❌ NoUser's Blueshift cookie used as an identifier for anonymous users.
device_typestring❌ NoSpecify the type of the device (e.g., ios, android).
device_tokenstring❌ NoSpecify the token of the device.
device_idfastring❌ NoSpecify the advertising identifier (IDFA) on the device.
device_idfvstring❌ NoSpecify the identifier for vendor (IDFV) on the device.
device_manufacturerstring❌ NoSpecify the manufacturer of the device.
os_namestring❌ NoSpecify the OS name.
network_carrierstring❌ NoSpecify the carrier on the mobile device.
ipstring❌ NoSpecify the IP address of the device.
latitudestring❌ NoSpecify the latitude of the user's location.
longitudestring❌ NoSpecify the longitude of the user's location.
event_uuidstring❌ NoSpecify a unique identifier of the event in UUID format. See RFC 4122.
subscription_groupsarray❌ NoSpecify the user's subscription preferences. See structure below.

Subscription groups object

ParameterTypeDescription
idstringThe ID of the subscription group.
subscribedbooleanEnter true if the user is subscribed, or false if unsubscribed.

Example requests & responses

Send an identify event

Request

curl --request POST \
     --url https://api.getblueshift.com/api/v1/event \
     --header 'accept: application/json' \
     --header 'authorization: Basic <YOUR_EVENT_API_KEY>' \
     --header 'content-type: application/json' \
     --data '{
       "customer_id": "812123",
       "event": "identify",
       "email": "[email protected]",
       "device_type": "ios",
       "device_id": "8abe3faa-d48d-4e4a-00ca-beae01f1c987",
       "ip": "192.0.2.1",
       "subscription_groups": [
         {
           "id": "newsletter",
           "subscribed": true
         },
         {
           "id": "weekly_promo",
           "subscribed": false
         }
       ]
     }'

Response

{
  "status": "OK"
}
API error responses

Note
The following error codes are commonly returned by Blueshift APIs. Depending on the specific endpoint, not all may apply.

Status code

Description

Example responses

400 Bad Request

The request is invalid due to missing or incorrect parameters. This includes missing fields, invalid values, formatting issues, or conflicts such as duplicate data.

{ "errors": { "name": ["can't be blank"] } }

{ "errors": { "startdate": ["can't be blank"] } }

401 Unauthorized

API authentication failed due to an invalid or missing API key.

{ "message": "Not authorized" }

403 Forbidden

The API key does not have sufficient permissions to perform this action.

{ "message": "Permission denied" }

404 Not Found

The specified campaign was not found. Verify the campaign UUID.

{ "message": "Campaign not found" }

422 Unprocessable Entity

  • The campaign cannot be paused due to its current status (e.g., already completed or archived).
  • One or more scheduling parameters may be invalid (if applicable).

{ "message": "Campaign cannot be paused in its current status." }

{ "message": "Invalid schedule values" }

429 Too Many Requests

The request limit has been exceeded. Reduce request frequency.

{ "message": "Rate limit exceeded" }

500 Internal Server Error

An unexpected server error occurred. Contact support if the issue persists.

{ "message": "Internal Server Error - Please contact support for more information." }

502 Bad Gateway

The server received an invalid response. Retry the request.

{ "message": "Bad Gateway - Please retry the request." }

503 Service Unavailable

The service is temporarily unavailable. Try again later.

{ "message": "Service Unavailable - The service is temporarily unavailable. Try again later." }

504 Gateway Timeout

The server took too long to respond. Retry the request with exponential backoff.

{ "message": "Gateway Timeout - The server took too long to respond. Retry with exponential backoff." }

Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!