API Overview
Ttoolab exposes a browser SDK API through its edge worker. This is the primary public HTTP interface for customer integrations.
SDK base URL
Section titled “SDK base URL”https://sdk.ttoolab.comAll SDK endpoints are served from this host in production.
Authentication
Section titled “Authentication”SDK endpoints do not require API keys. Authentication is implicit:
- Bootstrap — validated by
projectKeyandanonymousIdformat - Events — validated by
projectKeyin the request body
Do not expose internal service credentials in client-side code.
Request format
Section titled “Request format”- Bootstrap:
GETwith query parameters - Events and surveys:
POSTwithContent-Type: application/json
Response format
Section titled “Response format”Successful SDK responses return JSON:
{ "success": true }Bootstrap returns a JSON blob with assignments, experiments, surveys, and integration settings.
The SDK worker supports cross-origin requests from browsers. Preflight OPTIONS requests are handled automatically.
Rate limits
Section titled “Rate limits”Versioning
Section titled “Versioning”The SDK JavaScript bundle is versioned internally (1.0.0). HTTP paths are not versioned (/sdk/bootstrap, not /v1/sdk/bootstrap).
Health check
Section titled “Health check”GET https://sdk.ttoolab.com/healthResponse:
{ "ok": true, "service": "ttoolab-worker", "kv": true}JavaScript SDK methods
Section titled “JavaScript SDK methods”| Method | Description |
| :----- | :---------- |
| ttoolab.init(config?) | Initialize with optional projectKey and endpoint |
| ttoolab.track(name, payload?) | Send a custom event |
| ttoolab.ready(callback) | Callback when bootstrap completes |
| ttoolab.getBlob() | Get cached bootstrap data |
| ttoolab.getAssignments() | Get current assignments |
| ttoolab.getVariant(experimentKey) | Get variant key for an experiment |
| ttoolab.clear() | Clear local SDK storage |