api.apiRequest(endpoint, options?) Sends an authenticated HTTP request to the public REST API. The SDK adds Authorization: Bearer with the current access token and refreshes it on expiry. Resolves with a plain object { ok, status, data } (the parsed response) — not a fetch Response, so read response.data rather than calling response.json().
| argument | Type | Description |
|---|---|---|
| endpointrequired | string | API path starting with /api/v1/... (e.g. /api/v1/cards/123). See the REST section for the full list of endpoints. |
| options | RequestInit | Optional fetch options (method, headers, body, etc.). The Authorization header is added automatically. |
Return value - Promise<{ ok: boolean, status: number, data: any }>
// Inside an addon iframe
const api = window.Addon.iframe();
// Generic request — resolves with { ok, status, data } (not a fetch Response).
const response = await api.apiRequest('/api/v1/cards/123', {
method: 'GET',
});
if (response.ok) {
const card = response.data;
}