SDK reference · Client
Trickroom
class Trickroom(options: TrickroomOptions)Server-side client for one application. Its key decides which application it acts for and which calls it may make; keep the key out of browsers, mobile apps and sandboxes.
Resources hang off the client as namespaces: client.users, client.jobs, client.connections and so on. Every method returns a promise and throws TrickroomError when the API refuses the call.
Options
baseUrlstring- Your deployment's origin, or its API root ending in /v1 (both work).
apiKeystring- An application key (tak_…) from Settings → API keys.
applicationIdstringoptional- The key's application. Looked up once when omitted; set it to save that call.
fetchtypeof fetchoptional- A fetch to use instead of the global one, e.g. in tests.
applicationId
applicationId(): Promise<string>The key's application ID, looked up once and remembered. A failed lookup is retried by the next call.
Returns Promise<string>
request
request<T>(method: string, path: string, body?: unknown, key?: string, timeoutMs?: number): Promise<T>Calls any route of the application, relative to /v1/applications/{id}. Use it for routes the client has no method for yet.
Parameters
methodstring- GET, POST, PUT or DELETE.
pathstring- The route below the application, such as /flows.
bodyunknownoptional- Sent as JSON.
keystringoptional- An idempotency key. Retrying with the same key and input returns the first result instead of acting twice.
timeoutMsnumberoptional- Aborts the call after this long (default 45 s).
Returns Promise<T>