UNPKG

@noobforal/openphone-api-sdk

Version:

Unofficial TypeScript SDK for OpenPhone Public API (AI-generated - use with caution)

1,358 lines (1,357 loc) 82.3 kB
/** * OpenPhone API SDK Client * * ⚠️ WARNING: This is NOT an official OpenPhone SDK. * This is an unofficial, community-created SDK. * * ⚠️ WARNING: This code was primarily generated by AI. * Please review thoroughly before using in production environments. * Use at your own risk. */ export interface OpenPhoneConfig { apiKey: string; baseUrl?: string; timeout?: number; } export declare class OpenPhoneClient { private client; private config; constructor(config: OpenPhoneConfig); listCalls(params: { phoneNumberId: string; userId?: string; participants: string[]; since?: string; createdAfter?: string; createdBefore?: string; maxResults: number; pageToken?: string; }): Promise<{ data: { data: { answeredAt: string | null; answeredBy: string | null; initiatedBy: string | null; direction: "incoming" | "outgoing"; status: "queued" | "initiated" | "ringing" | "in-progress" | "completed" | "busy" | "failed" | "no-answer" | "canceled" | "missed" | "answered" | "forwarded" | "abandoned"; completedAt: string | null; createdAt: string; duration: number; forwardedFrom: string | null; forwardedTo: string | null; id: string; phoneNumberId: string; participants: string[]; updatedAt: string | null; userId: string; }[]; totalItems: number; nextPageToken: string | null; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 200: { headers: { [name: string]: unknown; }; content: { "application/json": { data: { answeredAt: string | null; answeredBy: string | null; initiatedBy: string | null; direction: "incoming" | "outgoing"; status: "queued" | "initiated" | "ringing" | "in-progress" | "completed" | "busy" | "failed" | "no-answer" | "canceled" | "missed" | "answered" | "forwarded" | "abandoned"; completedAt: string | null; createdAt: string; duration: number; forwardedFrom: string | null; forwardedTo: string | null; id: string; phoneNumberId: string; participants: string[]; updatedAt: string | null; userId: string; }[]; totalItems: number; nextPageToken: string | null; }; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0101400"; status: 400; docs: "https://openphone.com/docs"; title: "Too Many Participants"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Too Many Participants"; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0100401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0101403"; status: 403; docs: "https://openphone.com/docs"; title: "Not Phone Number User"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Not Phone Number User"; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0100404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0101500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; getCall(callId: string): Promise<{ data: { data: { answeredAt: string | null; answeredBy: string | null; initiatedBy: string | null; direction: "incoming" | "outgoing"; status: "queued" | "initiated" | "ringing" | "in-progress" | "completed" | "busy" | "failed" | "no-answer" | "canceled" | "missed" | "answered" | "forwarded" | "abandoned"; completedAt: string | null; createdAt: string; duration: number; forwardedFrom: string | null; forwardedTo: string | null; id: string; phoneNumberId: string; participants: string[]; updatedAt: string | null; userId: string; }; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 200: { headers: { [name: string]: unknown; }; content: { "application/json": { data: { answeredAt: string | null; answeredBy: string | null; initiatedBy: string | null; direction: "incoming" | "outgoing"; status: "queued" | "initiated" | "ringing" | "in-progress" | "completed" | "busy" | "failed" | "no-answer" | "canceled" | "missed" | "answered" | "forwarded" | "abandoned"; completedAt: string | null; createdAt: string; duration: number; forwardedFrom: string | null; forwardedTo: string | null; id: string; phoneNumberId: string; participants: string[]; updatedAt: string | null; userId: string; }; }; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0101400"; status: 400; docs: "https://openphone.com/docs"; title: "Too Many Participants"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Too Many Participants"; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0100401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0101403"; status: 403; docs: "https://openphone.com/docs"; title: "Not Phone Number User"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Not Phone Number User"; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0100404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0101500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; listMessages(params: { phoneNumberId: string; userId?: string; participants: string[]; since?: string; createdAfter?: string; createdBefore?: string; maxResults: number; pageToken?: string; }): Promise<{ data: { data: { id: string; to: string[]; from: string; text: string; phoneNumberId: string | null; direction: "incoming" | "outgoing"; userId: string; status: "queued" | "sent" | "delivered" | "undelivered"; createdAt: string; updatedAt: string; }[]; totalItems: number; nextPageToken: string | null; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 200: { headers: { [name: string]: unknown; }; content: { "application/json": { data: { id: string; to: string[]; from: string; text: string; phoneNumberId: string | null; direction: "incoming" | "outgoing"; userId: string; status: "queued" | "sent" | "delivered" | "undelivered"; createdAt: string; updatedAt: string; }[]; totalItems: number; nextPageToken: string | null; }; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0206400"; status: 400; docs: "https://openphone.com/docs"; title: "A2P Registration Not Approved"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "A2P Registration Not Approved"; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 402: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200402"; status: 402; docs: "https://openphone.com/docs"; title: "Not Enough Credits"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "The organization does not have enough prepaid credits to send the message"; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0202403"; status: 403; docs: "https://openphone.com/docs"; title: "Not Phone Number User"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Not Phone Number User"; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0201500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; getMessage(messageId: string): Promise<{ data: { data: { id: string; to: string[]; from: string; text: string; phoneNumberId: string | null; direction: "incoming" | "outgoing"; userId: string; status: "queued" | "sent" | "delivered" | "undelivered"; createdAt: string; updatedAt: string; }; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 200: { headers: { [name: string]: unknown; }; content: { "application/json": { data: { id: string; to: string[]; from: string; text: string; phoneNumberId: string | null; direction: "incoming" | "outgoing"; userId: string; status: "queued" | "sent" | "delivered" | "undelivered"; createdAt: string; updatedAt: string; }; }; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0206400"; status: 400; docs: "https://openphone.com/docs"; title: "A2P Registration Not Approved"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "A2P Registration Not Approved"; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 402: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200402"; status: 402; docs: "https://openphone.com/docs"; title: "Not Enough Credits"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "The organization does not have enough prepaid credits to send the message"; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0202403"; status: 403; docs: "https://openphone.com/docs"; title: "Not Phone Number User"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Not Phone Number User"; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0201500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; sendMessage(params: { content: string; phoneNumberId?: string; from: string; to: string[]; userId?: string; setInboxStatus?: 'done'; }): Promise<{ data: { data: { id: string; to: string[]; from: string; text: string; phoneNumberId: string | null; direction: "incoming" | "outgoing"; userId: string; status: "queued" | "sent" | "delivered" | "undelivered"; createdAt: string; updatedAt: string; }; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 202: { headers: { [name: string]: unknown; }; content: { "application/json": { data: { id: string; to: string[]; from: string; text: string; phoneNumberId: string | null; direction: "incoming" | "outgoing"; userId: string; status: "queued" | "sent" | "delivered" | "undelivered"; createdAt: string; updatedAt: string; }; }; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0206400"; status: 400; docs: "https://openphone.com/docs"; title: "A2P Registration Not Approved"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "A2P Registration Not Approved"; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 402: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200402"; status: 402; docs: "https://openphone.com/docs"; title: "Not Enough Credits"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "The organization does not have enough prepaid credits to send the message"; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0202403"; status: 403; docs: "https://openphone.com/docs"; title: "Not Phone Number User"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Not Phone Number User"; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0200404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0201500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; listPhoneNumbers(params?: { userId?: string; }): Promise<{ data: { data: { id: string; groupId: string; createdAt: string; updatedAt: string; name: string; number: string; formattedNumber: string | null; forward: string | null; portRequestId: string | null; portingStatus: string | null; symbol: string | null; users: { email: string; firstName: string | null; groupId: string; id: string; lastName: string | null; role: string; }[]; restrictions: { messaging: { CA: "restricted" | "unrestricted"; US: "restricted" | "unrestricted"; Intl: "restricted" | "unrestricted"; }; calling: { CA: "restricted" | "unrestricted"; US: "restricted" | "unrestricted"; Intl: "restricted" | "unrestricted"; }; }; }[]; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 200: { headers: { [name: string]: unknown; }; content: { "application/json": import("./types").components["schemas"]["ListPhoneNumbersResponse"]; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0400400"; status: 400; docs: "https://openphone.com/docs"; title: "Bad Request"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0400401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0400403"; status: 403; docs: "https://openphone.com/docs"; title: "Forbidden"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0400404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0401500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; listWebhooks(params?: { userId?: string; }): Promise<{ data: { data: ({ id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: ("message.received" | "message.delivered")[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: ("call.completed" | "call.ringing" | "call.recording.completed")[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: "call.summary.completed"[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: "call.transcript.completed"[]; resourceIds: string[] | "*"[]; })[]; } | undefined; error: import("openapi-typescript-helpers").ErrorResponse<{ 200: { headers: { [name: string]: unknown; }; content: { "application/json": { data: ({ id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: ("message.received" | "message.delivered")[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: ("call.completed" | "call.ringing" | "call.recording.completed")[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: "call.summary.completed"[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: "call.transcript.completed"[]; resourceIds: string[] | "*"[]; })[]; }; }; }; 400: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0305400"; status: 400; docs: "https://openphone.com/docs"; title: "Invalid Version"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; description: "Invalid Version"; }; }; }; 401: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0300401"; status: 401; docs: "https://openphone.com/docs"; title: "Unauthorized"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 403: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0300403"; status: 403; docs: "https://openphone.com/docs"; title: "Forbidden"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 404: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0300404"; status: 404; docs: "https://openphone.com/docs"; title: "Not Found"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; 500: { headers: { [name: string]: unknown; }; content: { "application/json": { message: string; code: "0301500"; status: 500; docs: "https://openphone.com/docs"; title: "Unknown"; trace?: string; errors?: { path: string; message: string; value?: unknown; schema: { type: string; }; }[]; }; }; }; }, `${string}/${string}`> | undefined; response: Response; }>; getWebhook(webhookId: string): Promise<{ data: { data: { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string; createdAt: string; updatedAt: string; deletedAt: string | null; events: ("message.received" | "message.delivered")[]; resourceIds: string[] | "*"[]; } | { id: string; userId: string; orgId: string; label: string | null; status: "enabled" | "disabled"; url: string; key: string;