Installation
Initialize the client
The SDK uses a Bearer token for authentication. Obtain an access token by exchanging your SDK credentials and pass it when creating the client:Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl | string | required | API base URL |
accessToken | string | required | Bearer token from /auth/token |
timeoutMs | int | 10000 | HTTP request timeout in ms |
maxRetries | int | 2 | Retry count on 429/5xx/timeouts |
collateWindowSeconds | float | 3 | Buffer events for this many seconds before flushing |
maxBatchSize | int | 200 | Flush immediately when the buffer reaches this size |
maxBufferedEvents | int | 5000 | Drop oldest events beyond this limit |
maxEventRetries | int | 5 | Retry count for buffered event sends |
disableArrayBatching | bool | false | Force single-event sends |
propagateRecommendationRequestId | bool | true | Auto-attach request_id from recommendations to subsequent events |
sessionId | string or null | null | Override the SDK-wide session ID |
autoSessionId | bool | true | Auto-generate a session UUID |
httpClient | callable | cURL | Custom HTTP transport for non-cURL environments or tests |
Get recommendations
entity_id, name, description, score, and any metadata you stored with the item. The response also includes a request_id for event attribution.
Auto-generated sections
UsegetAutoRecommendations for paginated, auto-titled recommendation sections:
Track events
Events provide the feedback loop that powers personalization. The PHP SDK buffers events in memory for the lifetime of the current process.How batching works in PHP
- Events are buffered with a
client_tstimestamp. - The buffer flushes when it reaches
maxBatchSize. - You can force delivery with
flushEvents()or by calling->wait()on the returnedPendingResult. - Remaining buffered events are flushed during PHP shutdown.
- Failed sends are retried with exponential backoff.
Request ID propagation
WhenpropagateRecommendationRequestId is enabled, the SDK captures the request_id from getRecommendations() and automatically attaches it to subsequent trackEvent() calls unless you explicitly provide requestId or request_id.
Manage catalog items
Upsert an item
Update an item
Delete items
Error handling
The SDK exposesSDKHttpError and SDKTimeoutError:
Logging
Configure structured logging for debugging and observability:TRACE, DEBUG, INFO, WARN, ERROR, FATAL.
Session management
The SDK auto-generates a session UUID on initialization whenautoSessionId is enabled. You can override or read it:

