import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs"; import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.mjs"; export type { Logger, LogLevel } from "./internal/utils/log.mjs"; import * as Opts from "./internal/request-options.mjs"; import * as Errors from "./core/error.mjs"; import * as Uploads from "./core/uploads.mjs"; import * as API from "./resources/index.mjs"; import { APIPromise } from "./core/api-promise.mjs"; import { Agent, AgentCreateParams, AgentCreateVersionParams, AgentCreateVersionResponse, AgentDeleteVersionParams, AgentGetVersionsResponse, AgentListParams, AgentListResponse, AgentListVersionsParams, AgentListVersionsResponse, AgentPublishParams, AgentResponse, AgentRetrieveParams, AgentUpdateParams } from "./resources/agent.mjs"; import { App, AppCreateParams, AppDeleteParams, AppListParams, AppListResponse, AppListUsagesParams, AppListUsagesResponse, AppResponse, AppTestAuthResponse, AppUpdateParams } from "./resources/app.mjs"; import { BatchCall, BatchCallCreateBatchCallParams, BatchCallResponse } from "./resources/batch-call.mjs"; import { Call, CallCreatePhoneCallParams, CallCreateWebCallParams, CallListParams, CallListResponse, CallRegisterPhoneCallParams, CallResponse, CallUpdateLiveParams, CallUpdateLiveResponse, CallUpdateParams, PhoneCallResponse, WebCallResponse } from "./resources/call.mjs"; import { Chat, ChatCreateChatCompletionParams, ChatCreateChatCompletionResponse, ChatCreateParams, ChatCreateSMSChatParams, ChatListParams, ChatListResponse, ChatResponse, ChatUpdateParams } from "./resources/chat.mjs"; import { ChatAgent, ChatAgentCreateParams, ChatAgentCreateVersionParams, ChatAgentCreateVersionResponse, ChatAgentDeleteVersionParams, ChatAgentGetVersionsResponse, ChatAgentListParams, ChatAgentListResponse, ChatAgentPublishParams, ChatAgentResponse, ChatAgentRetrieveParams, ChatAgentUpdateParams } from "./resources/chat-agent.mjs"; import { Concurrency, ConcurrencyRetrieveResponse } from "./resources/concurrency.mjs"; import { Contact, ContactBackfillAnalysisDataParams, ContactBackfillAnalysisDataResponse, ContactCreateParams, ContactGetBackfillJobStatusResponse, ContactListConversationsParams, ContactListConversationsResponse, ContactListParams, ContactListResponse, ContactResponse, ContactUpdateParams } from "./resources/contact.mjs"; import { ConversationFlow, ConversationFlowCreateParams, ConversationFlowDeleteParams, ConversationFlowListParams, ConversationFlowListResponse, ConversationFlowResponse, ConversationFlowRetrieveParams, ConversationFlowUpdateParams } from "./resources/conversation-flow.mjs"; import { ConversationFlowComponent, ConversationFlowComponentCreateParams, ConversationFlowComponentListParams, ConversationFlowComponentListResponse, ConversationFlowComponentResponse, ConversationFlowComponentUpdateParams } from "./resources/conversation-flow-component.mjs"; import { CRM, CRMConfig, CRMGetSchemaParams, CRMGetSchemaResponse, CRMGetSyncJobStatusResponse, CRMRunSyncJobResponse, CRMUpdateConfigParams } from "./resources/crm.mjs"; import { ExportRequest, ExportRequestListParams, ExportRequestListResponse } from "./resources/export-request.mjs"; import { Identity, IdentityRetrieveResponse } from "./resources/identity.mjs"; import { KnowledgeBase, KnowledgeBaseAddSourcesParams, KnowledgeBaseCreateParams, KnowledgeBaseDeleteSourceParams, KnowledgeBaseListResponse, KnowledgeBaseResponse } from "./resources/knowledge-base.mjs"; import { Llm, LlmCreateParams, LlmDeleteParams, LlmListParams, LlmListResponse, LlmResponse, LlmRetrieveParams, LlmUpdateParams } from "./resources/llm.mjs"; import { McpTool, McpToolDefinition, McpToolGetMcpToolsParams, McpToolGetMcpToolsResponse } from "./resources/mcp-tool.mjs"; import { PhoneNumber, PhoneNumberCreateParams, PhoneNumberImportParams, PhoneNumberListParams, PhoneNumberListResponse, PhoneNumberResponse, PhoneNumberUpdateParams } from "./resources/phone-number.mjs"; import { Playground, PlaygroundCompletionParams, PlaygroundCompletionResponse } from "./resources/playground.mjs"; import { BatchTestResponse, TestCaseDefinitionResponse, TestCaseJobResponse, TestCreateBatchTestParams, TestCreateTestCaseDefinitionParams, TestListBatchTestsParams, TestListBatchTestsResponse, TestListTestCaseDefinitionsParams, TestListTestCaseDefinitionsResponse, TestListTestRunsParams, TestListTestRunsResponse, TestUpdateTestCaseDefinitionParams, Tests } from "./resources/tests.mjs"; import { Voice, VoiceAddResourceParams, VoiceCloneParams, VoiceListResponse, VoiceResponse, VoiceSearchParams, VoiceSearchResponse } from "./resources/voice.mjs"; import { type Fetch } from "./internal/builtin-types.mjs"; import { HeadersLike, NullableHeaders } from "./internal/headers.mjs"; import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs"; import { type LogLevel, type Logger } from "./internal/utils/log.mjs"; export interface ClientOptions { /** * Defaults to process.env['RETELL_API_KEY']. */ apiKey?: string | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['RETELL_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * Additional `RequestInit` options to be passed to `fetch` calls. * Properties will be overridden by per-request `fetchOptions`. */ fetchOptions?: MergedRequestInit | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we expect that `fetch` is defined globally. */ fetch?: Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 2 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `null` in request options. */ defaultHeaders?: HeadersLike | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Record | undefined; /** * Set the log level. * * Defaults to process.env['RETELL_LOG'] or 'warn' if it isn't set. */ logLevel?: LogLevel | undefined; /** * Set the logger. * * Defaults to globalThis.console. */ logger?: Logger | undefined; } /** * API Client for interfacing with the Retell API. */ export declare class Retell { #private; apiKey: string; baseURL: string; maxRetries: number; timeout: number; logger: Logger; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; private fetch; protected idempotencyHeader?: string; private _options; /** * API Client for interfacing with the Retell API. * * @param {string | undefined} [opts.apiKey=process.env['RETELL_API_KEY'] ?? undefined] * @param {string} [opts.baseURL=process.env['RETELL_BASE_URL'] ?? https://api.retellai.com] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Record} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL, apiKey, ...opts }?: ClientOptions); /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this; protected defaultQuery(): Record | undefined; protected validateHeaders({ values, nulls }: NullableHeaders): void; protected authHeaders(opts: FinalRequestOptions): Promise; /** * Basic re-implementation of `qs.stringify` for primitive types. */ protected stringifyQuery(query: object | Record): string; private getUserAgent; protected defaultIdempotencyKey(): string; protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError; buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string; /** * Used as a callback for mutating the given `FinalRequestOptions` object. */ protected prepareOptions(options: FinalRequestOptions): Promise; /** * Used as a callback for mutating the given `RequestInit` object. * * This is useful for cases where you want to add certain headers based off of * the request properties, e.g. `method` or `url`. */ protected prepareRequest(request: RequestInit, { url, options }: { url: string; options: FinalRequestOptions; }): Promise; get(path: string, opts?: PromiseOrValue): APIPromise; post(path: string, opts?: PromiseOrValue): APIPromise; patch(path: string, opts?: PromiseOrValue): APIPromise; put(path: string, opts?: PromiseOrValue): APIPromise; delete(path: string, opts?: PromiseOrValue): APIPromise; private methodRequest; request(options: PromiseOrValue, remainingRetries?: number | null): APIPromise; private makeRequest; fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise; private shouldRetry; private retryRequest; private calculateDefaultRetryTimeoutMillis; buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: { retryCount?: number; }): Promise<{ req: FinalizedRequestInit; url: string; timeout: number; }>; private buildHeaders; private _makeAbort; private buildBody; static Retell: typeof Retell; static DEFAULT_TIMEOUT: number; static RetellError: typeof Errors.RetellError; static APIError: typeof Errors.APIError; static APIConnectionError: typeof Errors.APIConnectionError; static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError; static APIUserAbortError: typeof Errors.APIUserAbortError; static NotFoundError: typeof Errors.NotFoundError; static ConflictError: typeof Errors.ConflictError; static RateLimitError: typeof Errors.RateLimitError; static BadRequestError: typeof Errors.BadRequestError; static AuthenticationError: typeof Errors.AuthenticationError; static InternalServerError: typeof Errors.InternalServerError; static PermissionDeniedError: typeof Errors.PermissionDeniedError; static UnprocessableEntityError: typeof Errors.UnprocessableEntityError; static toFile: typeof Uploads.toFile; static verify: (body: string, apiKey: string, signature: string) => Promise; static sign: (body: string, apiKey: string) => Promise; call: API.Call; chat: API.Chat; phoneNumber: API.PhoneNumber; agent: API.Agent; chatAgent: API.ChatAgent; llm: API.Llm; conversationFlow: API.ConversationFlow; conversationFlowComponent: API.ConversationFlowComponent; knowledgeBase: API.KnowledgeBase; voice: API.Voice; concurrency: API.Concurrency; identity: API.Identity; exportRequest: API.ExportRequest; batchCall: API.BatchCall; tests: API.Tests; playground: API.Playground; mcpTool: API.McpTool; contact: API.Contact; app: API.App; crm: API.CRM; } export declare namespace Retell { export type RequestOptions = Opts.RequestOptions; export { Call as Call, type CallResponse as CallResponse, type PhoneCallResponse as PhoneCallResponse, type WebCallResponse as WebCallResponse, type CallListResponse as CallListResponse, type CallUpdateLiveResponse as CallUpdateLiveResponse, type CallUpdateParams as CallUpdateParams, type CallListParams as CallListParams, type CallCreatePhoneCallParams as CallCreatePhoneCallParams, type CallCreateWebCallParams as CallCreateWebCallParams, type CallRegisterPhoneCallParams as CallRegisterPhoneCallParams, type CallUpdateLiveParams as CallUpdateLiveParams, }; export { Chat as Chat, type ChatResponse as ChatResponse, type ChatListResponse as ChatListResponse, type ChatCreateChatCompletionResponse as ChatCreateChatCompletionResponse, type ChatCreateParams as ChatCreateParams, type ChatUpdateParams as ChatUpdateParams, type ChatListParams as ChatListParams, type ChatCreateChatCompletionParams as ChatCreateChatCompletionParams, type ChatCreateSMSChatParams as ChatCreateSMSChatParams, }; export { PhoneNumber as PhoneNumber, type PhoneNumberResponse as PhoneNumberResponse, type PhoneNumberListResponse as PhoneNumberListResponse, type PhoneNumberCreateParams as PhoneNumberCreateParams, type PhoneNumberUpdateParams as PhoneNumberUpdateParams, type PhoneNumberListParams as PhoneNumberListParams, type PhoneNumberImportParams as PhoneNumberImportParams, }; export { Agent as Agent, type AgentResponse as AgentResponse, type AgentListResponse as AgentListResponse, type AgentCreateVersionResponse as AgentCreateVersionResponse, type AgentGetVersionsResponse as AgentGetVersionsResponse, type AgentListVersionsResponse as AgentListVersionsResponse, type AgentCreateParams as AgentCreateParams, type AgentRetrieveParams as AgentRetrieveParams, type AgentUpdateParams as AgentUpdateParams, type AgentListParams as AgentListParams, type AgentCreateVersionParams as AgentCreateVersionParams, type AgentDeleteVersionParams as AgentDeleteVersionParams, type AgentListVersionsParams as AgentListVersionsParams, type AgentPublishParams as AgentPublishParams, }; export { ChatAgent as ChatAgent, type ChatAgentResponse as ChatAgentResponse, type ChatAgentListResponse as ChatAgentListResponse, type ChatAgentCreateVersionResponse as ChatAgentCreateVersionResponse, type ChatAgentGetVersionsResponse as ChatAgentGetVersionsResponse, type ChatAgentCreateParams as ChatAgentCreateParams, type ChatAgentRetrieveParams as ChatAgentRetrieveParams, type ChatAgentUpdateParams as ChatAgentUpdateParams, type ChatAgentListParams as ChatAgentListParams, type ChatAgentCreateVersionParams as ChatAgentCreateVersionParams, type ChatAgentDeleteVersionParams as ChatAgentDeleteVersionParams, type ChatAgentPublishParams as ChatAgentPublishParams, }; export { Llm as Llm, type LlmResponse as LlmResponse, type LlmListResponse as LlmListResponse, type LlmCreateParams as LlmCreateParams, type LlmRetrieveParams as LlmRetrieveParams, type LlmUpdateParams as LlmUpdateParams, type LlmListParams as LlmListParams, type LlmDeleteParams as LlmDeleteParams, }; export { ConversationFlow as ConversationFlow, type ConversationFlowResponse as ConversationFlowResponse, type ConversationFlowListResponse as ConversationFlowListResponse, type ConversationFlowCreateParams as ConversationFlowCreateParams, type ConversationFlowRetrieveParams as ConversationFlowRetrieveParams, type ConversationFlowUpdateParams as ConversationFlowUpdateParams, type ConversationFlowListParams as ConversationFlowListParams, type ConversationFlowDeleteParams as ConversationFlowDeleteParams, }; export { ConversationFlowComponent as ConversationFlowComponent, type ConversationFlowComponentResponse as ConversationFlowComponentResponse, type ConversationFlowComponentListResponse as ConversationFlowComponentListResponse, type ConversationFlowComponentCreateParams as ConversationFlowComponentCreateParams, type ConversationFlowComponentUpdateParams as ConversationFlowComponentUpdateParams, type ConversationFlowComponentListParams as ConversationFlowComponentListParams, }; export { KnowledgeBase as KnowledgeBase, type KnowledgeBaseResponse as KnowledgeBaseResponse, type KnowledgeBaseListResponse as KnowledgeBaseListResponse, type KnowledgeBaseCreateParams as KnowledgeBaseCreateParams, type KnowledgeBaseAddSourcesParams as KnowledgeBaseAddSourcesParams, type KnowledgeBaseDeleteSourceParams as KnowledgeBaseDeleteSourceParams, }; export { Voice as Voice, type VoiceResponse as VoiceResponse, type VoiceListResponse as VoiceListResponse, type VoiceSearchResponse as VoiceSearchResponse, type VoiceAddResourceParams as VoiceAddResourceParams, type VoiceCloneParams as VoiceCloneParams, type VoiceSearchParams as VoiceSearchParams, }; export { Concurrency as Concurrency, type ConcurrencyRetrieveResponse as ConcurrencyRetrieveResponse }; export { Identity as Identity, type IdentityRetrieveResponse as IdentityRetrieveResponse }; export { ExportRequest as ExportRequest, type ExportRequestListResponse as ExportRequestListResponse, type ExportRequestListParams as ExportRequestListParams, }; export { BatchCall as BatchCall, type BatchCallResponse as BatchCallResponse, type BatchCallCreateBatchCallParams as BatchCallCreateBatchCallParams, }; export { Tests as Tests, type BatchTestResponse as BatchTestResponse, type TestCaseDefinitionResponse as TestCaseDefinitionResponse, type TestCaseJobResponse as TestCaseJobResponse, type TestListBatchTestsResponse as TestListBatchTestsResponse, type TestListTestCaseDefinitionsResponse as TestListTestCaseDefinitionsResponse, type TestListTestRunsResponse as TestListTestRunsResponse, type TestCreateBatchTestParams as TestCreateBatchTestParams, type TestCreateTestCaseDefinitionParams as TestCreateTestCaseDefinitionParams, type TestListBatchTestsParams as TestListBatchTestsParams, type TestListTestCaseDefinitionsParams as TestListTestCaseDefinitionsParams, type TestListTestRunsParams as TestListTestRunsParams, type TestUpdateTestCaseDefinitionParams as TestUpdateTestCaseDefinitionParams, }; export { Playground as Playground, type PlaygroundCompletionResponse as PlaygroundCompletionResponse, type PlaygroundCompletionParams as PlaygroundCompletionParams, }; export { McpTool as McpTool, type McpToolDefinition as McpToolDefinition, type McpToolGetMcpToolsResponse as McpToolGetMcpToolsResponse, type McpToolGetMcpToolsParams as McpToolGetMcpToolsParams, }; export { Contact as Contact, type ContactResponse as ContactResponse, type ContactListResponse as ContactListResponse, type ContactBackfillAnalysisDataResponse as ContactBackfillAnalysisDataResponse, type ContactGetBackfillJobStatusResponse as ContactGetBackfillJobStatusResponse, type ContactListConversationsResponse as ContactListConversationsResponse, type ContactCreateParams as ContactCreateParams, type ContactUpdateParams as ContactUpdateParams, type ContactListParams as ContactListParams, type ContactBackfillAnalysisDataParams as ContactBackfillAnalysisDataParams, type ContactListConversationsParams as ContactListConversationsParams, }; export { App as App, type AppResponse as AppResponse, type AppListResponse as AppListResponse, type AppListUsagesResponse as AppListUsagesResponse, type AppTestAuthResponse as AppTestAuthResponse, type AppCreateParams as AppCreateParams, type AppUpdateParams as AppUpdateParams, type AppListParams as AppListParams, type AppDeleteParams as AppDeleteParams, type AppListUsagesParams as AppListUsagesParams, }; export { CRM as CRM, type CRMConfig as CRMConfig, type CRMGetSchemaResponse as CRMGetSchemaResponse, type CRMGetSyncJobStatusResponse as CRMGetSyncJobStatusResponse, type CRMRunSyncJobResponse as CRMRunSyncJobResponse, type CRMGetSchemaParams as CRMGetSchemaParams, type CRMUpdateConfigParams as CRMUpdateConfigParams, }; } //# sourceMappingURL=client.d.mts.map