Direct API Integration

The most flexible integration approach. Instead of relying on browser-based tracking, your systems send event data directly to rCDP using REST APIs. This gives you full control over what data is captured, when it is sent, and how it is structured — making it ideal for backend, mobile, and non-web environments.

Note: Direct API integration requires development effort but provides maximum control and accuracy.

Direct API integration shifts event tracking from the browser to your backend systems. Instead of capturing user behavior through JavaScript, your application explicitly generates and sends events to rCDP.

Your system becomes the source of truth for tracking data. You define the event, construct the payload, and decide exactly when it is triggered.

Tip: Use Direct API for critical events such as transactions where accuracy is essential.

When to Use Direct API

  • Backend or server-side event tracking

  • Mobile or non-browser environments

  • Precise control over event timing

  • Custom or headless architectures

  • Strict data validation requirements

How It Works

  1. Capture Event: Your system detects a business action such as purchase or login

  2. Build Payload: Construct structured JSON with metadata and eventData

  3. Send API Request: POST the payload to the rCDP endpoint

  4. Processing: rCDP validates and ingests the event

API Endpoint

All clickstream events are sent via HTTP POST to the following REST endpoint:

POST https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/<EVENT_NAME>
			

<TENANT_HASH>

Your unique tenant identifier — provided during Algonomy onboarding

<EVENT_NAME>

The event type string (e.g., eventProduct, eventAddToCart, eventCheckout)

Method

This is a POST API. All event data is sent in the JSON request body. The event name is part of the URL path.

Payload Structure

Each request contains context data and event-specific data.

  • Context → User, session, device, page

  • eventData → Business-specific event information

{
"srcId": "WBSTR",
"srcType": "Website",
"clientCorrelatorId": "5DEF0BF530F749AD46F652BDF3",
"requestTime": 1710000000000,
"siteHash": "ASADD5DEF0BF530F749AD46F652BDF3",
"sdkVersion": "2020R3",
"eventType": "eventHomePage",
"userAgent": {
"browserType": "Mozilla/5.0",
"browserVersion": "Firefox/32.0",
"customerDeviceOs": "IOS",
"customerDeviceType": "Mobile",
"timezone": "IST",
"isMobileDevice": "true",
"language": "us-en"
},
"session": {
"sessionKey": "SCBBD2244",
"customerIPAddress": "172.20.0.198",
"referrerSourceURL": "www.google.com",
"referrerName": "google",
"referrerType": "Search Engine",
"city": "Chicago",
"state": "IL",
"country": "US",
"cookieId": "5DEF0BF530F749AD46F652BDF3",
"sessionStartTime": "2015-02-02 23:14 UTC",
"locale": "en_US"
},
"customer": {
"customerCode": 12223433,
"mobile": 9876543211,
"email": "john.smith@example.com",
"uuid": "5DEF0BF530F749AD46F652BDF3"
},
"page": {
"pageKey": 12222,
"pageName": "Category",
"pageUrl": "www.example.com/category.html"
},
"utm": {
"source": "utm_src value",
"medium": "utm_med value",
"campaign": "utm_camp value",
"urlId": "t1_urlid value"
},
"storeId": "1222",
"eventDateTime": "2015-02-02 23:14 UTC",
"eventData": {}
}
			

Common Fields

Root-level fields provide system-level context. These are common across all event types:

ParameterTypeRequiredDescription
srcIdStringRequiredSource identifier — e.g., WBSTR (Web Store), MobileApp
srcTypeStringRequiredSource type — e.g., Shopify, Website Name, App Name
clientCorrelatorIdStringOptionalUnique identifier to correlate events across systems
requestTimeNumberRequiredUnix epoch timestamp in milliseconds
userAgentObjectOptionalDevice/browser info — browserType, customerDeviceType, timezone, language, etc.
sessionObjectOptionalSession context — sessionKey, customerIPAddress, referrerSourceURL, city, state, country, cookieId, locale
customerObjectRequiredCustomer identity — customerCode, email, mobile, uuid
pageObjectOptionalPage context — pageKey, pageName, pageUrl
utmObjectOptionalUTM tracking — source, medium, campaign, urlId
eventDataObjectRequiredEvent-specific business data (varies per event type)
eventDateTimeStringOptionalEvent date/time in yyyy-MM-dd HH:mm:ss (UTC)
storeIdStringOptionalPhysical store identifier (for POS/omnichannel)
siteHashStringOptionalSite hash provided during onboarding
sdkVersionStringOptionalSDK version string (e.g., 2020R3)

What This Enables

  • Full control over event data

  • Accurate server-side tracking

  • Cross-platform integration

  • Improved data reliability

  • Scalable architecture

Complete API Event Reference

Full examples for every supported event. For the complete official API documentation, see API Reference Guide.

Supported events:

Home - eventHomePage

Fires when the user lands on the home page.

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventHomePage" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com", "title": "Home" },
"eventData": {}
}'
			

Search - eventSearch

Fires when the user performsa search.

FieldTypeRequiredDescription
searchFacetstringYesSearch category or facet
searchStringstringYesThe search query entered by the user
searchResultsstringYesNumber of results returned
searchResponseTimestringNoResponse time in milliseconds

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventSearch" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/search?q=blue+shoes" },
"eventData": {
"searchFacet": "shoes",
"searchString": "blue shoes",
"searchResults": "42",
"searchResponseTime": "120"
}
}'
			

Category View - eventCategory

Fires when the user views a product category page.

FieldTypeRequiredDescription
categoryIdstringYesCategory ID
parentCategoryIdstringNoParent category

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventCategory" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/category/shoes" },
"eventData": {
"categoryId": "cat001",
"parentCategoryId": "parent001"
}
}'
			

Product

Product View - eventProduct

Fires when the user views a product detail page.

FieldTypeRequiredDescription
productIdstringYesUnique product identifier
categoryIdstringNoProduct category
pricestringYesProduct price
brandIdstringNoBrand identifier

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventProduct" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/product/prod001" },
"eventData": {
"productId": "prod001",
"categoryId": "cat001",
"price": "160.00",
"brandId": "brd001"
}
}'
			

Cart

Add to Cart - eventAddToCart

Fires when the user adds a product to the cart.

FieldTypeRequiredDescription
productIdstringYesProduct identifier
skustringNoSKU identifier
categoryIdstringNoProduct category
pricestringYesUnit price
quantitystringYesQuantity added
totalQuantitystringNoTotal quantity in cart

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventAddToCart" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/product/prod001" },
"eventData": {
"productId": "prod001",
"sku": "sku001",
"categoryId": "cat001",
"price": "160.00",
"quantity": "1",
"totalQuantity": "2"
}
}'
			

Edit Cart Item - eventCartItemEdit

Fires when the user modifies cart item quantity, removes an item, or applies a coupon.

FieldTypeRequiredDescription
cartIdstringYesCart identifier
cartProductsarrayYesArray of cart product objects
cartProducts[].productIdstringYesProduct identifier
cartProducts[].categoryIdstringNoCategory

cartProducts[].productPosition

string

No

Position context (e.g., 'Cart')

cartProducts[].actionstringYesAction performed
cartProducts[].quantitynumberYesUpdated quantity

cartProducts[].productBasePrice

number

Yes

Base price of the product

cartProducts[].tax

number

No

Tax amount

cartProducts[].sku

number

No

SKU identifier

cartProducts[].discount

number

No

Discount applied

cartProducts[].couponCode

string

No

Coupon code if applied

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventCartItemEdit" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/cart" },
"eventData": {
"cartId": "cart123",
"cartProducts": [
{
"productId": "814",
"categoryId": "222",
"productPosition": "Cart",
"action": "Edit Cart",
"quantity": 1,
"productBasePrice": 210.00,
"tax": 17.33,
"sku": "sku123",
"discount": 5.00,
"couponCode": "DISCOUNT2024"
}
]
}
}'
			

Transaction

Checkout - eventCheckout

Fires when the user initiates the checkout process.

FieldTypeRequiredDescription
transactionIdstringYesTransaction identifier
tenderTypestringYesPayment method
checkoutTypenumberNoCheckout type flag
totalPricenumberYesTotal order price
shippingCostnumberNoShipping cost
discountnumberNoTotal discount applied
couponCodestringNoCoupon code
cartIdstringNoCart identifier
cartProductsarrayYesCart products
billingInfoobjectYesBilling address
shippingInfoobjectYesShipping address

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventCheckout" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/checkout" },
"eventData": {
"transactionId": "727",
"tenderType": "cash",
"checkoutType": 0,
"totalPrice": 227.33,
"shippingCost": 0.00,
"discount": 0,
"couponCode": null,
"cartId": "cart123",
"cartProducts": [
{
"productId": "814",
"productPosition": 1,
"action": "Checkout",
"quantity": 1,
"productBasePrice": 210.00,
"tax": 17.33,
"sku": "sku",
"discount": 0.00,
"couponCode": null
}
],
"billingInfo": {
"firstName": "John",
"lastName": "Smith",
"line1": "4/40",
"cityCode": "Chicago",
"stateCode": "IL",
"zip": "60001",
"countryCode": "IN",
"emailAddress": "john.smith@example.com",
"phoneNumber": "1234567890"
},
"shippingInfo": {
"firstName": "John",
"lastName": "Smith",
"line1": "4/40",
"cityCode": "Chicago",
"stateCode": "IL",
"zip": "60001",
"countryCode": "IN",
"emailAddress": "john.smith@example.com",
"phoneNumber": "1234567890"
}
}
}'
			

Transaction Complete - eventTransactionComplete

Fires when the transaction is successfully completed.

FieldTypeRequiredDescription
transactionIdstringYesTransaction identifier
orderIdstringYesOrder identifier
tenderTypestringYesPayment method
checkoutTypenumberNoCheckout type flag
totalPricenumberYesTotal order price
shippingCostnumberNoShipping cost
discountnumberNoTotal discount
couponCodestringNoCoupon code
totalItemCountnumberNoTotal number of items
cartProductsarrayYesArray of cart product objects
billingInfoobjectYesBilling address object
shippingInfoobjectYesShipping address object

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventTransactionComplete" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/order-confirmation" },
"eventData": {
"transactionId": "727",
"orderId": "123",
"tenderType": "cash",
"checkoutType": 0,
"totalPrice": 227.33,
"shippingCost": 0.00,
"discount": 0,
"couponCode": null,
"totalItemCount": 1,
"cartProducts": [
{
"productId": "814",
"quantity": 1,
"productBasePrice": 210.00,
"tax": 17.33,
"sku": "sku",
"discount": 0.00,
"couponCode": null
}
],
"billingInfo": {
"firstName": "John",
"lastName": "Smith",
"line1": "4/40",
"cityCode": "Chicago",
"stateCode": "IL",
"zip": "60001",
"countryCode": "IN",
"emailAddress": "john.smith@example.com",
"phoneNumber": "1234567890"
},
"shippingInfo": {
"firstName": "John",
"lastName": "Smith",
"line1": "4/40",
"cityCode": "Chicago",
"stateCode": "IL",
"zip": "60001",
"countryCode": "IN",
"emailAddress": "john.smith@example.com",
"phoneNumber": "1234567890"
}
}
}'
			

Transaction Failure - eventTransactionFailure

Fires when a transaction fails.

FieldTypeRequiredDescription
orderIdstringYesOrder identifier
errorCodestringYesError code from the payment provider
errorMessagestringNoHuman-readable error message

 


					curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventTransactionFailure" \
					-H "Authorization: Bearer <ACCESS_TOKEN>" \
					-H "Content-Type: application/json" \
					-d '{
					"srcId": "WBSTR",
					"srcType": "Website",
xxx"totalPrice": 199.99,
xx}
					}'
			

Identity

Customer Create - eventCustomerCreate

Fires when a new customer registers.

FieldTypeRequiredDescription
customerCodestringYesInternal customer ID
customerEmailIdstringYesEmail address
mobileNostringNoMobile number
firstNamestringYesFirst name
lastNamestringYesLast name
genderstringNoGender (Male/Female/Other)
dobstringNoDate of birth (MM-DD-YYYY)
joiningDatestringNoRegistration date (MM-DD-YYYY)

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventCustomerCreate" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/register" },
"eventData": {
"customerCode": "100",
"customerEmailId": "user@mail.com",
"mobileNo": "9000000000",
"firstName": "John",
"lastName": "Smith",
"gender": "Male",
"dob": "12-30-2000",
"joiningDate": "01-15-2024"
}
}'
			

Login - eventLogin

Fires when the user logs in.

FieldTypeRequiredDescription
customerCodestringYesInternal customer ID

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventLogin" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/login" },
"eventData": {
"customerCode": "100"
}
}'
			

Update Profile - eventUpdateProfile

Fires when the user updates their profile.

FieldTypeRequiredDescription
customerCodestringYesInternal customer ID
firstNamestringNoUpdated first name
lastNamestringNoUpdated last name
customerEmailIdstringNoUpdated email
genderstringNoUpdated gender
dobstringNoUpdated date of birth

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventUpdateProfile" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/profile" },
"eventData": {
"customerCode": "100",
"firstName": "Jane",
"lastName": "Smith",
"customerEmailId": "jane@mail.com",
"gender": "Female",
"dob": "05-15-1990"
}
}'
			

Logout - eventLogout

Fires when the user logs out.

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventLogout" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com", "customerCode": "100" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/logout" },
"eventData": {}
}'
			

Forgot Password - eventForgotPassword

Fires when the user initiates a forgot password request.

FieldTypeRequiredDescription
customerEmailIdstringYesEmail address used for password reset
curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventForgotPassword" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/forgot-password" },
"eventData": {
"customerEmailId": "user@mail.com"
}
}'
			

Engagement

Share Wishlist - eventShareWishlist

Fires when the user shares a wishlist.

FieldTypeRequiredDescription
wishlistIdstringYesWishlist identifier
shareMethodstringNoSharing method (email, social, etc.)

 

curl -X POST "https://sandbox.algonomy.com/callback/rest/events/<TENANT_HASH>/eventShareWishlist" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"srcId": "WBSTR",
"srcType": "Website",
"requestTime": 1710000000000,
"customer": { "email": "user@mail.com" },
"session": { "sessionId": "sess-abc123" },
"page": { "url": "https://example.com/wishlist" },
"eventData": {
"wishlistId": "wl001",
"shareMethod": "email"
}
}'
			

Response Codes

The API returns standard HTTP status codes to indicate the outcome of each request:

Status CodeMeaningDescription
202 AcceptedSuccessEvent was accepted and queued for processing.
400 Bad RequestValidation ErrorThe request payload is malformed, missing required fields, or contains invalid data.
401 UnauthorizedAuth FailedThe access token is missing, expired, or invalid. Re-authenticate via OAuth.
403 ForbiddenAccess DeniedThe token does not have permission for this tenant or resource.
404 Not FoundInvalid EndpointThe tenant hash or event name in the URL is incorrect.
429 Too Many RequestsRate LimitedYou have exceeded the API rate limit. Implement exponential backoff and retry.
500 Internal Server ErrorServer ErrorAn unexpected error occurred on the server. Retry with backoff.

Best Practices

  • Validate payload before sending

  • Use consistent event naming

  • Retry failed requests with backoff

  • Ensure consent compliance

  • Log API responses for debugging

Tip: Use server-side retries to avoid data loss during transient failures.

Troubleshooting

  • Verify endpoint URL and tenant hash

  • Check payload structure

  • Ensure network connectivity

  • Review API response codes

Note: Most issues occur due to malformed payloads or incorrect event names.

Direct API integration provides maximum flexibility and control over event tracking. It is best suited for backend-driven systems and advanced use cases where precision and scalability are required.

OAuth 2.0 Authentication

The rCDP Clickstream API uses OAuth 2.0 Client Credentials flow. You must obtain an access token before making any API calls.

Obtain an Access Token

Token Request

curl -X POST https://rcdp-us.algonomy.com/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=<YOUR_CLIENT_ID>" \
-d "client_secret=<YOUR_CLIENT_SECRET>"
			

Token Response

{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "Bearer",
"expires_in": 3600
}
			

Use the Token in API Calls

Include the token as a Bearer token in the Authorization header of every API call.

  • client_id: Provided during Algonomy onboarding

  • client_secret: Provided during Algonomy onboarding

  • grant_type: Always client_credentials

  • expires_in: Token validity in seconds (typically 3600)

Token management
Access tokens expire. Cache the token and refresh it before expiry. Never embed client secrets in client-side code — OAuth-based API integration is intended for server-side use only.