Aller au contenu principal

Conversions API

The Conversions API provides a structured way to send conversion data to Rokt similar to the existing Event API. It uses a defined set of fields instead of arbitrary key-value pairs, validates data formats and provides detailed feedback on issues without rejecting entire requests.

Endpoint

POST https://api.rokt.com/v1/conversions

Authentication

Reach out to your Rokt account manager to create a public and secret key pair for the accounts for which you would like to submit conversion events. These keys take the form of rpub- and rsec- respectively.

NameValue
Rokt Public Keyrpub-********-****-****-****-************
Rokt Secret Keyrsec-********-****-****-****-************

Request

Headers

NameValueDescription
Content-Typeapplication/jsonMust be application/json.
AuthorizationBasic base64(rpub-...:rsec-...)Standard basic authentication header, with the credential value being a base64 encoding of rpub- and rsec- joined by a colon.

Body

The request body should be provided as JSON with the following fields:

FieldTypeMax lengthDescription
accountId*String64Rokt Account ID
testBooleanWhen set to true, the request is validated without processing or ingesting any events. Use for testing your integration.
events*List[Object]100 itemsArray of conversion events. Must contain at least one event.

Each object in the events array can contain the following fields:

FieldTypeMax lengthDescription
conversionIdString255Unique identifier for the conversion. Duplicate values within a request will cause subsequent events to be rejected.
conversionType*String255Type of conversion (e.g., purchase, signup, subscription).
eventTime*StringTime when the conversion event occurred (RFC3339 format). Cannot be in the future or more than 12 months old.
roktIdString255Rokt user identifier.
emailString255User email address (lowercase recommended for consistency with hashed values).
emailsha256String64SHA256 hash of user email address (64 character hex string).
rclidString64Rokt Click ID (SHA256 hash, 64 character hex string).
mobileString255User mobile phone number.
mobilesha256String64SHA256 hash of user mobile phone number (64 character hex string).
firstNameString255User first name.
lastNameString255User last name.
billingZipcodeString255User billing zip/postal code.
firstNamesha256String64SHA256 hash of user first name (64 character hex string).
lastNamesha256String64SHA256 hash of user last name (64 character hex string).
billingZipcodesha256String64SHA256 hash of user billing zip/postal code (64 character hex string).
ipAddressString255User IP address.
userAgentString1024User agent string from the browser.
valueNumberTransaction value (0 to 1000000).
ltvNumberCustomer lifetime value (0 to 1000000).
predictedLTVNumberPredicted customer lifetime value (0 to 1000000).
currencyString255Currency code (ISO 4217).
quantityIntegerQuantity of items (minimum 0). Must be a whole number.
productNameString255Name of the product.
skuString255Stock keeping unit identifier.
paymentTypeString255Payment method type.
marginNumberProfit margin (0 to 1000000).
transactionIdString100Unique transaction identifier.
confirmationRefString100Confirmation reference number. Used for deduplication.
customAttributesObjectCustom key-value pairs for additional data.
• Maximum 10 keys
• Keys must be alphanumeric (no spaces, underscores, or special characters)
• Keys must not conflict with event schema field names
• Key length maximum 255 characters
• String values maximum 1024 characters
Identifier Validation

Each conversion event must include at least one of the following identifier combinations to enable proper matching and attribution:

  • Any of: roktId, email, emailsha256, rclid, mobile, mobilesha256
  • All of: firstName, lastName, billingZipcode
  • All of: firstNamesha256, lastNamesha256, billingZipcodesha256
  • All of: ipAddress, userAgent

Events that do not meet these requirements will fail validation.

Samples

Minimal example with required fields only:

{
"accountId": "12345",
"events": [
{
"conversionType": "purchase",
"eventTime": "2024-12-11T10:00:00Z",
"email": "user@example.com"
}
]
}

Multiple events example:

{
"accountId": "12345",
"events": [
{
"conversionId": "evt_001",
"conversionType": "purchase",
"eventTime": "2024-12-11T10:00:00Z",
"email": "alice@example.com"
},
{
"conversionId": "evt_002",
"conversionType": "signup",
"eventTime": "2024-12-11T10:15:30Z",
"email": "bob@example.com"
},
{
"conversionId": "evt_003",
"conversionType": "purchase",
"eventTime": "2024-12-11T10:30:45Z",
"email": "carol@example.com"
}
]
}

Complete example with all available fields:

{
"accountId": "12345",
"events": [
{
"conversionId": "evt_123456",
"conversionType": "purchase",
"eventTime": "2024-09-11T10:00:00Z",
"roktId": "550e8400-e29b-41d4-a716-446655440000",
"email": "user@example.com",
"emailsha256": "d8a928b2043db77e340b523547bf16cb4aa483f0645fe0a290ed1f20aab76257",
"rclid": "550e8400e29b41d4a716446655440001550e8400e29b41d4a716446655440001",
"mobile": "+16175494599",
"mobilesha256": "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456",
"firstName": "John",
"lastName": "Doe",
"billingZipcode": "12345",
"firstNamesha256": "f1e2d3c4b5a698765432109876543210fedcba9876543210fedcba9876543210",
"lastNamesha256": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"billingZipcodesha256": "fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"ipAddress": "192.168.0.1",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"value": 99.99,
"ltv": 499.99,
"predictedLTV": 299.99,
"currency": "USD",
"quantity": 1,
"productName": "Premium Widget",
"sku": "WIDGET-001",
"paymentType": "credit_card",
"margin": 24.99,
"transactionId": "txn_789012",
"confirmationRef": "conf_456789",
"customAttributes": {
"source": "website",
"campaignId": "summer2024",
"isNewCustomer": true,
"sessionId": "abc123def456",
"couponCode": "SAVE20",
"discountPercent": 15,
"taxRate": 0.0825
}
}
]
}

Response

The API validates requests in two stages:

  1. Request validation: checks authentication, JSON format, and required fields
  2. Event validation: processes individual events if request validation passes

Status codes

HTTP response codeDescription
200Successfully processed conversion events (all or partial).
400Bad request - validation errors or all events failed.
401Unauthorized - invalid or missing authentication token.
403Forbidden - token not authorized for this account.
413Request Entity Too Large - request body exceeds 1MB limit.
429Too Many Requests - rate limit exceeded.
500Internal Server Error.
503Service Unavailable.

Request validation errors

Response contains a data object with:

FieldTypeDescription
codeStringError code (e.g., EventsRequiredError, AccountIDRequiredError, InvalidJSONError).
messageStringDetailed error message.

Event processing results

Returns 200 (Success/Partial) if at least one event is valid, or 400 (Failure) if no events are valid.

All responses contain a data object with the following fields:

FieldTypeDescription
codeStringResponse status code (Success, Partial, or Failure).
processedCountNumberNumber of events successfully processed.
invalidCountNumberNumber of events that failed validation.
errorsList[Object]Array of errors from event processing. Each object follows the error/warning schema below.
warningsList[Object]Array of warnings from event processing. Each object follows the error/warning schema below.

The warnings in the response will include the checks that have failed but are not severe enough to cause the whole conversion event to be rejected. They will not affect the invalidCount.

Each error and warning object in the errors and warnings arrays will include the conversionId field if it was provided in the corresponding request event. This helps identify which specific event caused the issue.

Error/warning object schema:

FieldTypeDescription
conversionIdStringConversion ID if present in the event.
eventIndexNumberPosition of the event in the request array (starting from 0).
fieldStringField name that caused the error or warning.
messageStringError or warning message.

Samples

Request validation error:

{
"data": {
"code": "InvalidAccountIDError",
"message": "Account ID is invalid"
}
}

Success (all events valid):

{
"data": {
"code": "Success",
"processedCount": 1,
"invalidCount": 0
}
}

Partial (some events valid):

{
"data": {
"code": "Partial",
"processedCount": 1,
"invalidCount": 1,
"errors": [
{
"eventIndex": 1,
"field": "conversionType",
"message": "conversionType is required"
},
{
"eventIndex": 1,
"field": "eventTime",
"message": "eventTime is required"
}
]
}
}

Failure (all events invalid):

{
"data": {
"code": "Failure",
"processedCount": 0,
"invalidCount": 1,
"errors": [
{
"eventIndex": 0,
"field": "eventTime",
"message": "must be a valid RFC3339 timestamp"
}
]
}
}
Cet article vous a-t-il été utile ?