api.apiPost<T>(endpoint, data) Convenience method that sends a POST request with a JSON body and returns the parsed JSON response.
| 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. |
| datarequired | unknown | Request body. The SDK serializes it as JSON and sets Content-Type: application/json. |
Return value - Promise<T>
const api = window.Addon.iframe();
const comment = await api.apiPost(
`/api/v1/cards/${cardId}/comments`,
{ text: 'Hello from my addon!' },
);
// { id, text, author_id, created, ... }