Documentation

DocsGuidesSDK Reference

TypeScript SDK Reference

Complete reference for the @outreachagent/sdk-ts package.

Installation

Terminal
npm install @outreachagent/sdk-ts

Initialization

TypeScript
import { OutreachAgentClient } from "@outreachagent/sdk-ts";

const client = new OutreachAgentClient(
  "https://api.outreachagent.dev",   // base URL
  "rm_live_..."                       // API key
);

Error Handling

TypeScript
import { OutreachAgentError } from "@outreachagent/sdk-ts";

try {
  await client.sendMessage({ ... });
} catch (err) {
  if (err instanceof OutreachAgentError) {
    console.log(err.status);  // HTTP status code (e.g., 400)
    console.log(err.code);    // Machine-readable code (e.g., "validation_error")
    console.log(err.message); // Human-readable description
  }
}

The SDK automatically retries on transient errors (408, 429, 500, 502, 503, 504) with exponential backoff. Default: 2 retries.

All Methods

TypeScript
// Organizations
listOrganizations(): Promise<Organization[]>

// API Keys
listApiKeys(params?): Promise<PaginatedResponse<ApiKey>>
createApiKey(name: string): Promise<ApiKey>
revokeApiKey(apiKeyId: string): Promise<{ ok: true }>

// Pods
listPods(params?): Promise<PaginatedResponse<Pod>>
getPod(podId: string): Promise<Pod>
createPod({ name, region }): Promise<Pod>
deletePod(podId: string): Promise<{ ok: true }>

// Inboxes
listInboxes(params?): Promise<PaginatedResponse<Inbox>>
getInbox(inboxId: string): Promise<Inbox>
createInbox({ address, displayName, podId }): Promise<Inbox>
updateInbox(inboxId, { displayName?, status? }): Promise<Inbox>
deleteInbox(inboxId: string): Promise<{ ok: true }>

// Messages
listMessages(params?): Promise<PaginatedResponse<Message>>
getMessage(messageId: string): Promise<Message>
sendMessage({ inboxId, subject, body, html?, from, to }): Promise<Message>

// Threads
listThreads(params?): Promise<PaginatedResponse<Thread>>
getThread(threadId: string): Promise<Thread>

// Domains
listDomains(params?): Promise<PaginatedResponse<Domain>>
getDomain(domainId: string): Promise<Domain>
createDomain(name: string): Promise<Domain>
deleteDomain(domainId: string): Promise<{ ok: true }>

// Contacts
listContacts(params?): Promise<PaginatedResponse<Contact>>
getContact(contactId: string): Promise<Contact>
createContact({ email, fullName, attributes?, segmentIds? }): Promise<Contact>
updateContact(contactId, { fullName?, email?, attributes?, segmentIds? }): Promise<Contact>
deleteContact(contactId: string): Promise<{ ok: true }>

// Templates
listTemplates(params?): Promise<PaginatedResponse<Template>>
getTemplate(templateId: string): Promise<Template>
createTemplate({ name, subject, html?, text?, body? }): Promise<Template>
updateTemplate(templateId, { name?, subject?, html?, text?, body? }): Promise<Template>
deleteTemplate(templateId: string): Promise<{ ok: true }>
previewTemplate(templateId, variables): Promise<TemplatePreview>

// Workflows
listWorkflows(params?): Promise<PaginatedResponse<WorkflowDefinition>>
getWorkflow(workflowId: string): Promise<WorkflowDefinition>
createWorkflow({ name, trigger, nodes, exitCriteria?, optOutMode? }): Promise<WorkflowDefinition>
updateWorkflow(workflowId, { name?, trigger?, nodes?, exitCriteria?, optOutMode? }): Promise<WorkflowDefinition>
deleteWorkflow(workflowId: string): Promise<{ ok: true }>
publishWorkflow(workflowId: string): Promise<WorkflowDefinition>
pauseWorkflow(workflowId: string): Promise<WorkflowDefinition>
resumeWorkflow(workflowId: string): Promise<WorkflowDefinition>
simulateWorkflow(workflowId, payload): Promise<WorkflowSimulationResponse>
testSendWorkflow(workflowId, { nodeId, to, contactId?, variables? }): Promise<{ subject, html, text?, to }>
getWorkflowAnalytics(workflowId: string): Promise<WorkflowAnalytics>
pauseNode(workflowId: string, nodeId: string): Promise<WorkflowDefinition>
resumeNode(workflowId: string, nodeId: string): Promise<WorkflowDefinition>

// Workflow Templates
listWorkflowTemplates(): Promise<WorkflowTemplate[]>
cloneFromTemplate(templateId: string, name?: string): Promise<WorkflowDefinition>

// Send Limits
listSendLimits(): Promise<SendLimit[]>
upsertSendLimit({ inboxId?, dailyLimit }): Promise<SendLimit>

// Enrollments
listEnrollments(params?): Promise<PaginatedResponse<Enrollment>>
getEnrollment(enrollmentId: string): Promise<Enrollment>
createEnrollment({ workflowId, contactId, variables? }): Promise<Enrollment>
bulkEnroll(workflowId: string, contactIds: string[]): Promise<{ results: BulkEnrollmentResult[] }>
listEnrollmentLogs(enrollmentId: string): Promise<ExecutionLog[]>

// Webhooks
listWebhookEndpoints(params?): Promise<PaginatedResponse<WebhookEndpoint>>
getWebhookEndpoint(endpointId: string): Promise<WebhookEndpoint>
createWebhookEndpoint({ url, subscribedEvents }): Promise<WebhookEndpoint>
updateWebhookEndpoint(endpointId, { url?, subscribedEvents? }): Promise<WebhookEndpoint>
deleteWebhookEndpoint(endpointId: string): Promise<{ ok: true }>
listWebhookDeliveries(params?): Promise<PaginatedResponse<WebhookDelivery>>
listEvents(params?): Promise<PaginatedResponse<WebhookEvent>>

// Metrics
getMetricsSummary(): Promise<UsageSummary>

// Billing
createCheckoutSession(tier: "pro"): Promise<CheckoutSession>

Type Re-exports

The SDK re-exports all types from @outreachagent/contracts, so you can import types directly:

TypeScript
import type {
  Message,
  Thread,
  Contact,
  WorkflowDefinition,
  PaginatedResponse
} from "@outreachagent/sdk-ts";

MCP Server

All SDK methods are also available as Model Context Protocol tools via the @outreachagent/mcp package. This lets AI agents in Cursor, Claude Desktop, and other MCP clients call OutreachAgent operations directly — no code integration required.

See the MCP Server guide for setup instructions.