### get usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SessionsClient.md Example of retrieving a session by its ID. Requires a VapiClient initialized with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const session = await client.sessions.get({ id: "session-id" }); ``` -------------------------------- ### get usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/FilesClient.md Example of retrieving a file by its ID using the VapiClient. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const file = await client.files.get({ id: "file-id" }); ``` -------------------------------- ### get usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of using the get method to retrieve a chat by ID. Requires a VapiClient instance with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const chat = await client.chats.get({ id: "chat-id" }); ``` -------------------------------- ### get usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SquadsClient.md Example of fetching a squad by its ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const squad = await client.squads.get({ id: "squad-id" }); ``` -------------------------------- ### create usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SessionsClient.md Example of creating a session with an assistantId and customer number. Requires a VapiClient initialized with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const session = await client.sessions.create({ assistantId: "assistant-id", customer: { number: "+14155550100" }, }); ``` -------------------------------- ### Install Vapi SDK with npm Source: https://github.com/vapiai/server-sdk-typescript/blob/main/README.md Install the @vapi-ai/server-sdk package using npm. ```sh npm i -s @vapi-ai/server-sdk ``` -------------------------------- ### create usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SquadsClient.md Example of creating a squad with a name and ordered list of assistant members. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const squad = await client.squads.create({ name: "Front Desk", members: [ { assistantId: "receptionist-id" }, { assistantId: "sales-id" }, ], }); console.log(squad.id); ``` -------------------------------- ### create usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of creating a chat with an assistant ID and input text, then logging the output. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const chat = await client.chats.create({ assistantId: "assistant-id", input: "Book me a table for two at 7pm", }); console.log(chat.output); ``` -------------------------------- ### get usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/CallsClient.md Example of using the get method to retrieve a call by ID and log its status, ended reason, and message count. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const call = await client.calls.get({ id: "call-id" }); console.log(call.status, call.endedReason, call.messages?.length); ``` -------------------------------- ### Usage example for HttpResponsePromise Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/core.md Shows how to use VapiClient to get a call, either accessing the parsed body directly or using withRawResponse() to access the raw response. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); // default: parsed body const call = await client.calls.get({ id: "call-id" }); console.log(call.status, call.cost); // raw access: status, headers, url const { data, rawResponse } = await client.calls.get({ id: "call-id" }).withRawResponse(); console.log(rawResponse.status, rawResponse.headers.get("x-ratelimit-remaining")); ``` -------------------------------- ### Usage example for boardControllerFindAll Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/BoardClient.md Example of using the board client to fetch the first page of boards with a limit of 20. Requires a VapiClient instance with a valid token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const page = await client.board.boardControllerFindAll({ page: 1, limit: 20 }); ``` -------------------------------- ### Usage example for simulationRunControllerGenerateSuggestions Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationRunsClient.md Example showing how to call the generate suggestions method using the VapiClient. It imports VapiClient, creates a client with a token, and awaits the method with a request containing id and itemId. After the call, it logs a message to the console. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.simulationRuns.simulationRunControllerGenerateSuggestions({ id: "run-id", itemId: "run-item-id", }); console.log("Suggestions generation started"); ``` -------------------------------- ### simulationControllerCreate usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationsClient.md Example of creating a simulation using the VapiClient. Requires a valid token and scenarioId/personalityId. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const simulation = await client.simulations.simulationControllerCreate({ scenarioId: "scenario-id", personalityId: "personality-id", }); ``` -------------------------------- ### Run structured output usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/StructuredOutputsClient.md Example of running a structured output against call IDs using the VapiClient. Requires a valid token and structured-output ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const run = await client.structuredOutputs.structuredOutputControllerRun({ structuredOutputId: "structured-output-id", calls: ["call-id-1", "call-id-2"], }); console.log(run); ``` -------------------------------- ### update usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/FilesClient.md Example of renaming a file by its ID using the VapiClient. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const renamed = await client.files.update({ id: "file-id", name: "terms-2024.pdf" }); ``` -------------------------------- ### list usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SquadsClient.md Example of listing squads with a limit filter. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const squads = await client.squads.list({ limit: 20 }); ``` -------------------------------- ### create multi-turn continuation example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of creating a chat with `previousChatId` to continue a conversation. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const first = await client.chats.create({ assistantId: "assistant-id", input: "Hi!" }); const second = await client.chats.create({ assistantId: "assistant-id", previousChatId: first.id, input: "Actually, make it 8pm.", }); ``` -------------------------------- ### scorecardControllerCreate usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ObservabilityScorecardClient.md Example of creating a scorecard with metrics and assistant links, then logging the new scorecard's ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const scorecard = await client.observabilityScorecard.scorecardControllerCreate({ name: "Support Quality", assistantIds: ["assistant-id"], metrics: [ { name: "Call duration", conditions: [{ comparator: "lte", value: 600 }], }, ], }); console.log(scorecard.id); ``` -------------------------------- ### simulationControllerGetConcurrency usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationsClient.md Example of retrieving concurrency information and logging the limit, active count, and available slots. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const c = await client.simulations.simulationControllerGetConcurrency(); console.log(c.limit, c.active, c.available); ``` -------------------------------- ### trafficAllocationControllerCreate usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/TrafficAllocationsClient.md Example of creating a traffic allocation rule using the VapiClient. Requires a valid token and a request object with name, allocationIntent, and target. Logs the created allocation's id. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const allocation = await client.trafficAllocations.trafficAllocationControllerCreate({ name: "Sales vs Support", allocationIntent: "intent-bucket", target: { type: "assistant", assistantId: "sales-assistant-id" }, }); console.log(allocation.id); ``` -------------------------------- ### Create personality example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationPersonalitiesAndScenariosClient.md Example of creating a personality using the VapiClient. Requires a valid token and a CreatePersonalityDto with name and systemPrompt. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const personality = await client.simulationPersonalities.personalityControllerCreate({ name: "Busy parent", systemPrompt: "You are a busy parent with limited patience...", communicationStyle: "brief", }); ``` -------------------------------- ### list usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of using `client.chats.list` to fetch a page of chats with a limit of 25. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const page = await client.chats.list({ limit: 25 }); ``` -------------------------------- ### Usage example for knowledgeBaseV2ControllerUpdate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/KnowledgeBasesV2Client.md Example of updating a knowledge base using the VapiClient. Requires a valid token and knowledge base ID. Catches VapiError to log status and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { const kb = await client.knowledgeBasesV2.knowledgeBaseV2ControllerUpdate({ id: "kb-id", name: "Product Docs (rev 2)", }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode}`, err.body); } } ``` -------------------------------- ### Install dependencies with pnpm Source: https://github.com/vapiai/server-sdk-typescript/blob/main/CONTRIBUTING.md Installs the project dependencies using the pnpm package manager. Requires Node.js 20 or higher and pnpm. ```bash pnpm install ``` -------------------------------- ### Usage example for simulationSuiteControllerUpdate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationSuitesClient.md Example of updating a simulation suite by id with a new name. Catches VapiError and logs the status code and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.simulationSuites.simulationSuiteControllerUpdate({ id: "suite-id", name: "Pre-release regression (extended)", }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode} body=${JSON.stringify(err.body)}`); } } ``` -------------------------------- ### Usage example for client.tools.list Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ToolsClient.md Shows how to instantiate `VapiClient` and call `client.tools.list` with a limit, then iterate over the returned tools to log their id, type, and name. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const tools = await client.tools.list({ limit: 100 }); for (const tool of tools) { console.log(tool.id, tool.type, tool.name); } ``` -------------------------------- ### createResponse usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of using the createResponse method to run a chat with an OpenAI Responses-API-compatible request. Requires a VapiClient instance with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const response = await client.chats.createResponse({ assistantId: "assistant-id", input: [{ role: "user", content: [{ type: "input_text", text: "Hello" }] }], }); ``` -------------------------------- ### Usage example for list Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/AssistantsClient.md Shows how to instantiate VapiClient and call client.assistants.list with a limit of 10, then log the id and name of each assistant. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const assistants = await client.assistants.list({ limit: 10 }); console.log(assistants.map((a) => ({ id: a.id, name: a.name }))); ``` -------------------------------- ### get error handling example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/CallsClient.md Example of handling errors when calling get with a non-existent call ID. Catches VapiError and logs the status code and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.calls.get({ id: "missing-call" }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode} body=${JSON.stringify(err.body)}`); } } ``` -------------------------------- ### Usage example for providerResourceControllerUpdateProviderResource Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ProviderResourcesClient.md Example showing how to update a provider resource using the VapiClient. It imports VapiClient and VapiError, creates a client with a token, and calls the update method with provider, resourceName, id, and name. Errors are caught and logged with status code and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.providerResources.providerResourceControllerUpdateProviderResource({ provider: "elevenlabs", resourceName: "pronunciation-dictionary", id: "vapi-resource-id", name: "Brand terms v2", }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode}`, err.body); } } ``` -------------------------------- ### simulationSuiteControllerDuplicate usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationSuitesClient.md Example of duplicating a simulation suite using the VapiClient. Requires a valid token. Catches Vapi.NotFoundError and Vapi.ConflictError to handle missing suite and naming conflicts respectively. ```typescript import { VapiClient, Vapi } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { const copy = await client.simulationSuites.simulationSuiteControllerDuplicate({ id: "suite-id" }); console.log("Duplicated as", copy.id); } catch (err) { if (err instanceof Vapi.NotFoundError) { console.error("Suite not found"); } else if (err instanceof Vapi.ConflictError) { console.error("Duplicate name conflict:", err.body); } } ``` -------------------------------- ### Update assistant usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/AssistantsClient.md Example of updating an assistant with a new first message and maximum duration. Requires a valid assistant ID and a client token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const updated = await client.assistants.update({ id: "assistant-id", firstMessage: "Thanks for calling Vapi support — how can I help?", maxDurationSeconds: 900, }); ``` -------------------------------- ### Usage: knowledgeBaseV2ControllerCreate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/KnowledgeBasesV2Client.md Example of creating a knowledge base with the name 'Product Docs'. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const kb = await client.knowledgeBasesV2.knowledgeBaseV2ControllerCreate({ name: "Product Docs", }); ``` -------------------------------- ### Get a tool by ID with client.tools.get() Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Returns the tool identified by its ID. The example passes an id parameter. ```typescript await client.tools.get({ id: "id" }); ``` -------------------------------- ### Usage example for knowledgeBaseV2ControllerFileAttach Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/KnowledgeBasesV2Client.md Shows how to attach a file to a knowledge base using the VapiClient. Requires a valid token and knowledge base ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.knowledgeBasesV2.knowledgeBaseV2ControllerFileAttach({ id: "kb-id", fileId: "file-id", }); ``` -------------------------------- ### Get provider resource with providerResourceControllerGetProviderResource Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ProviderResourcesClient.md Retrieves a provider resource by its Vapi resource ID via GET /provider/{provider}/{resourceName}/{id}. Throws Vapi.NotFoundError (404) if the resource does not exist. The example shows catching the error and logging its body. ```typescript public providerResourceControllerGetProviderResource( request: Vapi.ProviderResourceControllerGetProviderResourceRequest, requestOptions?: ProviderResourcesClient.RequestOptions, ): core.HttpResponsePromise ``` ```typescript import { VapiClient, Vapi } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { const resource = await client.providerResources.providerResourceControllerGetProviderResource({ provider: "cartesia", resourceName: "pronunciation-dictionary", id: "vapi-resource-id", }); } catch (err) { if (err instanceof Vapi.NotFoundError) { console.error("Resource not found:", err.body); } } ``` -------------------------------- ### trafficAllocationControllerLatestGet usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/TrafficAllocationsClient.md Example of retrieving the latest traffic allocations using the VapiClient. Requires a valid token. The request object can include optional filters actorType and allocationIntent. Logs the returned latest allocations. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const latest = await client.trafficAllocations.trafficAllocationControllerLatestGet({}); console.log(latest); ``` -------------------------------- ### simulationControllerGetConcurrency Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationsClient.md Returns the organization's simulation concurrency limit, the number of active simulations, and how many more can start. Sends a GET request to /eval/simulation/concurrency. ```APIDOC ## GET /eval/simulation/concurrency ### Description Returns the organization's simulation concurrency limit, the number of active simulations, and how many more can start. ### Method GET ### Endpoint /eval/simulation/concurrency ### Parameters None ### Response #### Success Response (200) - **limit** (number) - The concurrency limit. - **active** (number) - The number of active simulations. - **available** (number) - How many more simulations can start. #### Response Example ```json { "limit": 10, "active": 3, "available": 7 } ``` ``` -------------------------------- ### delete usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SquadsClient.md Example of deleting a squad by its ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.squads.delete({ id: "squad-id" }); ``` -------------------------------- ### Usage example for client.sessions.list Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SessionsClient.md Shows how to instantiate VapiClient and call sessions.list with an assistantId and limit, then log pagination metadata and result count. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const page = await client.sessions.list({ assistantId: "assistant-id", limit: 50 }); console.log(page.metadata?.totalCount, page.results.length); ``` -------------------------------- ### scorecardControllerGetPaginated usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ObservabilityScorecardClient.md Example of fetching the first page of scorecards. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const page = await client.observabilityScorecard.scorecardControllerGetPaginated({ page: 1 }); ``` -------------------------------- ### get Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ToolsClient.md Retrieves a tool by its ID. Corresponds to GET /tool/{id}. ```APIDOC ## GET /tool/{id} ### Description Returns the tool identified by its ID. ### Method GET ### Endpoint /tool/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the tool to retrieve. ### Request Example ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const tool = await client.tools.get({ id: "tool-id" }); ``` ### Response #### Success Response (200) Returns the entity variant matching the tool's `type`. ``` -------------------------------- ### Usage example for simulationRunControllerCreate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationRunsClient.md Shows how to create a simulation run with a target assistant and a list of simulations. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const run = await client.simulationRuns.simulationRunControllerCreate({ target: { assistantId: "assistant-id" }, simulations: [{ scenarioId: "scenario-id", personalityId: "personality-id" }], name: "Weekly regression", }); ``` -------------------------------- ### update usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SquadsClient.md Example of updating a squad's name and members. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const updated = await client.squads.update({ id: "squad-id", name: "Front Desk v2", members: [ { assistantId: "receptionist-id" }, { assistantId: "support-id" }, { assistantId: "sales-id" }, ], }); ``` -------------------------------- ### Create assistant with client.assistants.create() Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Creates a reusable assistant configuration containing the model, voice, transcriber, tools, prompts, and call behavior. ```typescript await client.assistants.create({}); ``` -------------------------------- ### Build the project Source: https://github.com/vapiai/server-sdk-typescript/blob/main/CONTRIBUTING.md Builds the project using the pnpm build script. ```bash pnpm build ``` -------------------------------- ### delete usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/FilesClient.md Example of deleting a file by its ID using the VapiClient. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.files.delete({ id: "file-id" }); ``` -------------------------------- ### scorecardControllerGet usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ObservabilityScorecardClient.md Example of retrieving a scorecard by its ID using the VapiClient. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const scorecard = await client.observabilityScorecard.scorecardControllerGet({ id: "scorecard-id" }); ``` -------------------------------- ### Create a knowledge base (knowledgeBaseV2ControllerCreate) Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Creates a new knowledge base with the provided name. ```typescript await client.knowledgeBasesV2.knowledgeBaseV2ControllerCreate({ name: "name" }); ``` -------------------------------- ### get method signature Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SquadsClient.md Signature for the get method that returns a squad by its ID. ```typescript public get( request: Vapi.GetSquadsRequest, requestOptions?: SquadsClient.RequestOptions, ): core.HttpResponsePromise ``` -------------------------------- ### Instantiate VapiClient and create a call Source: https://github.com/vapiai/server-sdk-typescript/blob/main/README.md Import VapiClient, instantiate with a token, and create a call. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "YOUR_TOKEN" }); await client.calls.create(); ``` -------------------------------- ### Create squad with client.squads.create() Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Creates a squad that coordinates multiple assistants and their handoffs during a conversation. Accepts Vapi.CreateSquadDto and SquadsClient.RequestOptions. ```typescript await client.squads.create({ members: [{}] }); ``` -------------------------------- ### get Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SessionsClient.md Retrieves a session by its ID. Sends a GET request to /session/{id}. ```APIDOC ## GET /session/{id} ### Description Returns the session identified by its ID. ### Method GET ### Endpoint /session/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the session to retrieve. ### Request Example ```json { "id": "session-id" } ``` ### Response #### Success Response (200) Returns a `Vapi.Session` object. #### Response Example ```json { "id": "session-id", "assistantId": "assistant-id" } ``` ``` -------------------------------- ### get Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Retrieves a chat by its ID. Sends a GET request to /chat/{id}. ```APIDOC ## GET /chat/{id} ### Description Returns the chat identified by its ID. ### Method GET ### Endpoint /chat/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the chat to retrieve. ### Request Example ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const chat = await client.chats.get({ id: "chat-id" }); ``` ### Response #### Success Response (200) - **Chat** (Vapi.Chat) - The chat object. #### Response Example ```json { "id": "chat-id", "messages": [] } ``` ``` -------------------------------- ### Usage example for insightControllerRun Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/InsightClient.md Shows how to instantiate the VapiClient and call `insight.insightControllerRun` with an insight ID. The response is logged to the console. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const run = await client.insight.insightControllerRun({ id: "insight-id" }); console.log(run); ``` -------------------------------- ### scorecardControllerUpdate usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ObservabilityScorecardClient.md Example of updating a scorecard's name using the VapiClient. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.observabilityScorecard.scorecardControllerUpdate({ id: "scorecard-id", name: "Quality v2", }); ``` -------------------------------- ### BaseClientOptions Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/BaseClient.md Options for initializing the Vapi client or any resource client. Includes authentication token, environment, base URL, headers, timeout, retries, fetch implementation, logging, and auth provider. ```APIDOC ## BaseClientOptions ### Description Options for initializing the Vapi client or any resource client. All clients accept the same `Options` type (`BaseClientOptions`). ### Type ```typescript export type BaseClientOptions = { environment?: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; /** Additional headers to include in requests. */ headers?: Record | null | undefined>; /** The default maximum time to wait for a response in seconds. */ timeoutInSeconds?: number; /** The default number of times to retry the request. Defaults to 2. */ maxRetries?: number; /** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */ fetch?: typeof fetch; fetcher?: core.FetchFunction; /** Configure logging for the client. */ logging?: core.logging.LogConfig | core.logging.Logger; } & BearerAuthProvider.AuthOptions; ``` ### Fields | Key | Type | Required | Default | Description | |-----|------|----------|---------|-------------| | `token` | `core.Supplier` | yes (unless `authProvider` given) | — | Bearer token; sent as `Authorization: Bearer `. If missing at request time and no other auth provider is configured, requests throw `VapiError` with message `Please provide 'token' when initializing the client` | | `environment` | `core.Supplier` | no | `VapiEnvironment.Default` (`"https://api.vapi.ai"`) | Base API environment | | `baseUrl` | `core.Supplier` | no | — | Custom base URL; takes precedence over `environment` | | `headers` | `Record \| null \| undefined>` | no | SDK default headers (see below) | Additional request headers; `null`/`undefined` values delete an existing header | | `timeoutInSeconds` | `number` | no | `60` | Default per-request timeout. The fetcher computes `timeoutMs = (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000` | | `maxRetries` | `number` | no | `2` | Default retry count (see [core.md](core.md) retry semantics) | | `fetch` | `typeof fetch` | no | global `fetch` | Custom fetch implementation | | `fetcher` | `core.FetchFunction` | no | `core.fetcher` | Full custom fetcher; overrides `fetch` | | `logging` | `core.logging.LogConfig \| core.logging.Logger` | no | silent logger | Debug/error HTTP logging | | `authProvider` | `core.AuthProvider` (via the `&` intersection in derived types) | no | `BearerAuthProvider` | Custom auth provider returning `AuthRequest` headers | ### Default Headers SDK default headers merged by `normalizeClientOptions` (`src/BaseClient.ts`): ```typescript const headers = mergeHeaders( { "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@vapi-ai/server-sdk", "X-Fern-SDK-Version": "3.0.0", "User-Agent": "@vapi-ai/server-sdk/3.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, }, options?.headers, ); ``` ``` -------------------------------- ### Usage example for simulationRunControllerFindAll Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationRunsClient.md Shows how to instantiate VapiClient and call simulationRunControllerFindAll with a page parameter. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const page = await client.simulationRuns.simulationRunControllerFindAll({ page: 1 }); ``` -------------------------------- ### Usage example for simulationControllerFindAll Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationsClient.md Example of listing simulations with a limit of 50 using the `simulationControllerFindAll` method. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const simulations = await client.simulations.simulationControllerFindAll({ limit: 50 }); ``` -------------------------------- ### delete usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SessionsClient.md Example of deleting a session by its ID. Requires a VapiClient initialized with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.sessions.delete({ id: "session-id" }); ``` -------------------------------- ### Create a tool with client.tools.create() Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Creates a reusable tool that assistants can invoke during conversations. The example creates an apiRequest tool with method POST and url 'url'. ```typescript await client.tools.create({ type: "apiRequest", method: "POST", url: "url" }); ``` -------------------------------- ### Usage: simulationSuiteControllerCreate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationSuitesClient.md Example of creating a simulation suite with a name, simulations, and target assignments. Requires a VapiClient instance with a valid token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const suite = await client.simulationSuites.simulationSuiteControllerCreate({ name: "Pre-release regression", simulations: [{ scenarioId: "scenario-id", personalityId: "personality-id" }], targetAssignments: [{ targetType: "assistant", targetId: "assistant-id" }], }); ``` -------------------------------- ### List files usage Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/FilesClient.md Creates a VapiClient and lists files with a limit of 20. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const files = await client.files.list({ limit: 20 }); ``` -------------------------------- ### Basic analytics query with VapiClient Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/AnalyticsClient.md Creates a VapiClient and calls `client.analytics.get` with a single query to sum the cost of calls. Logs the first result. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const results = await client.analytics.get({ queries: [{ table: "call", name: "Total cost", operations: [{ operation: "sum", column: "cost" }], }], }); console.log(results[0]?.result); ``` -------------------------------- ### Usage example for simulationGenerateControllerGenerate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationsClient.md Example of generating scenario suggestions using the `simulationGenerateControllerGenerate` method with a target assistant ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const gen = await client.simulations.simulationGenerateControllerGenerate({ target: { assistantId: "assistant-id" }, }); console.log(gen.scenarios); ``` -------------------------------- ### Error handling example for scorecardControllerGet Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ObservabilityScorecardClient.md Example of catching VapiError when a scorecard is not found, logging status code and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.observabilityScorecard.scorecardControllerGet({ id: "missing" }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode} body=${JSON.stringify(err.body)}`); } } ``` -------------------------------- ### Usage example for simulationControllerUpdate Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationsClient.md Shows how to update a simulation using the VapiClient. Requires a valid token and simulation ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.simulations.simulationControllerUpdate({ id: "simulation-id", personalityId: "new-personality-id", }); ``` -------------------------------- ### get method signature Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/FilesClient.md Signature for the get method. It takes a Vapi.GetFilesRequest (containing id) and returns a promise of Vapi.File_. ```typescript public get( request: Vapi.GetFilesRequest, requestOptions?: FilesClient.RequestOptions, ): core.HttpResponsePromise ``` -------------------------------- ### Basic VapiClient construction with static token Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/BaseClient.md Basic construction of the VapiClient with a static token from an environment variable, a 30-second timeout, and 3 retries. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: process.env.VAPI_TOKEN, timeoutInSeconds: 30, maxRetries: 3, }); ``` -------------------------------- ### get Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/CallsClient.md Retrieves a call by its ID. This method sends a GET request to /call/{id} and returns the call details. ```APIDOC ## GET /call/{id} ### Description Returns the call identified by its ID. ### Method GET ### Endpoint /call/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the call to retrieve. ### Request Example ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const call = await client.calls.get({ id: "call-id" }); console.log(call.status, call.endedReason, call.messages?.length); ``` ### Response #### Success Response (200) - **status** (string) - The status of the call. - **endedReason** (string) - The reason the call ended. - **messages** (array) - Optional - The messages associated with the call. #### Response Example ```typescript { "status": "completed", "endedReason": "customer-ended-call", "messages": [] } ``` ### Error Handling If the call is not found, a `VapiError` is thrown with the status code and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.calls.get({ id: "missing-call" }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode} body=${JSON.stringify(err.body)}`); } } ``` ``` -------------------------------- ### Basic VapiClient configuration with environment and retries Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/configuration.md Creates a VapiClient with a static token from an environment variable, sets the production environment, a 30-second timeout, and 3 max retries. The token is read by your code from process.env.VAPI_TOKEN. ```typescript import { VapiClient, VapiEnvironment } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: process.env.VAPI_TOKEN, // env vars are read by YOUR code environment: VapiEnvironment.Default, timeoutInSeconds: 30, maxRetries: 3, }); ``` -------------------------------- ### Get assistant by ID Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/AssistantsClient.md Sends a GET request to /assistant/{id} to retrieve the assistant identified by the given ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const assistant = await client.assistants.get({ id: "assistant-id" }); ``` -------------------------------- ### Delete personality example with error handling Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SimulationPersonalitiesAndScenariosClient.md Example of deleting a personality and handling a ConflictError (409) when the personality is in use by a simulation. ```typescript import { VapiClient, Vapi } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.simulationPersonalities.personalityControllerRemove({ id: "personality-id" }); } catch (err) { if (err instanceof Vapi.ConflictError) { console.error("Personality still in use:", err.body); } } ``` -------------------------------- ### Usage example for providerResourceControllerGetProviderResourcesPaginated Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ProviderResourcesClient.md Shows how to instantiate VapiClient and call the paginated method with provider 'elevenlabs' and resourceName 'pronunciation-dictionary'. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const page = await client.providerResources.providerResourceControllerGetProviderResourcesPaginated({ provider: "elevenlabs", resourceName: "pronunciation-dictionary", page: 1, }); ``` -------------------------------- ### Usage example for knowledgeBaseV2ControllerFileRetry Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/KnowledgeBasesV2Client.md Shows how to retry file processing with error handling. Requires a valid token and knowledge base ID. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.knowledgeBasesV2.knowledgeBaseV2ControllerFileRetry({ id: "kb-id", fileId: "file-id", }); } catch (err) { console.error(err); } ``` -------------------------------- ### boardControllerUpdate usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/BoardClient.md Example of updating a board's name using the VapiClient. The id is required; name is optional. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const updated = await client.board.boardControllerUpdate({ id: "board-id", name: "Weekly Ops (Updated)", }); ``` -------------------------------- ### client.sessions.create Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Creates a new session. ```APIDOC ## client.sessions.create({ ...params }) -> Vapi.Session ### Description Creates a new session. ### Method create ### Endpoint client.sessions.create ### Parameters #### Request - **request** (`Vapi.CreateSessionDto`) - Optional - The session creation data. - **requestOptions** (`SessionsClient.RequestOptions`) - Optional - Additional request options. ### Request Example ```typescript await client.sessions.create(); ``` ### Response Returns a `Vapi.Session`. ``` -------------------------------- ### createResponse error handling example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of error handling for createResponse. Catches VapiError and logs the status code and body. ```typescript import { VapiClient, VapiError } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); try { await client.chats.createResponse({ assistantId: "missing", input: "hi" }); } catch (err) { if (err instanceof VapiError) { console.error(`status=${err.statusCode} body=${JSON.stringify(err.body)}`); } } ``` -------------------------------- ### new VapiClient(options) Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/BaseClient.md Constructs a new VapiClient instance with configuration options such as token, timeout, max retries, base URL, and custom headers. ```APIDOC ## new VapiClient(options) ### Description Creates a new VapiClient instance for interacting with the Vapi API. The constructor accepts options for authentication, timeout, retries, base URL, and custom headers. ### Constructor `new VapiClient(options: VapiClientOptions)` ### Parameters - **token** (string | Supplier) - Required - Static token or a supplier function that returns a token. - **timeoutInSeconds** (number) - Optional - Default timeout for requests in seconds. - **maxRetries** (number) - Optional - Maximum number of retries for failed requests. - **baseUrl** (string) - Optional - Custom base URL for the API. - **headers** (Record) - Optional - Custom headers to include in all requests. ### Example ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: process.env.VAPI_TOKEN, timeoutInSeconds: 30, maxRetries: 3, }); ``` ### Errors - Throws `VapiError` if token is missing when initializing the client. ``` -------------------------------- ### delete usage example Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Example of using the delete method to delete a chat by ID. Requires a VapiClient instance with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); await client.chats.delete({ id: "chat-id" }); ``` -------------------------------- ### get method signature Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/SessionsClient.md Signature for the get method. It requires a Vapi.GetSessionsRequest containing the session id, and returns an HttpResponsePromise of Vapi.Session. ```typescript public get( request: Vapi.GetSessionsRequest, requestOptions?: SessionsClient.RequestOptions, ): core.HttpResponsePromise ``` -------------------------------- ### Create assistant with VapiClient Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/AssistantsClient.md Creates a new assistant with a name, OpenAI model, 11labs voice, and a first message. Requires a VapiClient initialized with a token. ```typescript import { VapiClient } from "@vapi-ai/server-sdk"; const client = new VapiClient({ token: "TOKEN" }); const assistant = await client.assistants.create({ name: "Support Bot", model: { provider: "openai", model: "gpt-4o-mini", messages: [{ role: "system", content: "You are a helpful support agent." }], }, voice: { provider: "11labs", voiceId: "aBcdEf..." }, firstMessage: "Hi! How can I help you today?", }); ``` -------------------------------- ### get method signature Source: https://github.com/vapiai/server-sdk-typescript/blob/main/_autodocs/api-reference/ChatsClient.md Signature for the get method. It takes a Vapi.GetChatsRequest and returns a promise of Vapi.Chat. The request is { id: string }. ```typescript public get( request: Vapi.GetChatsRequest, requestOptions?: ChatsClient.RequestOptions, ): core.HttpResponsePromise ``` -------------------------------- ### Create a simulation suite Source: https://github.com/vapiai/server-sdk-typescript/blob/main/reference.md Creates a simulation suite, a group of simulations that run together. Requires a name and an array of simulation IDs. ```typescript await client.simulationSuites.simulationSuiteControllerCreate({ name: "Checkout Flow Tests", simulationIds: ["simulationIds"] }); ```