Types
Import parameter and result types with import type. TypeScript uses them to check your code and removes them when compiling.
import type { AgentResource, CreateAgentRequest, WebhookEventOf } from "platic-sdk";
const draft: CreateAgentRequest = { name: "Support", instructions: "Be brief." };
function onMessage(event: WebhookEventOf<"message.created">, agent: AgentResource) {
console.log(agent.id, event.data.message.content, draft.name);
} What is exported
| Kind | Examples |
|---|---|
| Client and call options | ClientOptions, CallOptions |
| Pagination | Page<T>, ListParams |
| Request and result shapes | CreateAgentRequest, AgentResource, DraftResource, VersionResource, LibraryFile, FileJob, WhatsAppTemplateWrite |
| Conversations | Conversation, ConversationMessage, ConversationPage, ConversationResult, ConversationActionResult, ConversationSearchParams, ConversationSearchHit, ConversationCountsResult, ConversationBulkResult, ConversationField |
| Webhook events | PlaticaWebhookEvent (the union), WebhookEventOf<"message.created"> |
| Webhook verification | VerifyWebhookSignatureParams, WebhookVerificationFailure |
| Errors | ApiErrorCode, ConversationsErrorCode, ApiErrorDetails, ApiErrorIssue, RequestInfo (the classes are values: import them without type) |
The types are based on Platica's OpenAPI documents where available. Otherwise, they are defined from the API's behavior. Their names match the schemas in the API reference.
Types of a method
Get a method's result type with Awaited and ReturnType:
type Agent = Awaited<ReturnType<typeof platic.agents.create>>;
type FileJob = Awaited<ReturnType<typeof platic.files.waitForJob>>; For a paginated result, use Page:
import type { Page } from "platic-sdk";
type AgentPage = Awaited<ReturnType<typeof platic.agents.list>>; // Page<AgentSummary> Conversation pages extend Page with pagination, meta and included:
import type { ConversationActionResult, ConversationPage } from "platic-sdk";
function supervised(page: ConversationPage) {
return page.data.filter((conversation) => conversation.operation === "supervised");
}
function report(result: ConversationActionResult) {
console.log(result.meta.action, result.meta.changed, result.meta.effects);
} Constants
The SDK also exports values you may need at run time:
| Export | What it is |
|---|---|
DEFAULT_BASE_URL | https://api.platic.ai |
SDK_VERSION | The package version. |
WEBHOOK_SIGNATURE_HEADER | "x-webhook-signature" |
FILE_INLINE_MAX_BYTES, FILE_UPLOAD_MAX_BYTES | The file sizes sent inline and the largest upload. |
CHAT_MAX_ATTACHMENTS | The most attachments in a chat message. |
CASE_WEBHOOK_EVENTS, AI_PROVIDER_IDS, WEBCHAT_MODES, DATABASE_ENGINES, FUNCTION_STATUSES | The allowed values of those fields. |
CONVERSATIONS_RETRYABLE_ERRORS | The conversation error codes that may succeed if sent again. |
TypeScript settings
The package is tested with TypeScript 5.9 under strict, with module and moduleResolution set to nodenext. It ships ESM and CommonJS builds, each with its declarations.