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

KindExamples
Client and call optionsClientOptions, CallOptions
PaginationPage<T>, ListParams
Request and result shapesCreateAgentRequest, AgentResource, DraftResource, VersionResource, LibraryFile, FileJob, WhatsAppTemplateWrite
ConversationsConversation, ConversationMessage, ConversationPage, ConversationResult, ConversationActionResult, ConversationSearchParams, ConversationSearchHit, ConversationCountsResult, ConversationBulkResult, ConversationField
Webhook eventsPlaticaWebhookEvent (the union), WebhookEventOf<"message.created">
Webhook verificationVerifyWebhookSignatureParams, WebhookVerificationFailure
ErrorsApiErrorCode, 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:

ExportWhat it is
DEFAULT_BASE_URLhttps://api.platic.ai
SDK_VERSIONThe package version.
WEBHOOK_SIGNATURE_HEADER"x-webhook-signature"
FILE_INLINE_MAX_BYTES, FILE_UPLOAD_MAX_BYTESThe file sizes sent inline and the largest upload.
CHAT_MAX_ATTACHMENTSThe most attachments in a chat message.
CASE_WEBHOOK_EVENTS, AI_PROVIDER_IDS, WEBCHAT_MODES, DATABASE_ENGINES, FUNCTION_STATUSESThe allowed values of those fields.
CONVERSATIONS_RETRYABLE_ERRORSThe 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.

Next steps