diff --git a/fern/docs.yml b/fern/docs.yml index ba8ce4c29e..b6eb12d578 100644 --- a/fern/docs.yml +++ b/fern/docs.yml @@ -496,12 +496,26 @@ redirects: - source: /docs/browser-sdk/click-to-call/:slug* destination: /docs/browser-sdk/v3/click-to-call/:slug* + # The TypeScript SDK removed the Twilio-compatible LAML REST namespace + # (client.compat); point its old reference pages at the REST client overview. + - source: /docs/server-sdks/reference/typescript/rest/compat + destination: /docs/server-sdks/reference/typescript/rest + - source: /docs/server-sdks/reference/typescript/rest/compat/:slug* + destination: /docs/server-sdks/reference/typescript/rest + # The SWMLService `onRequest` override hook is now protected (renamed # `buildSwmlForRequest`) and no longer documented; point its old page URL at # the public equivalent, `setOnRequestCallback`. - source: /docs/server-sdks/reference/typescript/agents/swml-service/on-request destination: /docs/server-sdks/reference/typescript/agents/swml-service/set-on-request-callback + # SwmlBuilder getDocument()/renderDocument() were removed from the SDK in + # favor of the Python-parity names build()/render(). + - source: /docs/server-sdks/reference/typescript/agents/swml-builder/get-document + destination: /docs/server-sdks/reference/typescript/agents/swml-builder/build + - source: /docs/server-sdks/reference/typescript/agents/swml-builder/render-document + destination: /docs/server-sdks/reference/typescript/agents/swml-builder/render + # The Python SDK removed its Twilio-compatibility REST namespace # (`client.compat`, signalwire-python 3d08c96); the pages that documented it # are gone. Send old URLs to the Python REST overview. diff --git a/fern/products/server-sdks/pages/guides/build-ai-agents/builtin-skills.mdx b/fern/products/server-sdks/pages/guides/build-ai-agents/builtin-skills.mdx index 7beca450a9..39896a0fcd 100644 --- a/fern/products/server-sdks/pages/guides/build-ai-agents/builtin-skills.mdx +++ b/fern/products/server-sdks/pages/guides/build-ai-agents/builtin-skills.mdx @@ -284,7 +284,7 @@ Tell jokes to lighten the mood or entertain callers. Uses a curated joke databas **Functions:** -- `tell_joke` - Get a random joke +- `get_joke` - Get a random joke. Takes a required `type` argument, `jokes` or `dadjokes` **Requirements:** None @@ -292,7 +292,7 @@ Tell jokes to lighten the mood or entertain callers. Uses a curated joke databas | Parameter | Type | Description | Default | |-----------|------|-------------|---------| -| `tool_name` | string | Custom function name | "tell_joke" | +| `tool_name` | string | Custom function name | "get_joke" | ```python from signalwire import AgentBase @@ -323,22 +323,13 @@ Play audio files in the background during calls. Audio plays while conversation **Parameters:** -This skill supports two configuration styles: - -- **Catalog mode** — preload named files via `files`, caller selects by `key`: +Preload named files via `files`; the caller selects one by `key`: | Parameter | Type | Description | Default | |-----------|------|-------------|---------| | `tool_name` | string | Custom play function name | "play_background_file" | | `files` | array | List of `{ key, description, url, wait? }` entries | Required | -- **Free-form mode** — caller supplies a URL at call time (gated by `allowed_domains`): - -| Parameter | Type | Description | Default | -|-----------|------|-------------|---------| -| `default_file_url` | string | URL played when no argument is provided | Required | -| `allowed_domains` | array | Whitelisted domains for caller-supplied URLs | Required | - **Supported formats:** MP3, WAV, OGG ```python @@ -570,9 +561,6 @@ Validate addresses and compute driving routes using Google Maps. Supports geocod | `api_key` | string | Google Maps API key (falls back to `GOOGLE_MAPS_API_KEY`) | Required | | `lookup_tool_name` | string | Address lookup function name | "lookup_address" | | `route_tool_name` | string | Route computation function name | "compute_route" | -| `geocode_tool_name` | string | Reverse-geocoding function name | "geocode_address" | -| `route_by_coords_tool_name` | string | Coord-based route function name | "compute_route_by_coords" | -| `default_mode` | string | `"driving"`, `"walking"`, `"bicycling"`, or `"transit"` | "driving" | ```python from signalwire import AgentBase diff --git a/fern/products/server-sdks/pages/guides/deploy/docker-kubernetes.mdx b/fern/products/server-sdks/pages/guides/deploy/docker-kubernetes.mdx index 936a7d02fa..4e85131f0d 100644 --- a/fern/products/server-sdks/pages/guides/deploy/docker-kubernetes.mdx +++ b/fern/products/server-sdks/pages/guides/deploy/docker-kubernetes.mdx @@ -36,7 +36,7 @@ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "3000", "--workers", " ```dockerfile -FROM node:20-slim +FROM node:22-slim WORKDIR /app diff --git a/fern/products/server-sdks/pages/guides/deploy/serverless.mdx b/fern/products/server-sdks/pages/guides/deploy/serverless.mdx index baddcb842e..8951fd83d8 100644 --- a/fern/products/server-sdks/pages/guides/deploy/serverless.mdx +++ b/fern/products/server-sdks/pages/guides/deploy/serverless.mdx @@ -414,7 +414,7 @@ gcloud functions deploy signalwire-agent \ ## TypeScript (Node.js) gcloud functions deploy signalwire-agent \ --gen2 \ - --runtime nodejs20 \ + --runtime nodejs22 \ --trigger-http \ --allow-unauthenticated \ --entry-point main \ diff --git a/fern/products/server-sdks/pages/guides/getting-started/installation.mdx b/fern/products/server-sdks/pages/guides/getting-started/installation.mdx index b5d0dc7640..5e8940e267 100644 --- a/fern/products/server-sdks/pages/guides/getting-started/installation.mdx +++ b/fern/products/server-sdks/pages/guides/getting-started/installation.mdx @@ -10,7 +10,7 @@ max-toc-depth: 3 | Language | Runtime | Package Manager | OS | |----------|---------|-----------------|-----| | Python | 3.10+ | pip | Linux, macOS, Windows | -| TypeScript | Node.js 18+ | npm | Linux, macOS, Windows | +| TypeScript | Node.js 22+ | npm | Linux, macOS, Windows | {/* | Go | 1.21+ | go modules | Linux, macOS, Windows | | Ruby | 3.0+ | gem/bundler | Linux, macOS, Windows | @@ -36,7 +36,7 @@ npm install @signalwire/sdk ``` -`@signalwire/sdk` is published as an ES module only (no CommonJS build). Your project must use ESM — add `"type": "module"` to your `package.json`, use `.mjs` file extensions, or use a bundler/transpiler that supports ESM. `import` syntax works; `require('@signalwire/sdk')` does not work in Node older than 22 without the `--experimental-require-module` flag. +`@signalwire/sdk` is published as an ES module only (no CommonJS build). Your project must use ESM — add `"type": "module"` to your `package.json`, use `.mjs` file extensions, or use a bundler/transpiler that supports ESM. Import it with `import` syntax. diff --git a/fern/products/server-sdks/pages/guides/getting-started/overview.mdx b/fern/products/server-sdks/pages/guides/getting-started/overview.mdx index aec6621076..4f57e59922 100644 --- a/fern/products/server-sdks/pages/guides/getting-started/overview.mdx +++ b/fern/products/server-sdks/pages/guides/getting-started/overview.mdx @@ -87,7 +87,7 @@ Before starting, ensure you have the following: | Language | Requirement | Package Manager | |----------|-------------|-----------------| | Python | 3.10+ | pip | -| TypeScript | Node.js 18+ | npm | +| TypeScript | Node.js 22+ | npm | {/* | Go | 1.21+ | go modules | | Ruby | 3.0+ | gem/bundler | diff --git a/fern/products/server-sdks/pages/guides/manage-resources/overview.mdx b/fern/products/server-sdks/pages/guides/manage-resources/overview.mdx index 5a1a8e7c88..91e866eb71 100644 --- a/fern/products/server-sdks/pages/guides/manage-resources/overview.mdx +++ b/fern/products/server-sdks/pages/guides/manage-resources/overview.mdx @@ -559,6 +559,15 @@ client = RestClient(request_options=RequestOptions(timeout=10.0, retries=3)) numbers = client.phone_numbers.list(request_options=RequestOptions(timeout=60.0)) ``` +In TypeScript, every list resource has a `paginate()` method that returns an +async iterator over all pages: + +```typescript +for await (const number of client.phoneNumbers.paginate()) { + console.log(number.name, number.number); +} +``` + ### Error Handling REST errors raise `SignalWireRestError`. A request that never reaches the server diff --git a/fern/products/server-sdks/pages/reference/python/agents/bedrock-agent/index.mdx b/fern/products/server-sdks/pages/reference/python/agents/bedrock-agent/index.mdx index 8135558e5c..12e35644df 100644 --- a/fern/products/server-sdks/pages/reference/python/agents/bedrock-agent/index.mdx +++ b/fern/products/server-sdks/pages/reference/python/agents/bedrock-agent/index.mdx @@ -6,8 +6,8 @@ max-toc-depth: 3 --- [agentbase]: /docs/server-sdks/reference/python/agents/agent-base -[amazon-bedrock]: /docs/swml/reference/amazon-bedrock -[swml-bedrock-reference]: /docs/swml/reference/amazon-bedrock +[amazon-bedrock]: /docs/swml/reference/calling/amazon-bedrock +[swml-bedrock-reference]: /docs/swml/reference/calling/amazon-bedrock [setvoice]: /docs/server-sdks/reference/python/agents/bedrock-agent/set-voice [setinferenceparams]: /docs/server-sdks/reference/python/agents/bedrock-agent/set-inference-params @@ -72,7 +72,7 @@ full specification. -## **Overridden Behavior** +## **Overridden behavior** BedrockAgent overrides several AgentBase methods to adapt for the Bedrock voice-to-voice model: diff --git a/fern/products/server-sdks/pages/reference/python/agents/cli/swaig-test.mdx b/fern/products/server-sdks/pages/reference/python/agents/cli/swaig-test.mdx index c64db8290e..8cf966f23d 100644 --- a/fern/products/server-sdks/pages/reference/python/agents/cli/swaig-test.mdx +++ b/fern/products/server-sdks/pages/reference/python/agents/cli/swaig-test.mdx @@ -40,7 +40,7 @@ Choose one action per invocation: after the function name. -## Common Options +## Common options Enable verbose output with debug information, including raw result types and @@ -62,7 +62,7 @@ Choose one action per invocation: Mutually exclusive with `--agent-class`. -## Function Execution Options +## Function execution options Use minimal `post_data` containing only the function arguments. This is the default behavior. @@ -77,7 +77,7 @@ Choose one action per invocation: JSON string with custom `post_data` overrides merged into the request payload. -## SWML Generation Options +## SWML generation options Simulated call type. Valid values: @@ -103,7 +103,7 @@ Choose one action per invocation: Override the destination/to extension in mock data. -## Data Customization +## Data customization JSON string injected as `userVariables` in the mock request. Used to test @@ -124,7 +124,7 @@ Choose one action per invocation: Can be specified multiple times. -## Serverless Simulation +## Serverless simulation Simulate a serverless platform environment. Valid values: @@ -146,7 +146,7 @@ Choose one action per invocation: Load environment variables from a file (one `KEY=VALUE` per line). -### Platform-Specific Options +### Platform-specific options Run `swaig-test agent.py --help-platforms` for the full list. Key options per platform: @@ -158,7 +158,7 @@ Run `swaig-test agent.py --help-platforms` for the full list. Key options per pl **Azure**: `--azure-env`, `--azure-function-url` -## Extended Help +## Extended help Show detailed documentation for all serverless platform options. @@ -176,7 +176,7 @@ Run `swaig-test agent.py --help-platforms` for the full list. Key options per pl ## Examples -### List Tools and Generate SWML +### List tools and generate SWML ```bash # List all registered SWAIG functions @@ -192,7 +192,7 @@ swaig-test agent.py --dump-swml --raw | jq '.' swaig-test agent.py --dump-swml --raw | jq '.sections.main[1].ai.SWAIG.functions' ``` -### Execute Functions +### Execute functions ```bash # Execute with CLI-style arguments @@ -212,7 +212,7 @@ Arguments are automatically type-converted: numeric values become integers or floats, `true`/`false` become booleans, and everything else stays as a string. -### Multi-Agent Files +### Multi-agent files ```bash # Discover agents in the file @@ -225,7 +225,7 @@ swaig-test multi_agent.py --agent-class SalesAgent --list-tools swaig-test multi_agent.py --route /support --exec create_ticket --issue "Login problem" ``` -### Dynamic Agent Testing +### Dynamic agent testing ```bash # Test with query parameters @@ -238,7 +238,7 @@ swaig-test dynamic_agent.py --dump-swml \ --user-vars '{"preferences":{"language":"es"}}' ``` -### Serverless Simulation +### Serverless simulation ```bash # AWS Lambda @@ -265,7 +265,7 @@ swaig-test agent.py --simulate-serverless lambda \ --exec my_function ``` -## Exit Codes +## Exit codes | Code | Meaning | |------|---------| diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-function-include.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-function-include.mdx index 068fd19f1e..b45247b880 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-function-include.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-function-include.mdx @@ -5,8 +5,8 @@ description: Add a remote function include to the SWAIG configuration. max-toc-depth: 3 --- -[ai-swaig-includes]: /docs/swml/reference/ai/swaig/includes -[swml-swaig-includes-reference]: /docs/swml/reference/ai/swaig/includes +[ai-swaig-includes]: /docs/swml/reference/calling/ai/swaig/includes +[swml-swaig-includes-reference]: /docs/swml/reference/calling/ai/swaig/includes [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base Add a remote SWAIG function include so the agent can call tools hosted on an external diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-language.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-language.mdx index 87f7ffffce..aae05e36f4 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-language.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-language.mdx @@ -5,8 +5,8 @@ description: Add a language configuration with voice settings for multilingual c max-toc-depth: 3 --- -[ai-languages]: /docs/swml/reference/ai/languages -[swml-languages-reference]: /docs/swml/reference/ai/languages +[ai-languages]: /docs/swml/reference/calling/ai/languages +[swml-languages-reference]: /docs/swml/reference/calling/ai/languages [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base Add a language configuration with voice settings. The agent uses these configurations diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-skill-by-name.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-skill-by-name.mdx index bb5174e748..5bf1048e91 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-skill-by-name.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/add-skill-by-name.mdx @@ -14,8 +14,10 @@ Look up a skill class by name in the global ## **Parameters** - - Registered skill name (read from the target class's `SKILL_NAME`). + + Registered skill name (read from the target class's `SKILL_NAME`). The + `SkillName` union lists the 19 built-in names for editor autocompletion; any + other string resolves against skills you registered yourself. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/as-router.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/as-router.mdx index 9951c2f765..102915ace3 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/as-router.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/as-router.mdx @@ -16,8 +16,10 @@ None. ## **Returns** -`Hono` -- A Hono app with all agent endpoints (SWML delivery, SWAIG function -handling, post-prompt, debug events, health checks, etc.). +`HostAppRouter` -- The agent's Hono app, with all agent endpoints (SWML +delivery, SWAIG function handling, post-prompt, debug events, health checks, +etc.). `HostAppRouter` is a type alias for `Hono`, named for the host-app +mounting contract it fulfills. ## **Example** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-tool.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-tool.mdx index bec3e3dc48..064b2231eb 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-tool.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-tool.mdx @@ -5,10 +5,12 @@ description: Programmatically define a SWAIG tool that the AI can invoke during max-toc-depth: 3 --- -[swaig-function]: /docs/swml/reference/ai/swaig/functions -[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[swaig-function]: /docs/swml/reference/calling/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/calling/ai/swaig/functions [functionresult]: /docs/server-sdks/reference/typescript/agents/function-result [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base +[parameter-schema]: /docs/server-sdks/reference/typescript/agents/parameter-schema +[on-error]: /docs/server-sdks/reference/typescript/agents/agent-base/on-error Programmatically define a SWAIG function (tool) that the AI can invoke during a conversation. @@ -42,19 +44,25 @@ instead. when to call the tool. -"} toc={true}> - JSON Schema describing the tool's parameters. The AI generates arguments - conforming to this schema. + + JSON Schema describing the tool's parameters. Write it either as a flat map of + property name to schema (`{ city: { type: 'string' } }`) or as a wrapped + object schema (`{ type: 'object', properties: { ... } }`). With the flat form + the handler's `args` is typed from the schema, so `args.city` is a `string` + and an `enum` narrows to its literal union. You can also build the schema + with [`paramSchema()`][parameter-schema]. Callback invoked when the AI calls this tool. Receives - `(args: Record, rawData: Record)` and should - return a [`FunctionResult`][functionresult]. + `(args, rawData: SwaigRequest)` and returns a [`FunctionResult`][functionresult], + a plain object, or a string. - - Whether to require token validation on tool calls. Recommended for production. + + Whether to require token validation on tool calls. Tools are secure by + default: the rendered webhook URL carries a per-tool token. Pass `false` only + to expose the tool on the shared, unauthenticated webhook URL. "} toc={true}> @@ -84,6 +92,19 @@ instead. Additional fields merged into the SWAIG function definition. Equivalent to Python's `**swaig_fields` kwargs (e.g., `meta_data`). + + + Per-tool error hook, called when the handler throws. Return a + [`FunctionResult`][functionresult] to control what the caller hears, or + nothing to fall back to `errorMessage`. Runs before the agent-level + [`onError()`][on-error] hook. + + + + Message spoken to the caller when the handler throws and no error hook + supplies a response. Defaults to a generic apology asking the caller to try + again. + ## **Returns** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-typed-tool.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-typed-tool.mdx index b19976d557..76c24113ae 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-typed-tool.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/define-typed-tool.mdx @@ -47,8 +47,10 @@ the args object. object. Parameter names must match the JSON Schema property names. - - Whether to require token validation on tool calls. Recommended for production. + + Whether to require token validation on tool calls. Tools are secure by + default: the rendered webhook URL carries a per-tool token. Pass `false` only + to expose the tool on the shared, unauthenticated webhook URL. "} toc={true}> diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/handle-request.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/handle-request.mdx new file mode 100644 index 0000000000..e97375a662 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/handle-request.mdx @@ -0,0 +1,67 @@ +--- +title: "handleRequest" +slug: /reference/typescript/agents/agent-base/handle-request +description: Dispatch one inbound request from plain HTTP primitives, without a Hono app. +max-toc-depth: 3 +--- + +[as-router]: /docs/server-sdks/reference/typescript/agents/agent-base/as-router +[render-swml]: /docs/server-sdks/reference/typescript/agents/agent-base/render-swml + +Dispatch one inbound request from plain HTTP primitives and get back a +`[status, headers, body]` triple to write to the response. Use it to serve the +agent from a framework the SDK has no adapter for. It performs Basic Auth, +runs any routing callback, applies `onSwmlRequest` modifications, and renders +SWML with [`renderSwml()`][render-swml]. For Hono-based hosts, mount +[`asRouter()`][as-router] instead. + +## **Parameters** + + + HTTP method, such as `"GET"` or `"POST"`. + + + + The full request URL. + + +"} required={true} toc={true}> + Request headers as a plain object. + + + | null"} toc={true}> + The already-parsed JSON body for POST requests. Omit for GET. + + +## **Returns** + +`Promise<[number, Record, string]>` -- The status code, +response headers, and body string. A failed Basic Auth check returns `401` +with a `WWW-Authenticate` header; a routing callback that redirects returns +`307` with a `Location` header. + +## **Example** + +```typescript {8-13} +import { createServer } from 'node:http'; +import { AgentBase } from '@signalwire/sdk'; + +const agent = new AgentBase({ name: 'dispatch', route: '/' }); +agent.setPromptText('You are a taxi dispatcher.'); + +createServer(async (req, res) => { + const chunks: Buffer[] = []; + for await (const chunk of req) chunks.push(chunk as Buffer); + const raw = Buffer.concat(chunks).toString(); + const body = raw ? JSON.parse(raw) : null; + const url = `https://${req.headers.host}${req.url}`; + const [status, headers, text] = await agent.handleRequest( + req.method ?? 'GET', + url, + req.headers as Record, + body, + ); + res.writeHead(status, headers); + res.end(text); +}).listen(3000); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/has-skill.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/has-skill.mdx index 334b779a81..9e6afcc12e 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/has-skill.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/has-skill.mdx @@ -9,8 +9,9 @@ Check whether a skill with the given name is currently loaded. ## **Parameters** - - Skill name to check. + + Skill name to check. Built-in names autocomplete; any other string is + accepted. ## **Returns** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/index.mdx index 557eaf6895..932926a5a1 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/index.mdx @@ -5,8 +5,8 @@ description: The central class for building AI-powered voice agents with SignalW max-toc-depth: 3 --- -[ai]: /docs/swml/reference/ai -[swml-reference]: /docs/swml/reference/ai +[ai]: /docs/swml/reference/calling/ai +[swml-reference]: /docs/swml/reference/calling/ai [agentserver]: /docs/server-sdks/reference/typescript/agents/agent-server [swmlservice]: /docs/server-sdks/reference/typescript/agents/swml-service [setnativefunctions]: /docs/server-sdks/reference/typescript/agents/agent-base/native-functions @@ -177,6 +177,11 @@ const agent = new AgentBase({ Unique identifier for this agent instance. + + The Signing Key used for webhook signature validation, from the constructor + option or `SIGNALWIRE_SIGNING_KEY`. `null` when validation is disabled. + + ## **Static Members** @@ -516,4 +521,19 @@ await agent.run(); Read engine-specific params on an added language. + + Answer in whatever language the caller speaks. + + + Hook that runs when any tool handler throws. + + + Replace the global data object, discarding prior keys. + + + Route requests dynamically from the POST body. + + + Dispatch a request from plain HTTP primitives. + diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-error.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-error.mdx new file mode 100644 index 0000000000..95c7e6b1a7 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-error.mdx @@ -0,0 +1,45 @@ +--- +title: "onError" +slug: /reference/typescript/agents/agent-base/on-error +description: Register an agent-level hook that runs when any SWAIG tool handler throws. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base +[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result +[define-tool]: /docs/server-sdks/reference/typescript/agents/agent-base/define-tool + +Register an agent-level hook that runs when any SWAIG tool handler throws. Use +it to report the failure to your error tracker and, optionally, to decide what +the caller hears. The error is always contained: a thrown handler never breaks +the live call. + +The hook runs after the tool's own `onError` option, if one was set in +[`defineTool()`][define-tool]. + +## **Parameters** + + + Called with `(error, context)`. Return a [`FunctionResult`][functionresult] + to control the response, or return nothing to fall back to the tool's + `errorMessage` or the default message. Pass `undefined` to clear the hook. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns `this` for method chaining. + +## **Example** + +```typescript {5-9} +import { AgentBase, FunctionResult } from '@signalwire/sdk'; + +const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' }); + +agent.onError(async (error, context) => { + console.error('tool failed', { tool: context.functionName, error }); + return new FunctionResult( + "I couldn't reach the dispatch system. Let me connect you to an operator.", + ).connect('+15551234567'); +}); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-summary.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-summary.mdx index 79ee81b362..7e9a86d359 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-summary.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/on-summary.mdx @@ -24,12 +24,12 @@ to receive summaries at an external endpoint. ## **Parameters** - | null"} required={true} toc={true}> + The summary object generated by the AI based on your post-prompt instructions. `null` if no summary could be extracted from the response. -"} required={true} toc={true}> + The complete raw POST data from the post-prompt request, including metadata like `call_id` and the full AI response. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/register-routing-callback.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/register-routing-callback.mdx new file mode 100644 index 0000000000..047762df5a --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/register-routing-callback.mdx @@ -0,0 +1,54 @@ +--- +title: "registerRoutingCallback" +slug: /reference/typescript/agents/agent-base/register-routing-callback +description: Register a callback for dynamic request routing based on SIP URIs or POST data. +max-toc-depth: 3 +--- + +[enable-sip-routing]: /docs/server-sdks/reference/typescript/agents/agent-base/enable-sip-routing +[extract-sip-username]: /docs/server-sdks/reference/typescript/agents/agent-base/extract-sip-username +[ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base + +Register a callback for dynamic request routing. When a request arrives at +`path`, the callback inspects the POST body and decides whether to redirect the +request to a different route or let normal SWML serving continue. + +This is primarily used for SIP-based routing where the destination depends on +the incoming SIP URI. For routing on agent name alone, use +[`enableSipRouting()`][enable-sip-routing] instead. + +## **Parameters** + + + Receives the parsed request body and, optionally, the request headers. + Return a route string to redirect the request there (HTTP 307, preserving + the POST body), or return `null` or `undefined` to serve this agent's own + SWML. + + + + HTTP path where the routing endpoint is registered. Normalized to start with + `/`, with trailing slashes stripped. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns `this` for method chaining. + +## **Example** + +```typescript {6-11} +import { AgentBase } from '@signalwire/sdk'; + +const agent = new AgentBase({ name: 'router', route: '/' }); +agent.setPromptText('You are a helpful assistant.'); + +agent.registerRoutingCallback((body) => { + const username = AgentBase.extractSipUsername(body); + if (username === 'sales') return '/agents/sales'; + if (username === 'support') return '/agents/support'; + return null; +}, '/sip'); + +await agent.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/replace-global-data.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/replace-global-data.mdx new file mode 100644 index 0000000000..64e322d22c --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/replace-global-data.mdx @@ -0,0 +1,37 @@ +--- +title: "replaceGlobalData" +slug: /reference/typescript/agents/agent-base/replace-global-data +description: Replace the entire global data object, discarding every prior key. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base +[set-global-data]: /docs/server-sdks/reference/typescript/agents/agent-base/set-global-data +[update-global-data]: /docs/server-sdks/reference/typescript/agents/agent-base/update-global-data + +Replace the entire `global_data` object available to the AI, discarding every +prior key. [`setGlobalData()`][set-global-data] and +[`updateGlobalData()`][update-global-data] merge into the existing object; this +method clears it first. A shallow copy of `data` is stored, so later changes to +your object don't leak into the agent. + +## **Parameters** + +"} required={true} toc={true}> + The new global data object. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns `this` for method chaining. + +## **Example** + +```typescript {6} +import { AgentBase } from '@signalwire/sdk'; + +const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' }); + +agent.setGlobalData({ region: 'bayview', fleet_size: 12 }); +agent.replaceGlobalData({ region: 'mission' }); // fleet_size is gone +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-multilingual.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-multilingual.mdx new file mode 100644 index 0000000000..a1a89f67d5 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-multilingual.mdx @@ -0,0 +1,50 @@ +--- +title: "setMultilingual" +slug: /reference/typescript/agents/agent-base/set-multilingual +description: Configure recognizer-driven multilingual mode, where the agent answers in whatever language the caller speaks. +max-toc-depth: 3 +--- + +[ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base +[set-languages]: /docs/server-sdks/reference/typescript/agents/agent-base/set-languages +[swml-ai-multilingual]: /docs/swml/reference/calling/ai/multilingual + +Configure recognizer-driven multilingual mode. The speech recognizer runs in +code-switching mode and the agent answers in whatever language the caller +actually spoke, rather than the model choosing a language. The config is +emitted as the `multilingual` object on the SWML `ai` verb. + + +Mutually exclusive with [`setLanguages()`][set-languages]. If both are set, the +platform uses `multilingual` and ignores `languages`. + + +## **Parameters** + +"} required={true} toc={true}> + The multilingual configuration object, passed through as-is: `languages` + (required, one entry per language with a `voice`), `allowed`, + `start_language`, `min_switch_words`, and fillers. See the SWML + [`ai.multilingual`][swml-ai-multilingual] reference for every field. + + +## **Returns** + +[`AgentBase`][ref-agentbase] -- Returns `this` for method chaining. + +## **Example** + +```typescript {5-12} +import { AgentBase } from '@signalwire/sdk'; + +const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' }); + +agent.setMultilingual({ + start_language: 'en', + allowed: ['en', 'es'], + languages: [ + { language: 'default', voice: 'elevenlabs.rachel' }, + { language: 'es', voice: 'elevenlabs.maria' }, + ], +}); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-params.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-params.mdx index 59a1277ae7..172c581847 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-params.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-params.mdx @@ -5,8 +5,8 @@ description: Configure AI model parameters such as temperature, timeouts, and sp max-toc-depth: 3 --- -[ai-params]: /docs/swml/reference/ai/params -[swml-ai-params-reference]: /docs/swml/reference/ai/params +[ai-params]: /docs/swml/reference/calling/ai/params +[swml-ai-params-reference]: /docs/swml/reference/calling/ai/params [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base Set multiple AI parameters at once. Merges into any previously set parameters. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-prompt-text.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-prompt-text.mdx index 0e68d19ebd..e903026af9 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-prompt-text.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/set-prompt-text.mdx @@ -5,8 +5,8 @@ description: Set the agent's system prompt as a raw text string. max-toc-depth: 3 --- -[ai-prompt]: /docs/swml/reference/ai/prompt -[swml-prompt-reference]: /docs/swml/reference/ai/prompt +[ai-prompt]: /docs/swml/reference/calling/ai/prompt +[swml-prompt-reference]: /docs/swml/reference/calling/ai/prompt [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base Set the agent's system prompt as a raw text string. This is the simplest way to diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/validate-tool-token.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/validate-tool-token.mdx index cd03deb9f0..221cf42d2c 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/validate-tool-token.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/agent-base/validate-tool-token.mdx @@ -9,7 +9,7 @@ max-toc-depth: 3 Validate a per-tool HMAC token attached to an incoming SWAIG function call. Returns `false` for unknown tools, short-circuits to `true` for tools -registered without [`secure: true`][define-tool], and otherwise delegates to +registered with [`secure: false`][define-tool], and otherwise delegates to `SessionManager.validateToolToken`. Raw-dict descriptors (e.g. `DataMap` output) are always treated as secure. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/chat.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/chat.mdx new file mode 100644 index 0000000000..575d9e1dc8 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/chat.mdx @@ -0,0 +1,93 @@ +--- +title: "chat" +slug: /reference/typescript/agents/ai-chat-client/chat +description: Send a message to an AI agent and return its reply. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client +[createconversation]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/create-conversation +[swml-user-event]: /docs/server-sdks/reference/typescript/agents/function-result/swml-user-event + +Send a message and return the agent's reply. One call is one full turn, +including any tool calls the agent makes along the way, so expect seconds +rather than milliseconds. + +## **Parameters** + + + The conversation to send on. + + + + The message to send. + + + + Turn options. + + + + + + `user` or `system`. A `system` message steers the agent without appearing as + something the user said. + + + + Creates the conversation if it does not exist yet. Saves a call, at the cost + of never receiving `initialMessage`, so the agent does not speak first. + + +"} toc={true}> + Arbitrary data about the user, echoed back on this conversation's webhooks. + Sent as `user_meta_data`. + + + + Applies only when this call creates the conversation. + + + + Applies only when this call creates the conversation. + + + + +## **Returns** + +`Promise` -- carries `text`, `conversationId`, and `userEvent`. + +`userEvent` is `null` unless the turn produced one. Its contents are whatever +your tool passed to [`swmlUserEvent()`][swml-user-event], so the shape is yours. + +## **Throws** + +`ChatInProgressError` when a turn is already running on this conversation. That +is the contract rather than a transient failure, so wait for the first turn to +return instead of retrying. + +## **Example** + +```typescript {8-11} +import { AIChatClient, ChatInProgressError } from '@signalwire/sdk'; + +const CONFIG_URL = 'https://bayview-taxi.example.com/swml'; +const client = new AIChatClient({ space: 'your-space' }); +await client.createConversation('chat-8f21', { configUrl: CONFIG_URL }); + +try { + const reply = await client.chat( + 'chat-8f21', + 'How much is a van from 123 Gough Street to the airport?', + ); + console.log('Ada:', reply.text); + if (reply.userEvent) handle(reply.userEvent); +} catch (e) { + if (e instanceof ChatInProgressError) { + // a turn is already running; wait rather than retry + } else { + throw e; + } +} +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/close.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/close.mdx new file mode 100644 index 0000000000..f201b4f34a --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/close.mdx @@ -0,0 +1,39 @@ +--- +title: "close" +slug: /reference/typescript/agents/ai-chat-client/close +description: Complete the client's lifecycle. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client + +Complete the client's lifecycle. The client holds no pooled connection of its +own, so there is nothing to tear down and calling it more than once is safe. It +exists so code can treat `AIChatClient` like any other disposable resource. + +The client also implements `Symbol.asyncDispose`, so `await using client = new +AIChatClient(...)` calls `close()` for you when the scope exits. + +## **Parameters** + +None. + +## **Returns** + +`Promise` + +## **Example** + +Outside an `await using` block, close it yourself: + +```typescript {9} +import { AIChatClient } from '@signalwire/sdk'; + +const client = new AIChatClient({ space: 'your-space' }); +try { + const reply = await client.chat('chat-8f21', 'Where is my van?'); + console.log('Ada:', reply.text); +} finally { + await client.close(); +} +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/create-conversation.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/create-conversation.mdx new file mode 100644 index 0000000000..6d890786c6 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/create-conversation.mdx @@ -0,0 +1,77 @@ +--- +title: "createConversation" +slug: /reference/typescript/agents/ai-chat-client/create-conversation +description: Create a conversation with an AI agent, or reset an existing one. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client +[chat]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/chat + +Create a conversation, or reset an existing one when `reinit` is set. Calling +it for an id that already exists returns that conversation untouched. + +## **Parameters** + + + The conversation id. You choose it, and it is scoped to your project. + + + + Creation options. `configUrl` is required. + + + + + + The URL serving your agent's SWML. SignalWire fetches it server-to-server, so + it must be reachable from the public internet. + + + + An opening message from the user, sent as part of creating the conversation. + + + + Idle seconds before the conversation ends. Sent as `conversation_timeout`; + the service default is 3600. + + +"} toc={true}> + Arbitrary data about the user, echoed back on this conversation's webhooks. + Sent as `user_meta_data`. + + + + Reset an existing conversation instead of returning it as-is. + + + + +## **Returns** + +`Promise` -- carries `id`, `status`, and `initialMessage`. +`status` is the lifecycle state the service reports; the SDK fills in `created` +when the response omits it. + + + `initialMessage` is the agent's generated greeting. Create the conversation + when the visitor opens the chat rather than when the page loads. Use + [`chat()`][chat] with `configUrl` instead when you don't need the agent to + speak first. + + +## **Example** + +```typescript {6-9} +import { AIChatClient } from '@signalwire/sdk'; + +const CONFIG_URL = 'https://bayview-taxi.example.com/swml'; +const client = new AIChatClient({ space: 'your-space' }); + +const info = await client.createConversation('chat-8f21', { + configUrl: CONFIG_URL, + userMetadata: { customer_id: 'cust-4410' }, +}); +console.log(info.status, info.initialMessage); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/delete.mdx new file mode 100644 index 0000000000..9592c884ec --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/delete.mdx @@ -0,0 +1,33 @@ +--- +title: "delete" +slug: /reference/typescript/agents/ai-chat-client/delete +description: Remove a conversation and its data. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client +[end]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/end + +Remove the conversation and its data. Nothing is post-processed and no webhook +fires, which is the difference from [`end()`][end]. Deleting an id that no +longer exists is not an error. + +## **Parameters** + + + The conversation to delete. + + +## **Returns** + +`Promise` -- `true` when the service reported the conversation deleted. + +## **Example** + +```typescript {5} +import { AIChatClient } from '@signalwire/sdk'; + +const client = new AIChatClient({ space: 'your-space' }); + +await client.delete('chat-8f21'); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/end.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/end.mdx new file mode 100644 index 0000000000..9ebd5d3a46 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/end.mdx @@ -0,0 +1,36 @@ +--- +title: "end" +slug: /reference/typescript/agents/ai-chat-client/end +description: End a conversation and start post-processing. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client +[delete]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/delete + +End the conversation and start post-processing: the summary, and a request to +your `post_prompt_url` when your SWML sets one. The webhook is not instant, so +expect seconds. + +To remove a conversation without any of that, use [`delete()`][delete]. + +## **Parameters** + + + The conversation to end. + + +## **Returns** + +`Promise` -- `true` when the service reported the conversation ended. + +## **Example** + +```typescript {5} +import { AIChatClient } from '@signalwire/sdk'; + +const client = new AIChatClient({ space: 'your-space' }); + +const ended = await client.end('chat-8f21'); +console.log(ended ? 'Conversation ended' : 'No such conversation'); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/index.mdx new file mode 100644 index 0000000000..e0ff4ec9b6 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/index.mdx @@ -0,0 +1,169 @@ +--- +title: "AIChatClient" +slug: /reference/typescript/agents/ai-chat-client +description: Client for holding a text conversation with a SignalWire AI agent from your own server. +max-toc-depth: 3 +--- + +[chat-endpoint]: /docs/apis/rest/ai-chat/chat-methods +[error-codes]: /docs/apis/error-codes +[createconversation]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/create-conversation +[chat]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/chat +[end]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/end +[delete]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/delete +[log]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/log +[summarize]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/summarize +[close]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/close + +`AIChatClient` sends messages to an AI agent and returns its replies. The agent +is the same one a phone call would reach, and each call to [`chat()`][chat] +runs one full turn. + +Every method returns a promise. A turn waits on a full model round trip, +measured in seconds, so don't block on it in a request handler that serves +other users. + + + + + This class holds your API token, so it belongs on a server you control. Never + ship it to a browser. + + +## **Parameters** + + + Your project ID. Falls back to `SIGNALWIRE_PROJECT_ID`. The constructor throws + when neither is set. + + + + An API token with the `chat` scope. Falls back to `SIGNALWIRE_API_TOKEN`. + + + + Your space name, `your-space` rather than `your-space.signalwire.com`, used to build + the service URL. Falls back to `SIGNALWIRE_SPACE`. `RestClient` reads that variable + as a full hostname, so a value set for REST builds a wrong URL here; pass `space` or + `url` explicitly in that case. + + + + The service URL, used verbatim. Overrides `space`. The constructor throws when + neither is available. + + + + Custom `fetch` implementation. Defaults to the global `fetch`. + + + + Seconds of silence on the connection before a request is abandoned. The + service sends keepalive bytes while a slow turn runs, so this bounds a dead + connection rather than total turn length. `0` disables it. + + +A configured environment needs no arguments at all. Identity travels in HTTP +Basic auth, never in the request body. + +## **Return types** + + + Returned by [`createConversation()`][createconversation]. Carries `id`, + `status`, and `initialMessage`. + + + + Returned by [`chat()`][chat]. Carries `text`, `conversationId`, and `userEvent`. + + + + Returned by [`log()`][log]. Carries `messages` and `callTimeline`. + + +## **Errors** + +All extend `AIChatError`, which carries `code` and `serverMessage`. Codes +without a specific class throw `AIChatError` itself. Documented codes are listed +under [AI chat errors][error-codes]. + + + A JSON-RPC `-32009` response. + + + + No conversation with that id exists in your project. + + + + The service returned a JSON-RPC rate-limit error. + + + + A turn is already running on this conversation. + + + + Summary generation failed. `code` is `null`, because this failure rides the + success envelope rather than arriving as a JSON-RPC error. + + +Success and failure are decided by the JSON-RPC body, not the HTTP status. A +response that isn't JSON throws `AIChatError` with the HTTP status as its `code`. + +## **Methods** + + + + Create a conversation, or reset an existing one. + + + Send a message and return the agent's reply. + + + End the conversation and start post-processing. + + + Remove the conversation and its data. + + + Read the conversation back. + + + Generate a summary of the conversation. + + + Complete the client's lifecycle. + + + +## **Example** + +```typescript {6,9,14} +import { AIChatClient } from '@signalwire/sdk'; + +const CONFIG_URL = 'https://bayview-taxi.example.com/swml'; + +async function main() { + await using client = new AIChatClient({ space: 'your-space' }); + + const info = await client.createConversation('chat-8f21', { configUrl: CONFIG_URL }); + console.log('Ada:', info.initialMessage); + + const reply = await client.chat( + 'chat-8f21', + 'How much is a van from 123 Gough Street to the airport?', + ); + console.log('Ada:', reply.text); + + await client.end('chat-8f21'); +} + +await main(); +``` + +`await using` needs TypeScript 5.2 or later, which compiles it down for Node 22. +Without it, call [`close()`][close] in a `finally` block instead. + +The [AI chat endpoint][chat-endpoint] documents the wire protocol underneath +this class. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/log.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/log.mdx new file mode 100644 index 0000000000..c25d93ac54 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/log.mdx @@ -0,0 +1,42 @@ +--- +title: "log" +slug: /reference/typescript/agents/ai-chat-client/log +description: Read a conversation's message history and call timeline. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client + +Read the conversation back. This changes nothing about the conversation. + +## **Parameters** + + + The conversation to read. + + +## **Returns** + +`Promise` -- carries `messages` and `callTimeline`. + +Messages contain the fields returned by the service. Code that displays a +transcript should not assume every entry has a timestamp. `callTimeline` +contains any structured timeline entries returned for the conversation. + + + `messages` can include your prompt and other non-dialogue entries. Filter to + `user` and `assistant` roles before displaying a transcript. + + +## **Example** + +```typescript {5-8} +import { AIChatClient } from '@signalwire/sdk'; + +const client = new AIChatClient({ space: 'your-space' }); + +const { messages } = await client.log('chat-8f21'); +for (const m of messages) { + if (m.role === 'user' || m.role === 'assistant') console.log(m.role, m.content); +} +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/summarize.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/summarize.mdx new file mode 100644 index 0000000000..030866e607 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/ai-chat-client/summarize.mdx @@ -0,0 +1,75 @@ +--- +title: "summarize" +slug: /reference/typescript/agents/ai-chat-client/summarize +description: Generate a summary of a conversation. +max-toc-depth: 3 +--- + +[ref-aichatclient]: /docs/server-sdks/reference/typescript/agents/ai-chat-client +[post-prompt]: /docs/server-sdks/reference/typescript/agents/agent-base/set-post-prompt + +Generate a summary of the conversation. The service rate limits this per +conversation. + +## **Parameters** + + + The conversation to summarize. + + + + Prompt and sampling controls. + + + + + + How to summarize. Overrides the [post-prompt][post-prompt] text in your SWML + for this call only. + + + + Sampling temperature. + + + + Nucleus-sampling top-p. + + + + Frequency penalty. + + + + Presence penalty. + + + + Maximum tokens for the summary. + + + + +## **Returns** + +`Promise` -- the generated summary. + +## **Throws** + +`SummaryError` when the service reports that generation failed. The service +returns exactly one of `summary` or `error`, both on the success envelope, so a +failed summary surfaces as an exception rather than reaching you as an empty +string. `RateLimitError` when you exceed the per-conversation limit. + +## **Example** + +```typescript {5-7} +import { AIChatClient } from '@signalwire/sdk'; + +const client = new AIChatClient({ space: 'your-space' }); + +const summary = await client.summarize('chat-8f21', { + summaryPrompt: 'Summarize the ride request in two sentences.', +}); +console.log(summary); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/index.mdx new file mode 100644 index 0000000000..e45af71058 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/index.mdx @@ -0,0 +1,174 @@ +--- +title: "BedrockAgent" +slug: /reference/typescript/agents/bedrock-agent +description: "Amazon Bedrock voice-to-voice agent extending AgentBase." +max-toc-depth: 3 +--- + +[agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base +[amazon-bedrock]: /docs/swml/reference/calling/amazon-bedrock +[swml-bedrock-reference]: /docs/swml/reference/calling/amazon-bedrock +[setvoice]: /docs/server-sdks/reference/typescript/agents/bedrock-agent/set-voice +[setinferenceparams]: /docs/server-sdks/reference/typescript/agents/bedrock-agent/set-inference-params + +`BedrockAgent` extends [`AgentBase`][agentbase] to use Amazon Bedrock's +voice-to-voice model as the AI backend. It renders SWML with the +`amazon_bedrock` verb instead of `ai`, and keeps every standard agent feature: +text and POM prompts, skills, SWAIG functions, post-prompt, and dynamic +configuration. + +Extends [`AgentBase`][agentbase] -- inherits all parent properties and methods. + + +BedrockAgent generates SWML with the [`amazon_bedrock`][amazon-bedrock] verb +instead of `ai`. See the [SWML bedrock reference][swml-bedrock-reference] for the +full specification. + + +## **Constructor** + +```typescript {3} +import { BedrockAgent } from '@signalwire/sdk'; + +const agent = new BedrockAgent({ + systemPrompt: 'You are a helpful voice assistant.', + voiceId: 'joanna', +}); +``` + +The `createBedrockAgent(config)` factory function returns the same instance as +`new BedrockAgent(config)`. + +### Constructor parameters + + + Agent name. + + + + HTTP route for the agent endpoint. + + + + Initial system prompt, set as raw text. Can be overridden later with + `setPromptText()`. Leave it unset if you build the prompt from sections with + `promptAddSection()`, because raw text takes precedence over sections. + + + + Bedrock voice identifier (e.g., `"matthew"`, `"joanna"`). + + + + Generation temperature. Range: 0 to 1. + + + + Nucleus sampling parameter. Range: 0 to 1. + + + + Maximum tokens to generate per response. Accepted for compatibility with the + Python SDK. Not currently applied to the call. + + +"} toc={true}> + Additional [`AgentBase`][agentbase] constructor options (e.g., `host`, + `port`, `basicAuth`). + + +## **Methods** + + + + Set the Bedrock voice ID after construction. + + + Update Bedrock inference parameters. + + + +## **Overridden behavior** + +BedrockAgent overrides several AgentBase methods to fit the Bedrock +voice-to-voice model: + +| Method | Behavior | +|--------|----------| +| `setLlmModel()` | Logs a warning and does nothing. Bedrock uses a fixed voice-to-voice model. | +| `setLlmTemperature()` | Redirects to `setInferenceParams(temperature)`. | +| `setPromptLlmParams()` | Logs a warning. Use `setInferenceParams()` instead. | +| `setPostPromptLlmParams()` | Logs a warning. The Bedrock post-prompt uses the LLM configured in the platform. | + + +Parameters specific to text-based LLMs (`barge_confidence`, `presence_penalty`, +`frequency_penalty`) are filtered out during SWML rendering and have no effect +on Bedrock agents. + + +Prompt methods (`setPromptText()`, `setPromptPom()`, `promptAddSection()`, and +so on) work normally. The prompt is built the same way as in AgentBase and then +placed in the `amazon_bedrock` verb, with `voice_id`, `temperature`, and `top_p` +added to the prompt object itself. Raw text set through `systemPrompt` or +`setPromptText()` takes precedence: when it is present, sections added with +`promptAddSection()` are not rendered. Use one style or the other for a given +agent. + +## **Examples** + +### Basic Bedrock agent with a tool + +```typescript {3-11} +import { BedrockAgent, FunctionResult } from '@signalwire/sdk'; + +const agent = new BedrockAgent({ + name: 'bedrock-assistant', + route: '/assistant', + voiceId: 'joanna', + temperature: 0.5, +}); + +agent.promptAddSection('Role', { body: 'You are a helpful customer service representative.' }); +agent.promptAddSection('Guidelines', { body: 'Be concise and professional.' }); + +agent.defineTool({ + name: 'check_order', + description: 'Look up order status', + parameters: { + order_id: { type: 'string', description: 'Order ID' }, + }, + required: ['order_id'], + handler: async (args) => { + return new FunctionResult(`Order ${args.order_id} is shipped and arriving tomorrow.`); + }, +}); + +agent.setVoice('matthew'); +agent.setInferenceParams(0.3, 0.95); + +await agent.run(); +``` + +### Multi-agent server with Bedrock + +```typescript {8-13} +import { AgentBase, AgentServer, BedrockAgent } from '@signalwire/sdk'; + +// Standard agent +const standardAgent = new AgentBase({ name: 'standard', route: '/standard' }); +standardAgent.setPromptText('You are a general assistant.'); + +// Bedrock voice-to-voice agent +const bedrockAgent = new BedrockAgent({ + name: 'bedrock', + route: '/bedrock', + systemPrompt: 'You are a voice-optimized assistant.', + voiceId: 'matthew', +}); + +const server = new AgentServer(); +server.register(standardAgent); +server.register(bedrockAgent); + +await server.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/set-inference-params.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/set-inference-params.mdx new file mode 100644 index 0000000000..0efdb1e679 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/set-inference-params.mdx @@ -0,0 +1,44 @@ +--- +title: "setInferenceParams" +slug: /reference/typescript/agents/bedrock-agent/set-inference-params +description: "Update Bedrock inference parameters." +max-toc-depth: 3 +--- + +[ref-bedrockagent]: /docs/server-sdks/reference/typescript/agents/bedrock-agent + +Update Bedrock inference parameters. Only the arguments you pass are changed; +an argument left `undefined` keeps its current value. + +## **Parameters** + + + Generation temperature. Range: 0 to 1. + + + + Nucleus sampling parameter. Range: 0 to 1. + + + + Maximum tokens to generate. Accepted for compatibility with the Python SDK. + Not currently applied to the call. + + +## **Returns** + +[`BedrockAgent`][ref-bedrockagent] -- Returns `this` for method chaining. + +## **Example** + +```typescript {9} +import { BedrockAgent } from '@signalwire/sdk'; + +const agent = new BedrockAgent({ + name: 'bedrock-assistant', + route: '/assistant', + systemPrompt: 'You are a helpful assistant.', +}); + +agent.setInferenceParams(0.3, 0.95, 2048); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/set-voice.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/set-voice.mdx new file mode 100644 index 0000000000..01c9981fbd --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/bedrock-agent/set-voice.mdx @@ -0,0 +1,34 @@ +--- +title: "setVoice" +slug: /reference/typescript/agents/bedrock-agent/set-voice +description: "Set the Bedrock voice ID after construction." +max-toc-depth: 3 +--- + +[ref-bedrockagent]: /docs/server-sdks/reference/typescript/agents/bedrock-agent + +Set the Bedrock voice ID after construction. + +## **Parameters** + + + Bedrock voice identifier (e.g., `"matthew"`, `"joanna"`). + + +## **Returns** + +[`BedrockAgent`][ref-bedrockagent] -- Returns `this` for method chaining. + +## **Example** + +```typescript {9} +import { BedrockAgent } from '@signalwire/sdk'; + +const agent = new BedrockAgent({ + name: 'bedrock-assistant', + route: '/assistant', + systemPrompt: 'You are a helpful assistant.', +}); + +agent.setVoice('joanna'); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/cli/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/cli/index.mdx new file mode 100644 index 0000000000..0ddcbb3ccc --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/cli/index.mdx @@ -0,0 +1,35 @@ +--- +title: "CLI Tools" +slug: /reference/typescript/agents/cli +description: "Command-line tool for testing agents locally." +max-toc-depth: 3 +--- + +[swaig-test]: /docs/server-sdks/reference/typescript/agents/cli/swaig-test + +The TypeScript Server SDK ships one command-line tool, `swaig-test`, for local +development. It loads an agent file, renders its SWML, lists its SWAIG +functions, and executes a function with arguments you supply, all without +deploying or placing a call. The package's `bin` entry makes it available +through `npx` after installation. + + + +## Available tools + +| Command | Purpose | +|---------|---------| +| [`swaig-test`][swaig-test] | Test SWAIG functions and generate SWML output locally | + +## Local development workflow + +```bash +# 1. Inspect the generated SWML +npx swaig-test src/agent.ts --dump-swml + +# 2. List available tools +npx swaig-test src/agent.ts --list-tools + +# 3. Test a specific function +npx swaig-test src/agent.ts --exec get_info --arg topic=SignalWire +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/cli/swaig-test.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/cli/swaig-test.mdx new file mode 100644 index 0000000000..481bbae31d --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/cli/swaig-test.mdx @@ -0,0 +1,186 @@ +--- +title: "swaig-test" +slug: /reference/typescript/agents/cli/swaig-test +description: "Test SWAIG functions and generate SWML documents locally without deploying." +max-toc-depth: 3 +--- + +[ref-datamap]: /docs/server-sdks/reference/typescript/agents/data-map + +The `swaig-test` command loads an agent file and lets you render its SWML, list +its SWAIG functions, execute a function, and simulate serverless environments, +all without deploying. It supports both webhook and [DataMap][ref-datamap] +functions. + +```bash +npx swaig-test [options] +``` + + +One action flag is required. A target with no action exits with +`Error: one of --dump-swml, --list-tools, or --exec is required`. The one +exception is `--simulate-serverless`, which renders SWML for the platform on +its own. + + +## Actions + +Choose one action per invocation: + + + List all SWAIG functions registered on the agent, with their parameters. + + + + List all agents exported from the file. Useful for multi-agent files. + + + + Generate and output the full SWML document. Combine with `--raw` for + machine-readable JSON. + + + + Execute a SWAIG function by name. Pass arguments with `--arg key=value`. + + + + Validate the command-line arguments, print `parse OK`, and exit without + loading the agent file, touching the filesystem, or making network requests. + `--dry-run` is an alias. Accepted anywhere on the command line, including + after `--exec`. + + +## Common options + + + Output raw JSON only, suppressing all logs. Designed for piping to `jq`. + + + + Enable verbose output with debug information. + + + + Format output as indented JSON. + + + + Name of the agent class to use when the file exports several. + + + + Override the agent's route. + + +## Function execution options + + + A function argument. Repeat for each argument. + + + + Override a top-level field in the mock call data (e.g., + `--override call_state=answered`). Repeatable. + + +## SWML generation options + + + Simulated call type: `sip` or `webrtc`. + + + + Simulated call direction: `inbound` or `outbound`. + + + + Simulated call state: `active`, `ringing`, or `hold`. + + + + Override the call ID in the mock data. + + + + Override the caller's number in the mock data. + + + + Override the destination extension in the mock data. + + +## Serverless simulation + + + Render SWML as the agent would on a serverless platform. Valid values: + `lambda`, `gcf`, `azure`, and `cgi`. Any other value exits with an error + naming the supported set. + + + + Set an environment variable. Repeatable. Applied after `--env-file`. + + + + Load environment variables from a file (one `KEY=VALUE` per line). + + +## Examples + +### List tools and generate SWML + +```bash +# List all registered SWAIG functions +npx swaig-test src/agent.ts --list-tools + +# Generate the SWML document +npx swaig-test src/agent.ts --dump-swml + +# Generate raw JSON for piping +npx swaig-test src/agent.ts --dump-swml --raw | jq '.' + +# Validate the arguments without loading the agent +npx swaig-test src/agent.ts --parse-only +``` + +### Execute functions + +```bash +# Execute with arguments +npx swaig-test src/agent.ts --exec search --arg query="AI agents" --arg limit=5 + +# Execute with verbose debug output and an overridden caller number +npx swaig-test src/agent.ts --verbose --exec book_ride \ + --arg pickup="123 Gough Street" \ + --override from=+15551234567 +``` + +### Multi-agent files + +```bash +# Discover agents in the file +npx swaig-test src/agents.ts --list-agents + +# Target a specific agent by class name +npx swaig-test src/agents.ts --agent-class SalesAgent --list-tools +``` + +### Serverless simulation + +```bash +# AWS Lambda +npx swaig-test src/agent.ts --simulate-serverless lambda + +# Google Cloud Functions, with environment variables +npx swaig-test src/agent.ts --simulate-serverless gcf \ + --env SWML_BASIC_AUTH_USER=user \ + --env-file .env +``` + +## Exit codes + +| Code | Meaning | +|------|---------| +| `0` | Success | +| `1` | Error (file not found, invalid arguments, execution failure) | diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/configuration/environment-variables.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/configuration/environment-variables.mdx index 77e68b2e16..a61cb75483 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/configuration/environment-variables.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/configuration/environment-variables.mdx @@ -103,6 +103,15 @@ for webhook URL generation. Useful for performance in production when you trust your SWML output. +## Webhook signature validation + + + Your SignalWire Signing Key. When set (or when the `signingKey` constructor + option is passed), the agent validates the signature on every inbound + webhook and rejects unsigned or mis-signed requests with HTTP 403. Treat it + as a secret. + + ## Security @@ -145,7 +154,7 @@ for webhook URL generation. - Log level. + Log level. Case-insensitive; an unrecognized value falls back to `"info"`. - `"debug"` -- verbose output for development and troubleshooting - `"info"` -- standard operational messages @@ -160,6 +169,11 @@ for webhook URL generation. - `"json"` -- structured JSON log lines for log aggregation systems + + Force colored text output on (`"true"`) or off (`"false"`). When unset, color + is enabled only when writing to a terminal. + + ## Skills @@ -169,7 +183,9 @@ for webhook URL generation. ## Relay and REST Client -These variables are shared between the Relay WebSocket client and the REST HTTP client. +`RelayClient`, `RestClient`, and `AIChatClient` read these variables. The +three clients agree on the credential variables but not on `SIGNALWIRE_SPACE`, +so read that entry before setting it in a process that uses more than one client. SignalWire project ID for authentication. @@ -183,8 +199,44 @@ These variables are shared between the Relay WebSocket client and the REST HTTP JWT token for Relay authentication. Alternative to project ID + API token. - - Space hostname used for Relay WebSocket connections and as the REST API base URL. + + Your space hostname, for example `your-space.signalwire.com`. `RestClient` uses + it as the REST API host and throws when neither this variable, the `host` option, + nor `SIGNALWIRE_REST_BASE_URL` is set. `AIChatClient` reads the same variable but + expects the bare space name, `your-space`, and appends `.signalwire.com` itself. + + + +`RelayClient` connects to `relay.signalwire.com` by default and needs no space +setting. When `SIGNALWIRE_SPACE` is set, it connects to that host instead. If +the same process uses REST and Relay, set `SIGNALWIRE_RELAY_HOST=relay.signalwire.com` +or pass `host` to `RelayClient` so the REST setting does not redirect the WebSocket +connection. + + + + Full base URL for REST requests (e.g., `https://your-space.signalwire.com`). + Takes precedence over `SIGNALWIRE_SPACE`; the `host` constructor option + takes precedence over both. + + + + Path to a PEM file of additional CA certificates trusted for REST + connections. Adds trust; it never disables certificate verification. + + + + Override the Relay WebSocket host. Takes precedence over `SIGNALWIRE_SPACE`; + the `host` constructor option takes precedence over both. + + + + WebSocket scheme for the Relay connection, `wss` or `ws`. + + + + Path to a PEM file of additional CA certificates trusted for the Relay + WebSocket connection. Adds trust; it never disables certificate verification. @@ -280,6 +332,7 @@ SIGNALWIRE_LOG_LEVEL=info # Relay / REST SIGNALWIRE_PROJECT_ID=your-project-id SIGNALWIRE_API_TOKEN=your-api-token +# REST host. RelayClient reads it too; set SIGNALWIRE_RELAY_HOST to keep the default. SIGNALWIRE_SPACE=your-space.signalwire.com # Custom Skills diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/configuration/logging.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/configuration/logging.mdx index 271fe7f0d3..0c86a0c4c3 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/configuration/logging.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/configuration/logging.mdx @@ -236,7 +236,8 @@ None. ## **Returns** -`[string, 'off' | 'stderr' | 'default']` -- A tuple of `[environment_name, derived_log_mode]`. +`string` -- The detected environment name. The SDK derives the log mode from +it internally. | Environment | Detection | Log Mode | |-------------|-----------|----------| @@ -251,6 +252,6 @@ None. ```typescript {3} import { getExecutionMode } from '@signalwire/sdk'; -const [env, mode] = getExecutionMode(); -console.log(`Running in ${env} environment (log mode: ${mode})`); +const env = getExecutionMode(); +console.log(`Running in ${env} environment`); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/index.mdx index dc523e6a7c..d12d67ce55 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/index.mdx @@ -87,6 +87,9 @@ You obtain a Context by calling `addContext()` on a ContextBuilder or by calling Set all exit fillers at once. + + Set the default history visibility mode for every step. + Set whether to fully reset conversation history when entering this context. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/set-history.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/set-history.mdx new file mode 100644 index 0000000000..4fd179803d --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/context/set-history.mdx @@ -0,0 +1,37 @@ +--- +title: "setHistory" +slug: /reference/typescript/agents/context-builder/context/set-history +description: Set the default history visibility mode for every step in this context. +max-toc-depth: 3 +--- + +[ref-context]: /docs/server-sdks/reference/typescript/agents/context-builder/context +[step-set-history]: /docs/server-sdks/reference/typescript/agents/context-builder/step/set-history + +Set the default history visibility mode for every step in this context. A +step's own [`setHistory()`][step-set-history] overrides it. See that page for +what each mode does. + +## **Parameters** + + + History visibility mode: `"keep"`, `"default"`, or `"hide"`. Any other string + throws at call time. + + +## **Returns** + +[`Context`][ref-context] -- Self for method chaining. Throws an `Error` if +`history` is not one of the three modes. + +## **Example** + +```typescript {5} +import { ContextBuilder } from '@signalwire/sdk'; + +const builder = new ContextBuilder(); +const ctx = builder.addContext('billing'); +ctx.setHistory('keep'); +ctx.addStep('verify').setText('Verify the account holder.'); +ctx.addStep('dispute').setText('Take the details of the disputed charge.'); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/index.mdx index 88845a281b..2af3c9adee 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/index.mdx @@ -59,6 +59,9 @@ return `this` for fluent method chaining. Set which SWAIG functions are available during this step. + + Control how much prior conversation the model sees at this step. + Enable structured info gathering for this step. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/set-history.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/set-history.mdx new file mode 100644 index 0000000000..799d2642e9 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/agents/context-builder/step/set-history.mdx @@ -0,0 +1,48 @@ +--- +title: "setHistory" +slug: /reference/typescript/agents/context-builder/step/set-history +description: Control how much of the prior conversation the model sees when this step begins. +max-toc-depth: 3 +--- + +[ref-step]: /docs/server-sdks/reference/typescript/agents/context-builder/step +[context-set-history]: /docs/server-sdks/reference/typescript/agents/context-builder/context/set-history + +Control how much of the prior conversation the model sees when this step +begins. The setting applies to everything that came before the step; the step's +own turns accumulate normally, and nothing is deleted from the call log. +Overrides the context-level default set with +[`Context.setHistory()`][context-set-history]. + +## **Parameters** + + + History visibility mode. Any other string throws at call time. + + - `"keep"` -- clear nothing. Every prior step's instructions and dialogue stay + visible to the model. + - `"default"` -- hide the prior steps' instructions but keep the user and + assistant dialogue. This is the behavior when unset. + - `"hide"` -- hide the prior instructions and pull the prior dialogue out of the + model's context. Reference `${step_history.*}` in this step's text to bring + back exactly what you need. + + +## **Returns** + +[`Step`][ref-step] -- Self for method chaining. Throws an `Error` if `history` is +not one of the three modes. + +## **Example** + +```typescript {8} +import { ContextBuilder } from '@signalwire/sdk'; + +const builder = new ContextBuilder(); +const ctx = builder.addContext('default'); + +ctx.addStep('collect_pickup').setText('Ask for the pickup address.'); +ctx.addStep('confirm_fare') + .setHistory('hide') + .setText('Quote the fare for the pickup at ${step_history.collect_pickup} and confirm.'); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/data-map/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/data-map/index.mdx index f520e90e5f..00ea2d45d0 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/data-map/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/data-map/index.mdx @@ -7,8 +7,8 @@ max-toc-depth: 3 [swaigfunction]: /docs/server-sdks/reference/typescript/agents/swaig-function [functionresult]: /docs/server-sdks/reference/typescript/agents/function-result -[data-map]: /docs/swml/reference/ai/swaig/functions/data-map -[swml-data-map-reference]: /docs/swml/reference/ai/swaig/functions/data-map +[data-map]: /docs/swml/reference/calling/ai/swaig/functions/data-map +[swml-data-map-reference]: /docs/swml/reference/calling/ai/swaig/functions/data-map [body]: /docs/server-sdks/reference/typescript/agents/data-map/body [errorkeys]: /docs/server-sdks/reference/typescript/agents/data-map/error-keys [expression]: /docs/server-sdks/reference/typescript/agents/data-map/expression diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/function-result/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/function-result/index.mdx index 839179a9c6..cd6ea0e0d3 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/function-result/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/function-result/index.mdx @@ -8,8 +8,8 @@ max-toc-depth: 3 [tool]: /docs/server-sdks/reference/typescript/agents/agent-base#tool [define-tool]: /docs/server-sdks/reference/typescript/agents/agent-base/define-tool [agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base -[swaig-function]: /docs/swml/reference/ai/swaig/functions -[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[swaig-function]: /docs/swml/reference/calling/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/calling/ai/swaig/functions [setresponse]: /docs/server-sdks/reference/typescript/agents/function-result/set-response [setpostprocess]: /docs/server-sdks/reference/typescript/agents/function-result/set-post-process [addaction]: /docs/server-sdks/reference/typescript/agents/function-result/add-action diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/function-result/record-call.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/function-result/record-call.mdx index 1656070156..45decf813f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/function-result/record-call.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/function-result/record-call.mdx @@ -38,6 +38,7 @@ silence. Use [`stopRecordCall()`][stop-record-call] to end continuous recordings - `"wav"` -- uncompressed WAV audio - `"mp3"` -- compressed MP3 audio + - `"mp4"` -- MP4 container diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/helpers.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/helpers.mdx index ac5ab94504..749148c211 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/helpers.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/helpers.mdx @@ -11,17 +11,20 @@ max-toc-depth: 3 [ref-functionresult]: /docs/server-sdks/reference/typescript/agents/function-result [ref-pombuilder]: /docs/server-sdks/reference/typescript/agents/pom-builder [ref-skillregistry]: /docs/server-sdks/reference/typescript/agents/skill-registry +[ref-skillbase-gettools]: /docs/server-sdks/reference/typescript/agents/skill-base/get-tools +[ref-definetypedtool]: /docs/server-sdks/reference/typescript/agents/agent-base/define-typed-tool The SignalWire Server SDK exports helper functions and utilities at the top level for common tasks like creating standalone contexts, building server-side API tools, managing environment variable expansion, security, and type inference. All are imported directly from `@signalwire/sdk`. -```typescript {2-11} +```typescript {2-12} import { createSimpleContext, createSimpleApiTool, createExpressionTool, + defineSkillTool, setAllowedEnvPrefixes, getAllowedEnvPrefixes, safeAssign, @@ -233,6 +236,68 @@ builder and call `.expression()` multiple times. --- +## **defineSkillTool** + +```typescript {1} +defineSkillTool(toolDef: SkillToolDefinition): SkillToolDefinition +``` + +Build a tool entry for a skill's [`getTools()`][ref-skillbase-gettools] array +with typed handler arguments. The `parameters` schema and `required` list are +captured at compile time, so a required `string` property arrives in the handler +as `args.query: string`, an `enum` narrows to its literal union, and optional +properties are marked `?`. The skill-side counterpart to +[`defineTypedTool()`][ref-definetypedtool]. + +The typing is an authoring convenience only. At runtime `args` is whatever the +model extracted, so keep defensive checks on values that matter. The returned +definition is an ordinary `SkillToolDefinition`, and the generated SWAIG output +is identical to a hand-written entry. + +#### Parameters + + + The tool definition: `name`, `description`, `parameters`, optional + `required`, and a `handler` whose `args` type is inferred from the schema. + + +#### Returns + +`SkillToolDefinition` -- The same definition, ready to return from `getTools()`. + +#### Example + +```typescript {9-23} +import { SkillBase, defineSkillTool, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk'; + +class FareSkill extends SkillBase { + static override SKILL_NAME = 'fare'; + static override SKILL_DESCRIPTION = 'Quote taxi fares.'; + + override getTools(): SkillToolDefinition[] { + return [ + defineSkillTool({ + name: 'quote_fare', + description: 'Quote a fare between two addresses', + parameters: { + pickup: { type: 'string', description: 'Pickup address' }, + dropoff: { type: 'string', description: 'Drop-off address' }, + }, + required: ['pickup', 'dropoff'], + handler: async (args) => { + if (!args.pickup.trim() || !args.dropoff.trim()) { + return new FunctionResult('Provide both addresses.'); + } + return new FunctionResult(`Estimated fare from ${args.pickup} to ${args.dropoff}: $32.`); + }, + }), + ]; + } +} +``` + +--- + ## **setAllowedEnvPrefixes** ```typescript {1} diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/overview.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/overview.mdx index 8a24eb923b..64a56a8968 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/overview.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/overview.mdx @@ -8,7 +8,7 @@ max-toc-depth: 3 position: 0 --- -[swml]: /docs/swml/reference/ai +[swml]: /docs/swml/reference/calling/ai [agent-base]: /docs/server-sdks/reference/typescript/agents/agent-base [swml-service]: /docs/server-sdks/reference/typescript/agents/swml-service [swml-builder]: /docs/server-sdks/reference/typescript/agents/swml-builder @@ -20,14 +20,13 @@ position: 0 [pom-builder]: /docs/server-sdks/reference/typescript/agents/pom-builder [agent-server]: /docs/server-sdks/reference/typescript/agents/agent-server [bedrock-agent]: /docs/server-sdks/reference/typescript/agents/bedrock-agent +[ai-chat-client]: /docs/server-sdks/reference/typescript/agents/ai-chat-client +[parameter-schema]: /docs/server-sdks/reference/typescript/agents/parameter-schema [prefabs]: /docs/server-sdks/reference/typescript/agents/prefabs [skills]: /docs/server-sdks/reference/typescript/agents/skills [cli]: /docs/server-sdks/reference/typescript/agents/cli [configuration]: /docs/server-sdks/reference/typescript/agents/configuration [livewire]: /docs/server-sdks/reference/typescript/agents/livewire -[search]: /docs/server-sdks/reference/typescript/agents/search -[mcp-gateway]: /docs/server-sdks/reference/typescript/agents/mcp-gateway -[web-service]: /docs/server-sdks/reference/typescript/agents/web-service [helpers]: /docs/server-sdks/reference/typescript/agents/helpers [ref-agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base @@ -69,9 +68,9 @@ agent.defineTool({ }, }); -agent.addSkill('datetime'); +await agent.addSkillByName('datetime'); -agent.run(); +await agent.run(); ``` ## Classes @@ -137,6 +136,24 @@ agent.run(); > Host multiple agents on a single Hono process with route-based dispatch. + + Agent backed by the Amazon Bedrock voice-to-voice model. + + + Hold a text conversation with an AI agent from your own server. + + + Fluent builder for typed SWAIG tool parameter schemas. + Built-in skills catalog with 19 pluggable capabilities. + + Test SWAIG functions and render SWML locally with swaig-test. + + Add a property with an explicit JSON Schema `type` (`string`, `number`, + `integer`, `boolean`, `array`, or `object`). `extra` merges additional JSON + Schema keywords such as `enum`, `pattern`, `format`, or `items` into the + property. + + + + Add a `string` property. + + + + Add an `integer` property. + + + + Add a `number` property. + + + + Add a `boolean` property. + + + + Add an `array` property. `items` is the JSON Schema for each element, such as + `{ type: 'string' }`. Omit it for an untyped array. + + + + Add a property constrained to a closed set of values, emitted as `enum` in the + order given. `type` defaults to `string`. + + + + Add a `record_call` format property with `enum: ['wav', 'mp3', 'mp4']`. + + + + Add a `record_call` direction property with `enum: ['speak', 'listen', 'both']`. + + + + Add a `tap` direction property with `enum: ['speak', 'hear', 'both']`. + + + + Add a `tap` codec property with `enum: ['PCMU', 'PCMA']`. + + + + Mark already-added properties as required. Names are recorded in the order + given; duplicates are ignored. + + + + Return the plain `{ type: 'object', properties, required? }` object. `required` + is present only when at least one property was marked required. + + +## **Constants** + +The closed sets behind the typed helpers are exported as `as const` arrays, +each with a matching union type. + + + `['wav', 'mp3', 'mp4']` + + + + `['speak', 'listen', 'both']` + + + + `['speak', 'hear', 'both']` + + + + `['PCMU', 'PCMA']` + + +## **Example** + +```typescript {5-10,15} +import { AgentBase, FunctionResult, paramSchema } from '@signalwire/sdk'; + +const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' }); + +const params = paramSchema() + .string('pickup', 'Street address for the pickup') + .enum('vehicle', ['sedan', 'van', 'wheelchair'], 'Vehicle type') + .integer('passengers', 'Number of riders') + .required('pickup', 'vehicle') + .build(); + +agent.defineTool({ + name: 'book_ride', + description: 'Book a taxi for the caller', + parameters: params, + handler: async (args) => { + return new FunctionResult(`Booked a ${args.vehicle} to ${args.pickup}.`); + }, +}); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/define-tool.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/define-tool.mdx index 706ccea10f..0a19e09d6e 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/define-tool.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/define-tool.mdx @@ -44,8 +44,10 @@ directly instead. Async function invoked when the AI calls the tool. - - When `true`, the tool requires signed tokens for invocation. + + Whether to require token validation on tool calls. Tools are secure by + default: the rendered webhook URL carries a per-tool token. Pass `false` + only to expose the tool on the shared, unauthenticated webhook URL. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/get-tools.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/get-tools.mdx index d5bada4af7..3320e55b77 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/get-tools.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skill-base/get-tools.mdx @@ -6,6 +6,7 @@ max-toc-depth: 3 --- [ref-skillbase]: /docs/server-sdks/reference/typescript/agents/skill-base +[ref-defineskilltool]: /docs/server-sdks/reference/typescript/agents/helpers#defineskilltool Return the SWAIG tool definitions this skill exposes. Called by the `SkillManager` at SWML render time to collect every tool that should appear in @@ -48,6 +49,10 @@ class WeatherSkill extends SkillBase { } ``` +Wrap an entry in [`defineSkillTool()`][ref-defineskilltool] to have the +handler's `args` typed from the `parameters` schema instead of +`Record`. + ## **Example — imperative via defineTool()** ```typescript {5-13} diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skills/google-maps.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skills/google-maps.mdx index 45e058a4f7..6b6be642ce 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skills/google-maps.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skills/google-maps.mdx @@ -1,18 +1,18 @@ --- title: "GoogleMapsSkill" slug: /reference/typescript/agents/skills/google-maps -description: Get driving/walking/transit directions and search for places using Google Maps APIs. +description: Validate addresses and compute driving routes using Google Maps APIs. --- [add-skill]: /docs/server-sdks/reference/typescript/agents/agent-base/add-skill -Get driving/walking/transit directions, find places, geocode addresses, and -compute routes by coordinates using Google Maps APIs. +Validate and geocode a street address or business name, and compute the +driving distance and travel time between two coordinates, using Google Maps +APIs. **Class:** `GoogleMapsSkill` -**Tools:** `compute_route`, `lookup_address`, `geocode_address`, -`compute_route_by_coords` (each tool name is configurable). +**Tools:** `lookup_address`, `compute_route` (each tool name is configurable). **Env vars:** `GOOGLE_MAPS_API_KEY` (required — the tool handlers read this directly and do not fall back to an `api_key` config value). @@ -23,11 +23,6 @@ directly and do not fall back to an `api_key` config value). value is not used as a fallback. - - Default travel mode for `compute_route`: `"driving"`, `"walking"`, - `"bicycling"`, or `"transit"`. - - Custom name for the route computation tool. @@ -36,14 +31,6 @@ directly and do not fall back to an `api_key` config value). Custom name for the address / place lookup tool. - - Custom name for the address-to-coordinates geocode tool. - - - - Custom name for the coordinate-based route computation tool. - - ```typescript {6-8} import { AgentBase, GoogleMapsSkill } from '@signalwire/sdk'; @@ -51,7 +38,7 @@ const agent = new AgentBase({ name: 'assistant', route: '/assistant' }); agent.setPromptText('You are a helpful assistant.'); await agent.addSkill(new GoogleMapsSkill({ - default_mode: 'transit', + route_tool_name: 'get_driving_time', })); agent.run(); diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skills/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skills/index.mdx index 5bc3957d5e..364c2929fc 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skills/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skills/index.mdx @@ -6,7 +6,6 @@ max-toc-depth: 3 --- [add-skill]: /docs/server-sdks/reference/typescript/agents/agent-base/add-skill -[sw-search]: /docs/server-sdks/reference/typescript/agents/cli/sw-search [infogathereragent]: /docs/server-sdks/reference/typescript/agents/prefabs#infogathereragent [skillbase]: /docs/server-sdks/reference/typescript/agents/skill-base [ref-datamap]: /docs/server-sdks/reference/typescript/agents/data-map @@ -46,8 +45,8 @@ agent.run(); | [`weather_api`](/docs/server-sdks/reference/typescript/agents/skills/weather-api) | `WeatherApiSkill` | 1 | Yes | No | | [`web_search`](/docs/server-sdks/reference/typescript/agents/skills/web-search) | `WebSearchSkill` | 1 | Yes | Yes | | [`wikipedia_search`](/docs/server-sdks/reference/typescript/agents/skills/wikipedia-search) | `WikipediaSearchSkill` | 1 | No | No | -| [`google_maps`](/docs/server-sdks/reference/typescript/agents/skills/google-maps) | `GoogleMapsSkill` | 4 | Yes | No | -| [`play_background_file`](/docs/server-sdks/reference/typescript/agents/skills/play-background-file) | `PlayBackgroundFileSkill` | 1-3 | No | Yes | +| [`google_maps`](/docs/server-sdks/reference/typescript/agents/skills/google-maps) | `GoogleMapsSkill` | 2 | Yes | No | +| [`play_background_file`](/docs/server-sdks/reference/typescript/agents/skills/play-background-file) | `PlayBackgroundFileSkill` | 1 | No | Yes | | [`swml_transfer`](/docs/server-sdks/reference/typescript/agents/skills/swml-transfer) | `SwmlTransferSkill` | 1-2 | No | Yes | | [`datasphere`](/docs/server-sdks/reference/typescript/agents/skills/datasphere) | `DataSphereSkill` | 1 | Yes | Yes | | [`datasphere_serverless`](/docs/server-sdks/reference/typescript/agents/skills/datasphere-serverless) | `DataSphereServerlessSkill` | 1 | Yes | Yes | diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skills/joke.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skills/joke.mdx index f12d37c476..5026ea0091 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skills/joke.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skills/joke.mdx @@ -12,11 +12,12 @@ categories. No external API required. **Class:** `JokeSkill` -**Tools:** `tell_joke` (configurable via `tool_name`) +**Tools:** `get_joke` (configurable via `tool_name`). Takes one required +argument, `type`, which is `jokes` or `dadjokes`. **Env vars:** None - + Custom name for the joke tool. Overrides the default SWAIG function name. diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skills/mcp-gateway.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skills/mcp-gateway.mdx index 0207ac481d..c31019660f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skills/mcp-gateway.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skills/mcp-gateway.mdx @@ -69,9 +69,22 @@ cloud-metadata endpoints are rejected. Requests use retry semantics with - Whether to verify SSL certificates on outbound requests. + Whether to verify TLS certificates on outbound requests. Setting this to + `false` alone is ignored; verification stays on unless `allow_insecure_tls` + is also `true`. + + Explicit opt-in that, together with `verify_ssl: false`, disables TLS + certificate verification. + + + +With `verify_ssl: false` and `allow_insecure_tls: true`, outbound requests to +the gateway accept any certificate and are exposed to interception. Use it only +against a trusted self-signed gateway on a private network. + + ## Example ```typescript {6-13} diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/skills/play-background-file.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/skills/play-background-file.mdx index 6860da72cb..60de67da1f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/skills/play-background-file.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/skills/play-background-file.mdx @@ -1,43 +1,32 @@ --- title: "PlayBackgroundFileSkill" slug: /reference/typescript/agents/skills/play-background-file -description: Control background audio/video playback during calls. Supports pre-configured file list or free-form URL playback. +description: Control background audio/video playback during calls from a pre-configured file list. --- [add-skill]: /docs/server-sdks/reference/typescript/agents/agent-base/add-skill Control background audio/video playback during calls using SWML playback -actions. Two configuration modes are supported: - -- **Pre-configured mode (matches Python)** — supply `files` and the skill - emits a single tool whose `action` enum includes `start_` for each - configured file plus `stop`. -- **Free-form mode (TypeScript-specific)** — omit `files` and supply - `default_file_url` and/or `allowed_domains`. The skill emits two tools, - `play_background` and `stop_background`, which accept arbitrary URLs (with - optional domain allowlist). +actions. Supply `files` and the skill emits a single tool whose `action` enum +includes `start_` for each configured file plus `stop`. The skill refuses +to load when `files` is empty. **Class:** `PlayBackgroundFileSkill` -**Tools (pre-configured mode):** `play_background_file` (configurable via -`tool_name`) - -**Tools (free-form mode):** `play_background`, `stop_background` +**Tools:** `play_background_file` (configurable via `tool_name`) **Env vars:** None **Multi-instance:** yes — set a distinct `tool_name` per instance. - Custom name for the generated SWAIG tool in pre-configured mode. Required - when registering multiple instances on the same agent. + Custom name for the generated SWAIG tool. Required when registering + multiple instances on the same agent. - + Array of pre-configured file entries that become selectable via the tool's - `action` enum. When supplied (and non-empty), the skill runs in - pre-configured mode; when omitted or empty, the skill falls back to - free-form mode. + `action` enum. Each entry has: @@ -50,18 +39,7 @@ actions. Two configuration modes are supported: file to finish playing. - - Default audio file URL for free-form mode. When set, the `file_url` - parameter on the `play_background` tool becomes optional. - - - - Allowlist of domains for audio file URLs in free-form mode. When set, only - URLs whose hostname matches or is a subdomain of one of these entries are - accepted. - - -## Example — pre-configured files +## Example ```typescript {6-14} import { AgentBase, PlayBackgroundFileSkill } from '@signalwire/sdk'; @@ -83,12 +61,3 @@ await agent.addSkill(new PlayBackgroundFileSkill({ agent.run(); ``` - -## Example — free-form URL - -```typescript {6-9} -await agent.addSkill(new PlayBackgroundFileSkill({ - default_file_url: 'https://example.com/hold-music.mp3', - allowed_domains: ['example.com', 'cdn.example.com'], -})); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swaig-function/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swaig-function/index.mdx index 6b94b12e8d..1f4fff5cd9 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swaig-function/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swaig-function/index.mdx @@ -10,8 +10,8 @@ max-toc-depth: 3 [agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base [datamap]: /docs/server-sdks/reference/typescript/agents/data-map [functionresult]: /docs/server-sdks/reference/typescript/agents/function-result -[swaig-function-definition]: /docs/swml/reference/ai/swaig/functions -[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[swaig-function-definition]: /docs/swml/reference/calling/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/calling/ai/swaig/functions [execute]: /docs/server-sdks/reference/typescript/agents/swaig-function/execute [toswaig]: /docs/server-sdks/reference/typescript/agents/swaig-function/to-swaig [validateargs]: /docs/server-sdks/reference/typescript/agents/swaig-function/validate-args @@ -67,8 +67,9 @@ const fn = new SwaigFunction(opts); JSON Schema `properties` object describing the tool's parameters. - - Whether the tool requires session token authentication. + + Whether the tool requires session token authentication. Pass `false` to + expose the tool on the shared, unauthenticated webhook URL. "} toc={true}> diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-section.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-section.mdx index 2537f04c0f..b1197e4071 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-section.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-section.mdx @@ -38,5 +38,5 @@ builder.addVerbToSection('fallback', 'play', { }); builder.addVerbToSection('fallback', 'hangup', {}); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb-to-section.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb-to-section.mdx index 92dcbd9db7..d0f327c3ab 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb-to-section.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb-to-section.mdx @@ -5,8 +5,19 @@ description: "Append a verb to a named section, creating the section if it does max-toc-depth: 3 --- +[add-verb]: /docs/server-sdks/reference/typescript/agents/swml-builder/add-verb + Append a verb to a named section of the SWML document. If the section does not -exist, it is created automatically. +exist, it is created automatically. The verb config is validated against the +bundled schema when validation is enabled, exactly as in [`addVerb()`][add-verb]. + + +Validation is strict. An unknown verb name, an unknown or misspelled key inside +the verb config, or a value of the wrong type throws a `SchemaValidationError` +instead of being dropped silently. Earlier SDK versions appended to non-main +sections without validating. Set `SWML_SKIP_SCHEMA_VALIDATION=true` to disable +validation. + ## **Parameters** @@ -38,5 +49,5 @@ builder.addVerbToSection('goodbye', 'play', { }); builder.addVerbToSection('goodbye', 'hangup', {}); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb.mdx index 481a6bb98f..c154da5b30 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/add-verb.mdx @@ -8,6 +8,13 @@ max-toc-depth: 3 Append a verb to the `main` section of the SWML document. Validates the verb config against the bundled schema when validation is enabled. + +Validation is strict. An unknown verb name, an unknown or misspelled key inside +the verb config, or a value of the wrong type throws a `SchemaValidationError` +instead of being dropped silently. Set `SWML_SKIP_SCHEMA_VALIDATION=true` to +disable validation. + + ## **Parameters** @@ -21,8 +28,8 @@ against the bundled schema when validation is enabled. ## **Returns** -`void` -- Throws an `Error` if the verb fails schema validation (when validation -is enabled and the verb is defined in the schema). +`void` -- Throws a `SchemaValidationError` if the verb fails schema validation +(when validation is enabled). ## **Example** @@ -34,5 +41,5 @@ builder.addVerb('answer', {}); builder.addVerb('play', { url: 'https://example.com/greeting.mp3' }); builder.addVerb('hangup', {}); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/ai.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/ai.mdx index 1f9016bac7..51d0e1cd6f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/ai.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/ai.mdx @@ -14,7 +14,7 @@ passed directly as the AI verb's configuration payload in the SWML document. Optional configuration object for the AI verb. The structure matches the - [SWML AI verb specification](/docs/swml/reference/ai) and may include keys such as + [SWML AI verb specification](/docs/swml/reference/calling/ai) and may include keys such as `prompt`, `post_prompt`, `post_prompt_url`, `swaig`, `hints`, `languages`, `params`, and `global_data`. @@ -41,5 +41,5 @@ builder.ai({ post_prompt_url: 'https://example.com/summary', }); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/build.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/build.mdx index 358cf3f5d0..5c54906904 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/build.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/build.mdx @@ -1,17 +1,17 @@ --- title: "build" slug: /reference/typescript/agents/swml-builder/build -description: "Build and return the SWML document as an object (Python-compat alias for getDocument)." +description: "Build and return the SWML document as an object." max-toc-depth: 3 --- -[ref-getdocument]: /docs/server-sdks/reference/typescript/agents/swml-builder/get-document [ref-render]: /docs/server-sdks/reference/typescript/agents/swml-builder/render +[ref-document]: /docs/server-sdks/reference/typescript/agents/swml-builder/document -Return the SWML document as a plain object. Python-compat alias for -[`getDocument()`][ref-getdocument]; the two are functionally identical. Use -`build()` when porting from the Python SDK. For a JSON string, use -[`render()`][ref-render] or `renderDocument()`. +Return the SWML document as a plain object. The name matches the Python SDK's +`SWMLBuilder.build()`. For a JSON string, use [`render()`][ref-render]. For +property-style access to the same object, use the [`document`][ref-document] +getter. ## **Returns** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/document.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/document.mdx index 3155a9f1ed..eb7d9d1113 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/document.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/document.mdx @@ -5,16 +5,16 @@ description: "Read-only accessor for the underlying SWML document." max-toc-depth: 3 --- -[ref-getdocument]: /docs/server-sdks/reference/typescript/agents/swml-builder/get-document +[ref-build]: /docs/server-sdks/reference/typescript/agents/swml-builder/build Read-only getter for the underlying SWML document object. Provides direct access to the mutable document (the returned reference is the internal object, -not a copy). Equivalent to the Python SDK's `service` property on `SWMLBuilder`. +not a copy). -Prefer [`getDocument()`][ref-getdocument] when you want an explicit method -call for symmetry with other accessors. The `document` getter exists for -callers that want property-style access. +Prefer [`build()`][ref-build] when you want an explicit method call for +symmetry with other accessors. The `document` getter exists for callers that +want property-style access. ## **Type** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/get-document.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/get-document.mdx deleted file mode 100644 index 1db887ffb1..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/get-document.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "getDocument" -slug: /reference/typescript/agents/swml-builder/get-document -description: "Return the raw SWML document object." -max-toc-depth: 3 ---- - -Returns the raw SWML document object containing the version string and all sections -with their verb arrays. - -## **Parameters** - -This method takes no parameters. - -## **Returns** - -`Record` -- The SWML document object with `version` and `sections` keys. - -## **Example** - -```typescript {7} -import { SwmlBuilder } from '@signalwire/sdk'; - -const builder = new SwmlBuilder(); -builder.addVerb('answer', {}); -builder.addVerb('play', { url: 'https://example.com/audio.mp3' }); - -const doc = builder.getDocument(); -console.log(doc); -// { version: '1.0.0', sections: { main: [ { answer: {} }, { play: { url: '...' } } ] } } -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/index.mdx index 1fad956ef6..07ffaa60d6 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/index.mdx @@ -6,17 +6,15 @@ max-toc-depth: 3 --- [swmlservice]: /docs/server-sdks/reference/typescript/agents/swml-service -[swml]: /docs/swml/reference/ai -[swml-reference]: /docs/swml/reference/ai +[swml]: /docs/swml/reference/calling/ai +[swml-reference]: /docs/swml/reference/calling/ai [addverb]: /docs/server-sdks/reference/typescript/agents/swml-builder/add-verb [addverbtosection]: /docs/server-sdks/reference/typescript/agents/swml-builder/add-verb-to-section [ai]: /docs/server-sdks/reference/typescript/agents/swml-builder/ai [answer]: /docs/server-sdks/reference/typescript/agents/swml-builder/answer -[getdocument]: /docs/server-sdks/reference/typescript/agents/swml-builder/get-document [getschemautils]: /docs/server-sdks/reference/typescript/agents/swml-builder/get-schema-utils [hangup]: /docs/server-sdks/reference/typescript/agents/swml-builder/hangup [play]: /docs/server-sdks/reference/typescript/agents/swml-builder/play -[renderdocument]: /docs/server-sdks/reference/typescript/agents/swml-builder/render-document [reset]: /docs/server-sdks/reference/typescript/agents/swml-builder/reset SwmlBuilder provides a fluent interface for constructing SWML documents by chaining @@ -77,7 +75,7 @@ builder.answer(); builder.play({ url: 'https://example.com/greeting.mp3' }); builder.hangup(); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` The `sleep` verb is a special case -- it accepts either a number (duration) directly @@ -91,7 +89,7 @@ builder.answer(); builder.sleep(2000); builder.hangup(); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` ## **Methods** @@ -109,9 +107,6 @@ console.log(builder.renderDocument()); Add an answer verb to the SWML document. - - Return the raw SWML document object. - Get the shared SchemaUtils singleton (static). @@ -121,9 +116,6 @@ console.log(builder.renderDocument()); Add a play verb to play audio or text-to-speech. - - Serialize the SWML document to a JSON string. - Reset the SWML document to an empty state. @@ -131,10 +123,10 @@ console.log(builder.renderDocument()); Add a new named section to the document. - Build and return the document (Python-compat alias for getDocument). + Build and return the SWML document as an object. - Render the document as JSON (Python-compat alias for renderDocument). + Render the SWML document as a JSON string. Property-style read-only accessor for the underlying document. @@ -160,7 +152,7 @@ const doc = builder .play({ url: 'https://example.com/welcome.mp3' }) .sleep(1000) .hangup() - .getDocument(); + .build(); console.log(doc); ``` @@ -198,7 +190,7 @@ builder params: { end_of_speech_timeout: 500 }, }); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` ### Multi-Section Document @@ -218,5 +210,5 @@ builder.addVerbToSection('goodbye', 'play', { }); builder.addVerbToSection('goodbye', 'hangup', {}); -console.log(builder.renderDocument()); +console.log(builder.render()); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render-document.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render-document.mdx deleted file mode 100644 index 8d37924f06..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render-document.mdx +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: "renderDocument" -slug: /reference/typescript/agents/swml-builder/render-document -description: "Serialize the SWML document to a JSON string." -max-toc-depth: 3 ---- - -Serializes the SWML document to a JSON string using `JSON.stringify`. - -## **Parameters** - -This method takes no parameters. - -## **Returns** - -`string` -- The JSON-encoded SWML document. - -## **Example** - -```typescript {7} -import { SwmlBuilder } from '@signalwire/sdk'; - -const builder = new SwmlBuilder(); -builder.addVerb('answer', {}); -builder.addVerb('hangup', {}); - -const json = builder.renderDocument(); -console.log(json); -// '{"version":"1.0.0","sections":{"main":[{"answer":{}},{"hangup":{}}]}}' -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render.mdx index b68fa11db9..46f0e56b47 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-builder/render.mdx @@ -1,17 +1,15 @@ --- title: "render" slug: /reference/typescript/agents/swml-builder/render -description: "Render the SWML document as a JSON string (Python-compat alias for renderDocument)." +description: "Render the SWML document as a JSON string." max-toc-depth: 3 --- -[ref-renderdocument]: /docs/server-sdks/reference/typescript/agents/swml-builder/render-document [ref-build]: /docs/server-sdks/reference/typescript/agents/swml-builder/build -Render the SWML document as a JSON string. Python-compat alias for -[`renderDocument()`][ref-renderdocument]; the two are functionally identical. -Use `render()` when porting from the Python SDK. For the document as a plain -object, use [`build()`][ref-build] or `getDocument()`. +Render the SWML document as a JSON string. The name matches the Python SDK's +`SWMLBuilder.render()`. For the document as a plain object, use +[`build()`][ref-build]. ## **Returns** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/as-router.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/as-router.mdx index 9c1ace64f3..547567e906 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/as-router.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/as-router.mdx @@ -27,8 +27,9 @@ instance via [`AgentServer`][ref-agentserver]. ## **Returns** -`Hono` -- the configured Hono app with all routes registered (SWML document -endpoint plus any routing-callback paths). +`HostAppRouter` -- the configured Hono app with all routes registered (SWML +document endpoint plus any routing-callback paths). `HostAppRouter` is a type +alias for `Hono`. ## **Example** diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/define-tool.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/define-tool.mdx index d7a5fb2a62..418a452833 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/define-tool.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/define-tool.mdx @@ -5,8 +5,8 @@ description: Define a SWAIG tool on a SWMLService instance. max-toc-depth: 3 --- -[swaig-function]: /docs/swml/reference/ai/swaig/functions -[swml-swaig-functions-reference]: /docs/swml/reference/ai/swaig/functions +[swaig-function]: /docs/swml/reference/calling/ai/swaig/functions +[swml-swaig-functions-reference]: /docs/swml/reference/calling/ai/swaig/functions [functionresult]: /docs/server-sdks/reference/typescript/agents/function-result [ref-swmlservice]: /docs/server-sdks/reference/typescript/agents/swml-service @@ -48,8 +48,9 @@ specification. return a [`FunctionResult`][functionresult]. - - Whether to require token validation on tool calls. + + Whether to require token validation on tool calls. Pass `false` to expose + the tool on the shared, unauthenticated webhook URL. "} toc={true}> diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/index.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/index.mdx index 2548d04515..66bf16d86d 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/index.mdx @@ -6,8 +6,8 @@ max-toc-depth: 3 --- [agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base -[swml]: /docs/swml/reference/ai -[swml-reference]: /docs/swml/reference/ai +[swml]: /docs/swml/reference/calling/ai +[swml-reference]: /docs/swml/reference/calling/ai [swmlbuilder]: /docs/server-sdks/reference/typescript/agents/swml-builder [addverb]: /docs/server-sdks/reference/typescript/agents/swml-service/add-verb [getapp]: /docs/server-sdks/reference/typescript/agents/swml-service/get-app diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-document.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-document.mdx index 51e2156fb6..74806994a2 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-document.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-document.mdx @@ -10,7 +10,7 @@ max-toc-depth: 3 Render the current SWML document as a JSON string. This is the serialized form returned to SignalWire when a call requests SWML. Delegates to -`SwmlBuilder.renderDocument()` under the hood. +`SwmlBuilder.render()` under the hood. For the document as a plain object, use [`getDocument()`][ref-getdocument] or diff --git a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-swml.mdx b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-swml.mdx index 013ca750bb..0c313b2580 100644 --- a/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-swml.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/agents/swml-service/render-swml.mdx @@ -6,7 +6,7 @@ max-toc-depth: 3 --- Render the current SWML document. For a plain `SWMLService`, this delegates to -the underlying `SwmlBuilder`'s `getDocument()` method and returns the in-memory +the underlying `SwmlBuilder`'s `build()` method and returns the in-memory document object. The signature accepts optional `callId` and `modifications` arguments. These are diff --git a/fern/products/server-sdks/pages/reference/typescript/core/security/index.mdx b/fern/products/server-sdks/pages/reference/typescript/core/security/index.mdx index ac70974445..cf58384ce9 100644 --- a/fern/products/server-sdks/pages/reference/typescript/core/security/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/core/security/index.mdx @@ -8,6 +8,7 @@ max-toc-depth: 3 [agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base [validate-webhook-signature]: /docs/server-sdks/reference/typescript/core/security/validate-webhook-signature [validate-request]: /docs/server-sdks/reference/typescript/core/security/validate-request +[validate]: /docs/server-sdks/reference/typescript/core/security/validate [webhook-validation-middleware]: /docs/server-sdks/reference/typescript/core/security/webhook-validation-middleware SignalWire signs the webhook requests it sends to your endpoints. These @@ -18,6 +19,7 @@ All are imported directly from `@signalwire/sdk`. import { validateWebhookSignature, validateRequest, + validate, webhookValidationMiddleware, SIGNALWIRE_SIGNATURE_HEADER, TWILIO_COMPAT_SIGNATURE_HEADER, @@ -38,7 +40,10 @@ for you. Verify a signature against a raw request body. - Legacy compatibility-api drop-in accepting parsed form params. + Verify a signature against a raw body or pre-parsed form params. + + + Framework-free validator that returns a rejection triple or null. Hono middleware that validates and rejects unsigned requests. @@ -52,6 +57,6 @@ for you. - The Twilio-compatible signature header name: `'x-twilio-signature'`, - recognized on the compatibility surface. + The legacy signature header name, `'x-twilio-signature'`. The validators + accept it as an alias of `SIGNALWIRE_SIGNATURE_HEADER`. diff --git a/fern/products/server-sdks/pages/reference/typescript/core/security/validate-request.mdx b/fern/products/server-sdks/pages/reference/typescript/core/security/validate-request.mdx index 6f3d9e348f..ae68ada313 100644 --- a/fern/products/server-sdks/pages/reference/typescript/core/security/validate-request.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/core/security/validate-request.mdx @@ -1,16 +1,16 @@ --- title: "validateRequest" slug: /reference/typescript/core/security/validate-request -description: "Legacy compatibility-api drop-in for webhook signature validation." +description: "Verify a webhook signature from a raw body or pre-parsed form params." max-toc-depth: 3 --- [validate-webhook-signature]: /docs/server-sdks/reference/typescript/core/security/validate-webhook-signature Verify a SignalWire webhook signature, accepting either a raw body string or -pre-parsed form params. This is the drop-in replacement for the legacy -`@signalwire/compatibility-api` `validateRequest`. For new code that has access -to the raw body, prefer [`validateWebhookSignature()`][validate-webhook-signature]. +pre-parsed form params. Use it when your framework has already parsed the form +body and the raw bytes are gone. When you have the raw body, prefer +[`validateWebhookSignature()`][validate-webhook-signature]. ```typescript {1} validateRequest(signingKey: string, signature: string, url: string, paramsOrRawBody: string | Record | Array<[string, unknown]> | null | undefined): boolean @@ -38,14 +38,15 @@ validateRequest(signingKey: string, signature: string, url: string, paramsOrRawB ## **Returns** `boolean` -- `true` when the signature matches; `false` otherwise. The -comparison is constant-time. +comparison is constant-time. Throws a `TypeError` when `paramsOrRawBody` is +neither a string nor a record, `Map`, or array of tuples. ## **Example** ```typescript {6} import { validateRequest } from '@signalwire/sdk'; -// Pre-parsed form params (compat surface) +// Pre-parsed form params const params = { From: '+15551234567', To: '+15559876543' }; const ok = validateRequest( diff --git a/fern/products/server-sdks/pages/reference/typescript/core/security/validate.mdx b/fern/products/server-sdks/pages/reference/typescript/core/security/validate.mdx new file mode 100644 index 0000000000..625b5705f6 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/core/security/validate.mdx @@ -0,0 +1,77 @@ +--- +title: "validate" +slug: /reference/typescript/core/security/validate +description: "Framework-free webhook validation that returns a rejection triple or null." +max-toc-depth: 3 +--- + +[validate-webhook-signature]: /docs/server-sdks/reference/typescript/core/security/validate-webhook-signature +[webhook-validation-middleware]: /docs/server-sdks/reference/typescript/core/security/webhook-validation-middleware + +Decide whether an inbound webhook is authentic from plain request primitives, +with no framework request or response objects. Returns `null` to let the +request through, or a `[status, headers, body]` triple to write back verbatim. +[`webhookValidationMiddleware()`][webhook-validation-middleware] is a thin Hono +wrapper over this function; use `validate()` directly from any other server. + +```typescript {1} +validate(method: string, url: string, headers: Record, body: string, signingKey: string): WebhookRejection | null +``` + +## **Parameters** + + + The HTTP method. Informational; the signature does not cover it. + + + + The full public URL SignalWire POSTed to, including scheme, host, path, and + query. Reconstruct it behind a proxy or tunnel before calling. + + +"} required={true} toc={true}> + Request headers. The signature header is looked up case-insensitively under + `X-SignalWire-Signature`, or the legacy `X-Twilio-Signature` alias. + + + + The raw request body as a string, before any JSON or form parsing. + + + + Your SignalWire Signing Key. An empty or non-string value throws an `Error`. + + +## **Returns** + +`WebhookRejection | null` -- `null` when the signature is valid. Otherwise a +`[403, {}, 'Forbidden']` triple, whether the header is missing, empty, or +wrong. The body never says which check failed. + +## **Example** + +```typescript {8-13} +import { createServer } from 'node:http'; +import { validate } from '@signalwire/sdk'; + +createServer(async (req, res) => { + const chunks: Buffer[] = []; + for await (const chunk of req) chunks.push(chunk as Buffer); + const body = Buffer.concat(chunks).toString(); + const rejection = validate( + req.method ?? 'POST', + `https://${req.headers.host}${req.url}`, + req.headers as Record, + body, + process.env.SIGNALWIRE_SIGNING_KEY!, + ); + if (rejection) { + const [status, headers, text] = rejection; + res.writeHead(status, headers); + res.end(text); + return; + } + // handle the authentic webhook + res.end('ok'); +}).listen(3000); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/ai.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/ai.mdx index b4d4449bdf..9687e7ed81 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/call/ai.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/ai.mdx @@ -8,8 +8,8 @@ max-toc-depth: 3 [aiaction]: /docs/server-sdks/reference/typescript/relay/actions [agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base [amazon-bedrock]: /docs/server-sdks/reference/typescript/relay/call/amazon-bedrock -[ai]: /docs/swml/reference/ai -[swml-ai-reference]: /docs/swml/reference/ai +[ai]: /docs/swml/reference/calling/ai +[swml-ai-reference]: /docs/swml/reference/calling/ai Start an AI agent session on the call. The AI agent handles the conversation using the provided prompt, tools, and configuration. Returns an diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/connect.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/connect.mdx index 6efe2f9a8f..6ef8ea5576 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/call/connect.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/connect.mdx @@ -7,8 +7,8 @@ max-toc-depth: 3 [calling-call-connect]: /docs/server-sdks/reference/typescript/relay/call#events [call-events]: /docs/server-sdks/reference/typescript/relay/call#events -[connect]: /docs/swml/reference/connect -[swml-connect-reference]: /docs/swml/reference/connect +[connect]: /docs/swml/reference/calling/connect +[swml-connect-reference]: /docs/swml/reference/calling/connect [play]: /docs/server-sdks/reference/typescript/relay/call/play Bridge the call to one or more destinations. The `devices` parameter supports @@ -32,8 +32,10 @@ This method corresponds to the SWML [`connect`][connect] verb. See the (all devices in the group ring simultaneously). Each device object contains: - - `"type"` -- Device type (`"phone"`, `"sip"`) - - `"params"` -- Type-specific parameters (`to_number`, `from_number`, etc.) + - `"type"` -- Device type (`"phone"`, `"sip"`, or `"fabric"` for a resource + address) + - `"params"` -- Type-specific parameters (`to_number` and `from_number` for + phone; `to` plus optional `from` and `timeout` for fabric) [] | undefined"} toc={true}> diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-answering-machine.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-answering-machine.mdx new file mode 100644 index 0000000000..b0799b079e --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-answering-machine.mdx @@ -0,0 +1,80 @@ +--- +title: "detectAnsweringMachine" +slug: /reference/typescript/relay/call/detect-answering-machine +description: "Detect whether a human or an answering machine picked up." +max-toc-depth: 3 +--- + +[detectaction]: /docs/server-sdks/reference/typescript/relay/actions +[detect]: /docs/server-sdks/reference/typescript/relay/call/detect + +Detect whether a human or an answering machine picked up. A typed convenience +over [`detect()`][detect] with the `machine` detector. + +## **Parameters** + + + Detector options. Each maps to the matching snake_case param of the + [`detect()`][detect] command's `machine` detector type. + + + + + + Seconds to wait for initial voice before deciding. + + + + Seconds of silence that end the greeting. + + + + Seconds of continuous voice that indicate a machine. + + + + Word count that indicates a machine. + + + + Report interruptions during the greeting. + + + + Keep detecting until the machine's greeting ends, so you can leave a message. + + + + Maximum seconds to run the detector before stopping. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`DetectAction`][detectaction]`>` -- An action handle with `stop()` and `wait()` methods. It resolves on the first detection result. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.detectAnsweringMachine({ detectMessageEnd: true, timeout: 30 }); + const event = await action.wait(); + console.log(event.params); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-digit.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-digit.mdx new file mode 100644 index 0000000000..0c68461869 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-digit.mdx @@ -0,0 +1,59 @@ +--- +title: "detectDigit" +slug: /reference/typescript/relay/call/detect-digit +description: "Detect DTMF digits on a call." +max-toc-depth: 3 +--- + +[detectaction]: /docs/server-sdks/reference/typescript/relay/actions +[detect]: /docs/server-sdks/reference/typescript/relay/call/detect + +Detect DTMF digits on the call. A typed convenience over [`detect()`][detect] +with the `digit` detector. + +## **Parameters** + + + Detector options. + + + + + + The digits to listen for, such as `"0123456789#*"`. + + + + Maximum seconds to run the detector before stopping. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`DetectAction`][detectaction]`>` -- An action handle with `stop()` and `wait()` methods. It resolves on the first detection result. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.detectDigit({ digits: '0#', timeout: 15 }); + const event = await action.wait(); + console.log(event.params); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-fax.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-fax.mdx new file mode 100644 index 0000000000..e115de29df --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/detect-fax.mdx @@ -0,0 +1,59 @@ +--- +title: "detectFax" +slug: /reference/typescript/relay/call/detect-fax +description: "Detect a fax tone on a call." +max-toc-depth: 3 +--- + +[detectaction]: /docs/server-sdks/reference/typescript/relay/actions +[detect]: /docs/server-sdks/reference/typescript/relay/call/detect + +Detect a fax tone on the call. A typed convenience over [`detect()`][detect] +with the `fax` detector. + +## **Parameters** + + + Detector options. + + + + + + `"CED"` (called station) or `"CNG"` (calling station). + + + + Maximum seconds to run the detector before stopping. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`DetectAction`][detectaction]`>` -- An action handle with `stop()` and `wait()` methods. It resolves on the first detection result. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.detectFax({ tone: 'CED', timeout: 20 }); + const event = await action.wait(); + console.log(event.params); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/index.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/index.mdx index 75178eb248..6472b6fa49 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/call/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/index.mdx @@ -110,6 +110,10 @@ objects that let you stop, pause, or wait for the operation to complete. Call segment identifier for tracking call legs. + + `true` once the call has reached the `ended` state. + + ## **Methods** @@ -122,6 +126,15 @@ objects that let you stop, pause, or wait for the operation to complete. Wait for a call to reach the ended state. + + Wait for a call to be answered. + + + Wait for a call to start ringing. + + + Wait for a call to start ending. + Answer an inbound Relay call. @@ -149,18 +162,45 @@ objects that let you stop, pause, or wait for the operation to complete. Play audio content on a call. + + Play text-to-speech. + + + Play an audio file from a URL. + + + Play silence for a number of seconds. + + + Play a named ringtone. + Record audio from a call. Play audio and collect DTMF or speech input. + + Speak a prompt, then collect input. + + + Play an audio prompt, then collect input. + Collect DTMF or speech input without playing media. Detect answering machines, fax tones, or digits on a call. + + Detect whether a human or a machine picked up. + + + Detect DTMF digits. + + + Detect a fax tone. + Start an AI agent session on a call. diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/play-audio.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-audio.mdx new file mode 100644 index 0000000000..627c4cc24a --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-audio.mdx @@ -0,0 +1,58 @@ +--- +title: "playAudio" +slug: /reference/typescript/relay/call/play-audio +description: "Play an audio file from a URL on a call." +max-toc-depth: 3 +--- + +[playaction]: /docs/server-sdks/reference/typescript/relay/actions +[play]: /docs/server-sdks/reference/typescript/relay/call/play + +Play an audio file from a URL on the call. A typed convenience over +[`play()`][play]. + +## **Parameters** + + + URL of the audio file. + + + + Playback options. + + + + + + Volume adjustment in dB, from `-40` to `40`. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`PlayAction`][playaction]`>` -- An action handle with `stop()`, `pause()`, `resume()`, `volume()`, and `wait()` methods. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.playAudio('https://example.com/hold-music.mp3', { volume: -6 }); + await action.wait(); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/play-ringtone.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-ringtone.mdx new file mode 100644 index 0000000000..10a65bfa90 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-ringtone.mdx @@ -0,0 +1,61 @@ +--- +title: "playRingtone" +slug: /reference/typescript/relay/call/play-ringtone +description: "Play a named ringtone on a call." +max-toc-depth: 3 +--- + +[playaction]: /docs/server-sdks/reference/typescript/relay/actions +[play]: /docs/server-sdks/reference/typescript/relay/call/play + +Play a named ringtone on the call. A typed convenience over [`play()`][play]. + +## **Parameters** + + + Ringtone name, a country code such as `"us"` or `"gb"`. + + + + Playback options. + + + + + + Seconds to play the ringtone. + + + + Volume adjustment in dB, from `-40` to `40`. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`PlayAction`][playaction]`>` -- An action handle with `stop()`, `pause()`, `resume()`, `volume()`, and `wait()` methods. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.playRingtone('us', { duration: 10 }); + await action.wait(); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/play-silence.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-silence.mdx new file mode 100644 index 0000000000..7137ccbf9b --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-silence.mdx @@ -0,0 +1,54 @@ +--- +title: "playSilence" +slug: /reference/typescript/relay/call/play-silence +description: "Play silence on a call for a number of seconds." +max-toc-depth: 3 +--- + +[playaction]: /docs/server-sdks/reference/typescript/relay/actions +[play]: /docs/server-sdks/reference/typescript/relay/call/play + +Play silence on the call for `duration` seconds. A typed convenience over +[`play()`][play]. + +## **Parameters** + + + Seconds of silence. + + + + Playback options. + + + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`PlayAction`][playaction]`>` -- An action handle with `stop()`, `pause()`, `resume()`, `volume()`, and `wait()` methods. + +## **Example** + +```typescript {12} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + await (await call.playTTS('One moment.')).wait(); + await (await call.playSilence(2)).wait(); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/play-tts.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-tts.mdx new file mode 100644 index 0000000000..7d8f69afc0 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/play-tts.mdx @@ -0,0 +1,70 @@ +--- +title: "playTTS" +slug: /reference/typescript/relay/call/play-tts +description: "Play text-to-speech on a call." +max-toc-depth: 3 +--- + +[playaction]: /docs/server-sdks/reference/typescript/relay/actions +[play]: /docs/server-sdks/reference/typescript/relay/call/play + +Play text-to-speech on the call. A typed convenience over [`play()`][play] that +builds the TTS media item for you. + +## **Parameters** + + + The text to speak. + + + + Voice and playback options. + + + + + + Language code for the voice, such as `"en-US"`. + + + + `"male"` or `"female"`. + + + + Voice identifier for the TTS engine. + + + + Volume adjustment in dB, from `-40` to `40`. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`PlayAction`][playaction]`>` -- An action handle with `stop()`, `pause()`, `resume()`, `volume()`, and `wait()` methods. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.playTTS('Welcome to Bayview Taxi.', { language: 'en-US' }); + await action.wait(); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/prompt-audio.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/prompt-audio.mdx new file mode 100644 index 0000000000..dcfbab9fec --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/prompt-audio.mdx @@ -0,0 +1,67 @@ +--- +title: "promptAudio" +slug: /reference/typescript/relay/call/prompt-audio +description: "Play an audio prompt, then collect DTMF or speech input." +max-toc-depth: 3 +--- + +[collectaction]: /docs/server-sdks/reference/typescript/relay/actions/collect-action +[play-and-collect]: /docs/server-sdks/reference/typescript/relay/call/play-and-collect + +Play an audio file as the prompt, then collect DTMF or speech input. A typed +convenience over [`playAndCollect()`][play-and-collect]. + +## **Parameters** + + + URL of the audio file to play as the prompt. + + + + Input collection configuration: `digits`, `speech`, `initial_timeout`, and + the other fields accepted by [`playAndCollect()`][play-and-collect]. Field + names are the snake_case wire names; the object is sent as-is. + + + + Playback options. + + + + + + Volume adjustment in dB, from `-40` to `40`. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`CollectAction`][collectaction]`>` -- An action handle with `stop()`, `pause()`, `resume()`, `volume()`, `startInputTimers()`, and `wait()` methods. + +## **Example** + +```typescript {11-14} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.promptAudio( + 'https://example.com/menu.mp3', + { digits: { max: 1 } }, + ); + await action.wait(); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/prompt-tts.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/prompt-tts.mdx new file mode 100644 index 0000000000..99f58c9452 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/prompt-tts.mdx @@ -0,0 +1,80 @@ +--- +title: "promptTTS" +slug: /reference/typescript/relay/call/prompt-tts +description: "Speak a prompt, then collect DTMF or speech input." +max-toc-depth: 3 +--- + +[collectaction]: /docs/server-sdks/reference/typescript/relay/actions/collect-action +[play-and-collect]: /docs/server-sdks/reference/typescript/relay/call/play-and-collect + +Speak a text-to-speech prompt, then collect DTMF or speech input. A typed +convenience over [`playAndCollect()`][play-and-collect]. + +## **Parameters** + + + The prompt to speak. + + + + Input collection configuration: `digits`, `speech`, `initial_timeout`, and + the other fields accepted by [`playAndCollect()`][play-and-collect]. Field + names are the snake_case wire names; the object is sent as-is. + + + + Voice and playback options. + + + + + + Language code for the voice, such as `"en-US"`. + + + + `"male"` or `"female"`. + + + + Voice identifier for the TTS engine. + + + + Volume adjustment in dB, from `-40` to `40`. + + + + Callback invoked when the operation reaches a terminal state. + + + + +## **Returns** + +`Promise<`[`CollectAction`][collectaction]`>` -- An action handle with `stop()`, `pause()`, `resume()`, `volume()`, `startInputTimers()`, and `wait()` methods. + +## **Example** + +```typescript {11-14} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + const action = await call.promptTTS( + 'Enter your four digit PIN.', + { digits: { max: 4, terminators: '#' } }, + ); + const event = await action.wait(); + console.log(event.params); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-answered.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-answered.mdx new file mode 100644 index 0000000000..f31bdb4ac6 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-answered.mdx @@ -0,0 +1,48 @@ +--- +title: "waitForAnswered" +slug: /reference/typescript/relay/call/wait-for-answered +description: "Wait for a call to reach the answered state." +max-toc-depth: 3 +--- + +[relayevent]: /docs/server-sdks/reference/typescript/relay/events +[wait-for]: /docs/server-sdks/reference/typescript/relay/call/wait-for + +Wait for the call to reach the `answered` state. Returns immediately if the call +is already answered or past that state. A typed wait over [`waitFor()`][wait-for]. + +`answer()` resolves when the platform accepts the command. Call +`waitForAnswered()` afterwards to block until the state event confirms the call +is up. A call returned by `client.dial()` is already answered, so this returns +at once. + +## **Parameters** + + + Maximum milliseconds to wait. Throws an `Error` if exceeded. `undefined` + waits indefinitely. + + +## **Returns** + +`Promise<`[`RelayEvent`][relayevent]`>` -- The state-change event. + +## **Example** + +```typescript {11} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + await call.waitForAnswered(5000); + await call.playTTS('Thanks for calling Bayview Taxi.'); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-ending.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-ending.mdx new file mode 100644 index 0000000000..33c1669dfc --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-ending.mdx @@ -0,0 +1,44 @@ +--- +title: "waitForEnding" +slug: /reference/typescript/relay/call/wait-for-ending +description: "Wait for a call to reach the ending state." +max-toc-depth: 3 +--- + +[relayevent]: /docs/server-sdks/reference/typescript/relay/events +[wait-for]: /docs/server-sdks/reference/typescript/relay/call/wait-for + +Wait for the call to reach the `ending` state. Returns immediately if the call +is already ending or past that state. A typed wait over [`waitFor()`][wait-for]. + +## **Parameters** + + + Maximum milliseconds to wait. Throws an `Error` if exceeded. `undefined` + waits indefinitely. + + +## **Returns** + +`Promise<`[`RelayEvent`][relayevent]`>` -- The state-change event. + +## **Example** + +```typescript {12} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + await call.answer(); + await call.hangup(); + await call.waitForEnding(); + console.log(call.state); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-ringing.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-ringing.mdx new file mode 100644 index 0000000000..6ab8af9e2d --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/relay/call/wait-for-ringing.mdx @@ -0,0 +1,43 @@ +--- +title: "waitForRinging" +slug: /reference/typescript/relay/call/wait-for-ringing +description: "Wait for a call to reach the ringing state." +max-toc-depth: 3 +--- + +[relayevent]: /docs/server-sdks/reference/typescript/relay/events +[wait-for]: /docs/server-sdks/reference/typescript/relay/call/wait-for + +Wait for the call to reach the `ringing` state. Returns immediately if the call +is already ringing or past that state. A typed wait over [`waitFor()`][wait-for]. + +## **Parameters** + + + Maximum milliseconds to wait. Throws an `Error` if exceeded. `undefined` + waits indefinitely. + + +## **Returns** + +`Promise<`[`RelayEvent`][relayevent]`>` -- The state-change event. + +## **Example** + +```typescript {10} +import { RelayClient } from '@signalwire/sdk'; + +const client = new RelayClient({ + project: process.env.SIGNALWIRE_PROJECT_ID!, + token: process.env.SIGNALWIRE_API_TOKEN!, + contexts: ['default'] +}); + +client.onCall(async (call) => { + const event = await call.waitForRinging(5000); + console.log(event.params.call_state); + await call.answer(); +}); + +await client.run(); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/client/dial.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/client/dial.mdx index 0b13d9d01d..f07961b5a6 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/client/dial.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/client/dial.mdx @@ -26,7 +26,9 @@ Throws `RelayError` if the dial fails or if no answer is received within the [][]"} required={true} toc={true}> Nested array of device definitions for serial and parallel dialing. Each device is - an object with `type` and `params` keys. + an object with `type` and `params` keys. You can also put the fields flat next + to `type`; the SDK wraps them in `params` and, for `"phone"`, maps `to` and + `from` to `to_number` and `from_number`. - **Serial dial** (try one after another): each inner array has one device - **Parallel dial** (ring simultaneously): one inner array with multiple devices @@ -37,19 +39,31 @@ Throws `RelayError` if the dial fails or if no answer is received within the Device type. Valid values: - `"phone"` -- PSTN phone number - `"sip"` -- SIP endpoint + - `"fabric"` -- a resource address. The platform resolves the address to + whatever it points to, such as a subscriber or a Relay application, and + rings every live registration of a subscriber at once. - Device-specific parameters. + Device-specific parameters. Which fields are required depends on the device + type. - - Destination phone number in E.164 format (for `"phone"` type). + + Destination phone number in E.164 format. Required for `"phone"`. - - Caller ID phone number in E.164 format (for `"phone"` type). + + Caller ID phone number in E.164 format. Required for `"phone"`. + + + + Destination resource address. Required for `"fabric"`. + + + + Caller ID shown to the destination (for `"fabric"`). diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/client/index.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/client/index.mdx index 37e34bcf88..71d3ca1128 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/client/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/client/index.mdx @@ -41,8 +41,11 @@ token. Credentials can be passed directly or read from environment variables. - SignalWire space hostname (e.g., `your-space.signalwire.com`). Set via constructor or `SIGNALWIRE_SPACE` - environment variable. + Relay WebSocket endpoint. The default is the endpoint for SignalWire projects; you + do not set your space here. The constructor option wins, then `SIGNALWIRE_RELAY_HOST`, + then `SIGNALWIRE_SPACE`, then the default. `RestClient` reads `SIGNALWIRE_SPACE` as + the REST host, so when it is set for REST, set `SIGNALWIRE_RELAY_HOST` or pass `host` + to keep the default. diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/constants.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/constants.mdx index 8b0ea5103e..ac24d1558a 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/constants.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/constants.mdx @@ -109,16 +109,39 @@ messages progress through: `queued` -> `initiated` -> `sent` -> `delivered` | `MESSAGE_STATE_FAILED` | `"failed"` | Message send failed | | `MESSAGE_STATE_RECEIVED` | `"received"` | Inbound message received | +## Typed state unions + +Each state family also has a string-literal union type, the list of its terminal +values, and a predicate, so you can narrow states without comparing against +individual constants. + +| Type | Terminal values | Predicate | +|------|-----------------|-----------| +| `CallState` | `CALL_STATE_TERMINAL` = `["ended"]` | `isCallStateTerminal(state)` | +| `DialState` (`dialing`, `answered`, `failed`) | `DIAL_STATE_TERMINAL` = `["answered", "failed"]` | `isDialStateTerminal(state)` | +| `MessageState` | `MESSAGE_STATE_TERMINAL` = `["delivered", "undelivered", "failed"]` | `isMessageStateTerminal(state)` | + +Two more closed sets are exported for method options: `TtsGender` (`"male"` or +`"female"`) and `FaxTone` (`"CED"` or `"CNG"`). + +```typescript {1,4} +import { isMessageStateTerminal, type MessageState } from '@signalwire/sdk'; + +function handleMessageState(message: { state: MessageState }) { + if (isMessageStateTerminal(message.state)) { + console.log('Message delivery complete'); + } +} +``` + ## **Example** -```typescript {12} +```typescript {11,20} import { CALL_STATE_ANSWERED, CALL_STATE_ENDED, EVENT_CALL_STATE, - MESSAGE_STATE_DELIVERED, - MESSAGE_STATE_UNDELIVERED, - MESSAGE_STATE_FAILED, + isMessageStateTerminal, } from '@signalwire/sdk'; import type { CallStateEvent } from '@signalwire/sdk'; @@ -132,9 +155,8 @@ function handleCallState(event: CallStateEvent) { } // Check terminal message states -const TERMINAL = [MESSAGE_STATE_DELIVERED, MESSAGE_STATE_UNDELIVERED, MESSAGE_STATE_FAILED]; function handleMessageState(message: { state: string }) { - if (TERMINAL.includes(message.state)) { + if (isMessageStateTerminal(message.state)) { console.log('Message delivery complete'); } } diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/message/index.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/message/index.mdx index c79fff4bea..5f0929d781 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/message/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/message/index.mdx @@ -107,6 +107,12 @@ await client.disconnect(); Read-only property. + + `true` when `state` is `delivered`, `undelivered`, or `failed`. Unlike + `isDone`, this tests the state value alone, so it is meaningful on an inbound + message before any event has been dispatched. + + The terminal [`RelayEvent`][relayevent] that resolved this message, or `null` if the message has not yet completed. diff --git a/fern/products/server-sdks/pages/reference/typescript/relay/relay-error.mdx b/fern/products/server-sdks/pages/reference/typescript/relay/relay-error.mdx index ff0fcd2f1b..b7e8afd985 100644 --- a/fern/products/server-sdks/pages/reference/typescript/relay/relay-error.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/relay/relay-error.mdx @@ -19,7 +19,13 @@ import { RelayError } from '@signalwire/sdk'; - Human-readable error description returned by the Relay server. + `"RELAY error {code}: {serverMessage}"`. The standard `Error` message, + prefixed with the code. + + + + The server's own error text, without the `RELAY error` prefix. Read this to + match on or display the server's wording. diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/ai-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/ai-stop.mdx index f36768c7da..c7f9a65a08 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/ai-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/ai-stop.mdx @@ -18,7 +18,7 @@ the call itself remains active, allowing further call control operations. ## **Example** -```typescript {10} +```typescript {10-13} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -27,10 +27,10 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -// Stop AI and then play a goodbye message -await client.calling.aiStop("call-id-xxx", { control_id: "ctrl-id" }); -await client.calling.play("call-id-xxx", { - play: [{ type: "tts", text: "Thank you for calling. Goodbye!" }] -}); +// Stop the AI agent running on the call, then play a goodbye message under a new control ID +await client.calling.aiStop("call-id-xxx", "agent-1"); +await client.calling.play("call-id-xxx", [ + { type: "tts", params: { text: "Thank you for calling. Goodbye!" } }, +], { control_id: "goodbye-1" }); await client.calling.end("call-id-xxx", { reason: "hangup" }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-start-input-timers.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-start-input-timers.mdx index 16424e21e8..1c1e7e6592 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-start-input-timers.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-start-input-timers.mdx @@ -21,7 +21,7 @@ before starting the timer countdown. ## **Example** -```typescript {21} +```typescript {10-14,17-19,22} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -30,19 +30,18 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -// Start collection without auto-timers, play prompt, then start timers -const result = await client.calling.collect("call-id-xxx", { +// Start collection with a control ID you choose, play a prompt, then start timers +const controlId = "pin-collect-1"; +await client.calling.collect("call-id-xxx", { + control_id: controlId, digits: { max: 4, terminators: "#" }, }); -const controlId = result.control_id; -// Play a prompt first -await client.calling.play("call-id-xxx", { - play: [{ type: "tts", text: "Please enter your 4-digit PIN." }] -}); +// Play a prompt under its own control ID +await client.calling.play("call-id-xxx", [ + { type: "tts", params: { text: "Please enter your 4-digit PIN." } }, +], { control_id: "pin-prompt-1" }); // Now start the input timers -await client.calling.collectStartInputTimers("call-id-xxx", { - control_id: controlId, -}); +await client.calling.collectStartInputTimers("call-id-xxx", controlId); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-stop.mdx index 15f6af450a..0abf0799b7 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect-stop.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.collectStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.collectStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect.mdx index 56da07befb..ad4fa52462 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/collect.mdx @@ -6,7 +6,11 @@ max-toc-depth: 3 --- Start collecting user input on an active call. Supports DTMF digit collection -and speech recognition. Returns a `control_id` for managing the collection. +and speech recognition. + + + +Keep it to manage the collection later. ## **Request** @@ -20,7 +24,7 @@ and speech recognition. Returns a `control_id` for managing the collection. ### Collect DTMF Digits -```typescript {10} +```typescript {10-14} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -29,8 +33,9 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -// Collect DTMF digits +// Collect DTMF digits under a control ID you choose const result = await client.calling.collect("call-id-xxx", { + control_id: "pin-collect-1", digits: { max: 4, terminators: "#", digit_timeout: 5.0 }, initial_timeout: 10.0, }); @@ -38,7 +43,7 @@ const result = await client.calling.collect("call-id-xxx", { ### Collect Speech -```typescript {9} +```typescript {9-15} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -48,6 +53,7 @@ const client = new RestClient({ }); const result = await client.calling.collect("call-id-xxx", { + control_id: "speech-collect-1", speech: { end_silence_timeout: 1.0, language: "en-US", @@ -57,7 +63,7 @@ const result = await client.calling.collect("call-id-xxx", { ### Collect Both -```typescript {9} +```typescript {9-14} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -67,6 +73,7 @@ const client = new RestClient({ }); const result = await client.calling.collect("call-id-xxx", { + control_id: "combined-collect-1", digits: { max: 1, terminators: "#" }, speech: { end_silence_timeout: 2.0 }, initial_timeout: 15.0, diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect-stop.mdx index df8291fc88..b684fbd0b4 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect-stop.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.detectStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.detectStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect.mdx index da041665ce..0aed796db5 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/detect.mdx @@ -6,7 +6,13 @@ max-toc-depth: 3 --- Start a detector on an active call. Detectors can identify answering machines, -fax tones, or DTMF digits. Returns a `control_id` for managing the detector. +fax tones, or DTMF digits. + + + +Keep it — [`detectStop()`][detect-stop] uses it to end the detector. + +[detect-stop]: /docs/server-sdks/reference/typescript/rest/calling/detect-stop ## **Request** @@ -20,7 +26,7 @@ fax tones, or DTMF digits. Returns a `control_id` for managing the detector. ### Answering Machine Detection -```typescript {10} +```typescript {9-20} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -29,22 +35,24 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -// Answering machine detection -const result = await client.calling.detect("call-id-xxx", { - detect: { +// Answering machine detection, correlated by the control ID you choose +const controlId = "amd-1"; +const result = await client.calling.detect( + "call-id-xxx", + { type: "machine", params: { initial_timeout: 4.5, end_silence_timeout: 1.0, - } + }, }, - timeout: 30.0, -}); + { control_id: controlId, timeout: 30.0 }, +); ``` ### Fax Detection -```typescript {9} +```typescript {9-12} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -54,13 +62,14 @@ const client = new RestClient({ }); const result = await client.calling.detect("call-id-xxx", { - detect: { type: "fax", params: { tone: "CED" } } -}); + type: "fax", + params: { tone: "CED" }, +}, { control_id: "fax-detect-1" }); ``` ### Digit Detection -```typescript {9} +```typescript {9-12} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -70,6 +79,7 @@ const client = new RestClient({ }); const result = await client.calling.detect("call-id-xxx", { - detect: { type: "digit", params: { digits: "0123456789#*" } } -}); + type: "digit", + params: { digits: "0123456789#*" }, +}, { control_id: "digit-detect-1" }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/dial.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/dial.mdx index 4c11388e90..c57b4ba671 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/dial.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/dial.mdx @@ -27,9 +27,7 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const result = await client.calling.dial({ - from: "+15551234567", - to: "+15559876543", +const result = await client.calling.dial("+15551234567", "+15559876543", { url: "https://example.com/call-handler", }); console.log(result); // { id: "call-id-xxx", ... } diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/index.mdx index cab86f333b..6f7685dd25 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/index.mdx @@ -6,14 +6,41 @@ max-toc-depth: 3 --- [restclient]: /docs/server-sdks/reference/typescript/rest/client +[request-options]: /docs/server-sdks/reference/typescript/rest/request-options -The `CallingNamespace` provides REST-based call control through the +The `Calling` resource provides REST-based call control through the [`RestClient`][restclient]. All 37 commands are dispatched as POST requests to a single endpoint (`/api/calling/calls`) with a `command` field identifying the operation. Access via `client.calling` on a [`RestClient`][restclient] instance. +Every method takes the call ID first, then any required command fields as +positional arguments, then an optional `options` object for the remaining +fields. The `options` object also accepts `extras`, a bag of additional fields +merged into the command as-is. A final optional +[`requestOptions`][request-options] argument sets the timeout, retries, and +abort signal for that one request. + +```typescript {9-11,13-15} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const call = await client.calling.dial("+15551234567", "+15559876543", { + url: "https://example.com/call-handler", +}); + +const controlId = "greeting-1"; +await client.calling.play(call.id, [{ type: "tts", params: { text: "Hello!" } }], { control_id: controlId }); +await client.calling.playStop(call.id, controlId); +await client.calling.end(call.id, { reason: "hangup" }); +``` + Unlike the Relay client which uses persistent WebSocket connections, the Calling namespace sends each command as an independent HTTP request. This is suitable for server-side diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-transcribe.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-transcribe.mdx index fb2bce1a6c..f522ea9390 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-transcribe.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-transcribe.mdx @@ -32,13 +32,11 @@ const client = new RestClient({ }); await client.calling.liveTranscribe("call-id-xxx", { - action: { - start: { - lang: "en-US", - direction: ["local-caller", "remote-caller"], - webhook: "https://example.com/transcription-events", - live_events: true, - } + start: { + lang: "en-US", + direction: ["local-caller", "remote-caller"], + webhook: "https://example.com/transcription-events", + live_events: true, }, }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-translate.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-translate.mdx index dc1180e8d2..f04dc1f83f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-translate.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/live-translate.mdx @@ -28,14 +28,12 @@ const client = new RestClient({ }); await client.calling.liveTranslate("call-id-xxx", { - action: { - start: { - from_lang: "en-US", - to_lang: "es-ES", - direction: ["local-caller", "remote-caller"], - from_voice: "elevenlabs.josh", - to_voice: "elevenlabs.josh", - } + start: { + from_lang: "en-US", + to_lang: "es-ES", + direction: ["local-caller", "remote-caller"], + from_voice: "elevenlabs.josh", + to_voice: "elevenlabs.josh", }, }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-pause.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-pause.mdx index 854065e126..0089055d3c 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-pause.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-pause.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.playPause("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.playPause("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-resume.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-resume.mdx index a7fd0c0a53..af7d30f229 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-resume.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-resume.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.playResume("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.playResume("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-stop.mdx index 8e7bd80f4f..5068290977 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-stop.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.playStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.playStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-volume.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-volume.mdx index 790e3e4c53..3700a11264 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-volume.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play-volume.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.playVolume("call-id-xxx", { control_id: "ctrl-id", volume: 5.0 }); +await client.calling.playVolume("call-id-xxx", "ctrl-id", 5.0); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play.mdx index f2f9a1c31e..7685593395 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/play.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/play.mdx @@ -10,12 +10,15 @@ max-toc-depth: 3 [play-stop]: /docs/server-sdks/reference/typescript/rest/calling/play-stop [play-volume]: /docs/server-sdks/reference/typescript/rest/calling/play-volume -Play audio or text-to-speech on an active call. Returns a `control_id` that can be -used with [`playPause()`][play-pause], -[`playResume()`][play-resume], -[`playStop()`][play-stop], and -[`playVolume()`][play-volume] to manage -the playback. +Play audio or text-to-speech on an active call. The response confirms that +the command was accepted; playback state arrives asynchronously at +`status_url`. + + + +Keep it to manage the playback later with [`playPause()`][play-pause], +[`playResume()`][play-resume], [`playStop()`][play-stop], and +[`playVolume()`][play-volume]. ## **Request** @@ -29,7 +32,7 @@ the playback. ### Play TTS -```typescript {10} +```typescript {9-14} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -38,16 +41,18 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -// Play TTS -const result = await client.calling.play("call-id-xxx", { - play: [{ type: "tts", text: "Hello from the REST API!" }] -}); -const controlId = result.control_id; +// Choose a control ID and keep it for later play commands +const controlId = "greeting-1"; +await client.calling.play( + "call-id-xxx", + [{ type: "tts", params: { text: "Hello from the REST API!" } }], + { control_id: controlId }, +); ``` ### Play Audio File -```typescript {9} +```typescript {9-11} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -56,9 +61,9 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.play("call-id-xxx", { - play: [{ type: "audio", url: "https://example.com/greeting.mp3" }] -}); +await client.calling.play("call-id-xxx", [ + { type: "audio", params: { url: "https://example.com/greeting.mp3" } }, +], { control_id: "greeting-1" }); ``` ### Play Multiple Items @@ -72,11 +77,13 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.play("call-id-xxx", { - play: [ - { type: "tts", text: "Please hold while we connect you." }, - { type: "silence", duration: 1 }, - { type: "audio", url: "https://example.com/hold-music.mp3" }, - ] -}); +await client.calling.play( + "call-id-xxx", + [ + { type: "tts", params: { text: "Please hold while we connect you." } }, + { type: "silence", params: { duration: 1 } }, + { type: "audio", params: { url: "https://example.com/hold-music.mp3" } }, + ], + { control_id: "hold-sequence-1", loop: 2 }, +); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/receive-fax-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/receive-fax-stop.mdx index e2193d0616..7ee3d1bf8c 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/receive-fax-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/receive-fax-stop.mdx @@ -33,5 +33,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.receiveFaxStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.receiveFaxStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-pause.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-pause.mdx index 9818e2f5ba..7f7829f6d0 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-pause.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-pause.mdx @@ -30,5 +30,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.recordPause("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.recordPause("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-resume.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-resume.mdx index 5d8c07075f..6337566065 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-resume.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-resume.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.recordResume("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.recordResume("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-stop.mdx index 63b1724781..f1b1110a8b 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record-stop.mdx @@ -28,6 +28,6 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const result = await client.calling.recordStop("call-id-xxx", { control_id: "ctrl-id" }); -console.log(result); // Contains recording URL +const result = await client.calling.recordStop("call-id-xxx", "ctrl-id"); +console.log(result.id, result.status); // The updated call leg ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record.mdx index f8c0b59d82..fea37452d8 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/record.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/record.mdx @@ -9,10 +9,12 @@ max-toc-depth: 3 [resume]: /docs/server-sdks/reference/typescript/rest/calling/record-resume [stop]: /docs/server-sdks/reference/typescript/rest/calling/record-stop -Start recording an active call. Returns a `control_id` used to -[pause][pause], -[resume][resume], -or [stop][stop] the recording. +Start recording an active call. + + + +Keep it to [pause][pause], [resume][resume], or [stop][stop] the recording +later. ## **Request** @@ -24,7 +26,7 @@ or [stop][stop] the recording. ## **Example** -```typescript {9} +```typescript {9-13} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -33,8 +35,9 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const result = await client.calling.record("call-id-xxx", { - audio: { format: "mp3", stereo: true } +const controlId = "recording-1"; +await client.calling.record("call-id-xxx", { + control_id: controlId, + audio: { format: "mp3", stereo: true }, }); -const controlId = result.control_id; ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/refer.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/refer.mdx index 1061f1e5e4..c7cb6371d4 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/refer.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/refer.mdx @@ -37,6 +37,7 @@ const client = new RestClient({ }); await client.calling.refer("call-id-xxx", { - device: { type: "sip", params: { to: "sip:sales@example.com" } }, + type: "sip", + params: { to: "sip:sales@example.com" }, }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/send-fax-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/send-fax-stop.mdx index 26cfe164c4..c760c96c80 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/send-fax-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/send-fax-stop.mdx @@ -33,5 +33,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.sendFaxStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.sendFaxStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream-stop.mdx index 3f17cff3e6..410cb36aad 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream-stop.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.streamStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.streamStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream.mdx index 5c11fe36de..bb66c1bf1c 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/stream.mdx @@ -7,7 +7,10 @@ max-toc-depth: 3 Start streaming audio from an active call to a WebSocket endpoint. This is commonly used for real-time speech processing, analytics, or archival. -Returns a `control_id` for stopping the stream. + + + +Keep it to stop the stream later. ## **Request** @@ -19,7 +22,7 @@ Returns a `control_id` for stopping the stream. ## **Example** -```typescript {9} +```typescript {9-12} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -28,8 +31,8 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const result = await client.calling.stream("call-id-xxx", { - url: "wss://example.com/audio-stream", +const controlId = "audio-stream-1"; +await client.calling.stream("call-id-xxx", "wss://example.com/audio-stream", { + control_id: controlId, }); -const controlId = result.control_id; ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap-stop.mdx index 7dbb23aefd..52b6b3eba2 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap-stop.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.tapStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.tapStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap.mdx index f735947d75..292046612f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/tap.mdx @@ -6,8 +6,11 @@ max-toc-depth: 3 --- Start tapping audio from an active call and sending it to an external endpoint -(e.g., a WebSocket or RTP destination). Returns a `control_id` for stopping -the tap. +(e.g., a WebSocket or RTP destination). + + + +Keep it to stop the tap later. ## **Request** @@ -19,7 +22,7 @@ the tap. ## **Example** -```typescript {9} +```typescript {9-15} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ @@ -28,9 +31,11 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const result = await client.calling.tap("call-id-xxx", { - tap: { type: "audio", params: { direction: "both" } }, - device: { type: "ws", params: { uri: "wss://example.com/tap" } }, -}); -const controlId = result.control_id; +const controlId = "tap-1"; +await client.calling.tap( + "call-id-xxx", + { type: "audio", params: { direction: "both" } }, + { type: "ws", params: { uri: "wss://example.com/tap" } }, + { control_id: controlId }, +); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe-stop.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe-stop.mdx index 8d5f9aa2a1..7ca7fc4902 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe-stop.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe-stop.mdx @@ -28,5 +28,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.transcribeStop("call-id-xxx", { control_id: "ctrl-id" }); +await client.calling.transcribeStop("call-id-xxx", "ctrl-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe.mdx index a359789db3..fdbacf7b54 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/transcribe.mdx @@ -7,8 +7,11 @@ max-toc-depth: 3 Start transcribing an active call in the background. The transcription covers the whole call and completes when the call ends. For real-time transcription, use live transcription. -Status updates are delivered to the optional `status_url`. Supply a `control_id` so you -can stop the transcription later with +Status updates are delivered to the optional `status_url`. + + + +Keep it to stop the transcription later with [`transcribeStop`](/docs/server-sdks/reference/typescript/rest/calling/transcribe-stop). ## **Request** diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/transfer.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/transfer.mdx index 7bbeeec07b..b95a082c3c 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/transfer.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/transfer.mdx @@ -5,8 +5,8 @@ description: Transfer an active call to a new destination via REST. max-toc-depth: 3 --- -Transfer an active call to a new destination. The current call leg is replaced -by a new connection to the specified target. +Transfer an active call to a new destination. Pass a destination string, such +as a SIP address, or an inline SWML document that takes over the call. ## **Request** @@ -28,6 +28,9 @@ const client = new RestClient({ }); await client.calling.transfer("call-id-xxx", { - dest: { type: "phone", params: { to_number: "+15559876543" } } + version: "1.0.0", + sections: { + main: [{ connect: { to: "+15559876543" } }], + }, }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/calling/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/calling/update.mdx index 79621977c8..9568dbc65a 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/calling/update.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/calling/update.mdx @@ -7,11 +7,6 @@ max-toc-depth: 3 Update parameters on an active call, such as the SWML document, URL, or status. - -Unlike most calling methods, `update()` does **not** take a positional `callId` -parameter. Pass all fields (including call identification) in a single object. - - ## **Request** @@ -31,8 +26,7 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.calling.update({ - id: "call-id-xxx", +await client.calling.update("call-id-xxx", { url: "https://example.com/new-call-handler", }); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/chat/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/chat/index.mdx index eb5980c04e..79ffff0298 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/chat/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/chat/index.mdx @@ -1,5 +1,5 @@ --- -title: "ChatResource" +title: "Chat" slug: /reference/typescript/rest/chat description: Chat API namespace for token creation. max-toc-depth: 3 diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/client/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/client/index.mdx index b9129645c2..026eb3f11a 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/client/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/client/index.mdx @@ -25,14 +25,16 @@ max-toc-depth: 3 [project]: /docs/server-sdks/reference/typescript/rest/project [pubsub]: /docs/server-sdks/reference/typescript/rest/pubsub [chat]: /docs/server-sdks/reference/typescript/rest/chat -[compatibility]: /docs/server-sdks/reference/typescript/rest/compat +[messages]: /docs/server-sdks/reference/typescript/rest/messages +[projects]: /docs/server-sdks/reference/typescript/rest/projects +[request-options]: /docs/server-sdks/reference/typescript/rest/request-options The `RestClient` is the entry point for all SignalWire REST API operations. It authenticates with your project credentials and exposes every API namespace as a property, giving you typed access to phone numbers, fabric resources, call control, video rooms, datasphere documents, logs, and more. -## **Constructor Parameters** +## **Constructor parameters** SignalWire project ID. Falls back to the `SIGNALWIRE_PROJECT_ID` environment variable @@ -45,78 +47,90 @@ call control, video rooms, datasphere documents, logs, and more. - SignalWire space hostname (e.g., `your-space.signalwire.com`). Falls back to the - `SIGNALWIRE_SPACE` environment variable when not provided. + SignalWire space hostname (e.g., `your-space.signalwire.com`) or a full + `https://` base URL. When not provided, falls back to the + `SIGNALWIRE_REST_BASE_URL` environment variable (a full URL), then to + `SIGNALWIRE_SPACE` (a bare hostname). + + + + Client-wide default timeout, retry, backoff, and abort settings applied to + every request. A per-request `requestOptions` argument overrides individual + fields for that call. See [`RequestOptions`][request-options]. + + + + Custom `fetch` implementation. Defaults to the global `fetch`. -All three parameters are required. If any is missing from both the constructor -arguments and environment variables, an `Error` is thrown. +`project`, `token`, and `host` are required. If any is missing from both the +constructor arguments and environment variables, an `Error` is thrown. -## **Namespace Properties** +## **Namespace properties** AI agents, SWML scripts, [subscribers](/docs/platform/subscribers), call flows, SIP gateways, and tokens. See [`Fabric`][fabric]. - + REST-based call control with 37+ commands dispatched via POST. See [`Calling`][calling]. - + Search, purchase, and manage phone numbers. See [`Phone Numbers`][phone-numbers]. - + Manage regulatory addresses. See [`Addresses`][addresses]. - + Manage call queues and queue members. See [`Queues`][queues]. - + List, retrieve, and delete call recordings. See [`Recordings`][recordings]. - + Manage number groups and their memberships. See [`Number Groups`][number-groups]. - + Manage and verify caller IDs. See [`Verified Callers`][verified-callers]. - + Get and update the project SIP profile. See [`SIP Profile`][sip-profile]. - + Phone number carrier and CNAM lookup. See [`Lookup`][lookup]. - + Manage short codes. See [`Short Codes`][short-codes]. - + Import externally-hosted phone numbers. See [`Imported Numbers`][imported-numbers]. - + Multi-factor authentication via SMS and voice. See [`MFA`][mfa]. @@ -142,23 +156,28 @@ arguments and environment variables, an `Error` is thrown. - Project-level API token management. + API token management for the current project (`client.project.tokens`). See [`Project`][project]. - + PubSub token generation. See [`PubSub`][pubsub]. - + Chat token generation. See [`Chat`][chat]. - - Twilio-compatible LAML API for migration. - See [`Compatibility`][compatibility]. + + Send SMS and MMS messages and redact message bodies. + See [`Messages`][messages]. + + + + Create, update, and delete projects, and rotate a project's signing key. + See [`Projects`][projects]. ## **Examples** @@ -185,35 +204,29 @@ import { RestClient } from "@signalwire/sdk"; // With SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, and SIGNALWIRE_SPACE set const client = new RestClient(); -const available = await client.phoneNumbers.search({ areaCode: "512" }); +const available = await client.phoneNumbers.search({ areacode: "512" }); ``` ## **Factory function** The top-level `restClient()` factory is a thin wrapper around -`new RestClient(...)`, provided for parity with the Python SDK's -`RestClient(*args, **kwargs)` call form. +`new RestClient(...)`. Both forms construct the same client. ```typescript {1} -restClient(args?: string[], kwargs?: Record): RestClient +restClient(opts?: ClientOptions): RestClient ``` - - Positional credentials, a compatibility shim for ports that pass - project/token/host positionally. Usually empty in TypeScript. - - - - Keyword-style credentials (`project`, `token`, `host`). When omitted, the same - `SIGNALWIRE_PROJECT_ID`, `SIGNALWIRE_API_TOKEN`, and `SIGNALWIRE_SPACE` - environment variables are read. + + The same options the constructor accepts: `project`, `token`, `host`, + `requestOptions`, and `fetchImpl`. When omitted, the + `SIGNALWIRE_PROJECT_ID`, `SIGNALWIRE_API_TOKEN`, and `SIGNALWIRE_REST_BASE_URL` + or `SIGNALWIRE_SPACE` environment variables are read. -```typescript {3-4,7} +```typescript {3-7,10} import { restClient } from "@signalwire/sdk"; -// Explicit credentials -const client = restClient([], { +const client = restClient({ project: "your-project-id", token: "your-api-token", host: "your-space.signalwire.com", diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/create.mdx deleted file mode 100644 index ab13a501cb..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/create.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/accounts/create -description: Create a new subproject (sub-account). -max-toc-depth: 3 ---- - - -Create a new subproject (sub-account). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const sub = await client.compat.accounts.create({ FriendlyName: "Marketing Team" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/get.mdx deleted file mode 100644 index e61c01980e..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/accounts/get -description: Retrieve a single account by SID. -max-toc-depth: 3 ---- - - -Retrieve a single account by its SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const account = await client.compat.accounts.get("account-sid"); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/index.mdx deleted file mode 100644 index 605c174ab0..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/index.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Accounts" -slug: /reference/typescript/rest/compat/accounts -description: Manage accounts and subprojects via the Compat API. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/accounts/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/accounts/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/accounts/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/accounts/update - -Manage accounts and subprojects. The base path is -`/api/laml/2010-04-01/Accounts` (not scoped to a specific account SID). - -Access via `client.compat.accounts` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const accounts = await client.compat.accounts.list(); -``` - -## **Methods** - - - - List accounts in the project. - - - Create a new subproject (sub-account). - - - Retrieve a single account by SID. - - - Update an account. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/list.mdx deleted file mode 100644 index 2bac3a537b..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/accounts/list -description: List accounts in the project. -max-toc-depth: 3 ---- - - -List accounts. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const accounts = await client.compat.accounts.list(); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/update.mdx deleted file mode 100644 index e1e53794cc..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/accounts/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/accounts/update -description: Update an account. -max-toc-depth: 3 ---- - - -Update an account. Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.accounts.update("account-sid", { FriendlyName: "Sales Team" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/create.mdx deleted file mode 100644 index 8bd65fb32b..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/create.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/applications/create -description: Create a new application. -max-toc-depth: 3 ---- - - -Create a new application. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const app = await client.compat.applications.create({ - FriendlyName: "My App", - VoiceUrl: "https://example.com/voice", - SmsUrl: "https://example.com/sms", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/delete.mdx deleted file mode 100644 index 37a303c5b3..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/delete.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/applications/delete -description: Delete an application. -max-toc-depth: 3 ---- - - -Delete an application. - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.applications.delete("AP..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/get.mdx deleted file mode 100644 index 1b94ef98f8..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/applications/get -description: Retrieve a single application by SID. -max-toc-depth: 3 ---- - - -Retrieve a single application by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const app = await client.compat.applications.get("AP..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/index.mdx deleted file mode 100644 index 8a5319dbc6..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/index.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "Applications" -slug: /reference/typescript/rest/compat/applications -description: Manage applications with CRUD operations. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/applications/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/applications/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/applications/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/applications/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/applications/delete - -Manage applications with CRUD operations. Applications define voice and messaging -URL endpoints for handling incoming calls and messages. - -Access via `client.compat.applications` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const apps = await client.compat.applications.list(); -``` - -## **Methods** - - - - List applications in the account. - - - Create a new application. - - - Retrieve a single application by SID. - - - Update an application. - - - Delete an application. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/list.mdx deleted file mode 100644 index 99c17664d5..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/applications/list -description: List applications in the account. -max-toc-depth: 3 ---- - - -List applications in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const apps = await client.compat.applications.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/update.mdx deleted file mode 100644 index 0e7c957cd4..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/applications/update.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/applications/update -description: Update an application. -max-toc-depth: 3 ---- - - -Update an application's configuration. Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.applications.update("AP...", { - VoiceUrl: "https://example.com/new-voice", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/create.mdx deleted file mode 100644 index 38981868e2..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/create.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/calls/create -description: Initiate a new outbound call. -max-toc-depth: 3 ---- - - -Initiate a new outbound call. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const call = await client.compat.calls.create({ - To: "+15559876543", - From: "+15551234567", - Url: "https://example.com/voice", -}); -console.log(call.sid); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/delete.mdx deleted file mode 100644 index fc952e1591..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/delete.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/calls/delete -description: Delete a call record. -max-toc-depth: 3 ---- - - -Delete a call record. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.calls.delete("CA..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/get.mdx deleted file mode 100644 index ae15e68b76..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/calls/get -description: Retrieve a single call by SID. -max-toc-depth: 3 ---- - - -Retrieve a single call by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const call = await client.compat.calls.get("CA..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/index.mdx deleted file mode 100644 index e5a236a96f..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/index.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: "Calls" -slug: /reference/typescript/rest/compat/calls -description: Manage calls with CRUD operations, in-call recording, and media streaming. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/calls/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/calls/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/calls/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/calls/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/calls/delete -[startrecording]: /docs/server-sdks/reference/typescript/rest/compat/calls/start-recording -[updaterecording]: /docs/server-sdks/reference/typescript/rest/compat/calls/update-recording -[startstream]: /docs/server-sdks/reference/typescript/rest/compat/calls/start-stream -[stopstream]: /docs/server-sdks/reference/typescript/rest/compat/calls/stop-stream - -Manage calls with CRUD operations, plus sub-resources for in-call recording -and streaming. Uses POST for updates (Twilio convention). - -Access via `client.compat.calls` on a [`RestClient`][restclient] instance. - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const calls = await client.compat.calls.list(); -``` - -## **Methods** - -### Call CRUD - - - - List calls in the account. - - - Initiate a new outbound call. - - - Retrieve a single call by SID. - - - Update an active call. - - - Delete a call record. - - - -### Recording - - - - Start recording an active call. - - - Update a call recording (pause, resume, or stop). - - - -### Streaming - - - - Start a media stream on an active call. - - - Stop a media stream on a call. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/list.mdx deleted file mode 100644 index beee1431d4..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/calls/list -description: List calls in the account. -max-toc-depth: 3 ---- - - -List calls in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const calls = await client.compat.calls.list({ Status: "completed", PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/start-recording.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/start-recording.mdx deleted file mode 100644 index ef17b61124..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/start-recording.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "startRecording" -slug: /reference/typescript/rest/compat/calls/start-recording -description: Start recording an active call. -max-toc-depth: 3 ---- - - -Start recording an active call. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const recording = await client.compat.calls.startRecording("CA..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/start-stream.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/start-stream.mdx deleted file mode 100644 index 64301128d9..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/start-stream.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "startStream" -slug: /reference/typescript/rest/compat/calls/start-stream -description: Start a media stream on an active call. -max-toc-depth: 3 ---- - - -Start a media stream on an active call, sending real-time audio to a WebSocket URL. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const stream = await client.compat.calls.startStream("CA...", { - Url: "wss://stream.example.com", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/stop-stream.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/stop-stream.mdx deleted file mode 100644 index f2605c1421..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/stop-stream.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "stopStream" -slug: /reference/typescript/rest/compat/calls/stop-stream -description: Stop a media stream on a call. -max-toc-depth: 3 ---- - - -Stop a media stream on a call. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.calls.stopStream("CA...", "ST...", { Status: "stopped" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/update-recording.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/update-recording.mdx deleted file mode 100644 index d124efd54a..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/update-recording.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "updateRecording" -slug: /reference/typescript/rest/compat/calls/update-recording -description: Update a call recording (pause, resume, or stop). -max-toc-depth: 3 ---- - - -Update a call recording (e.g., pause, resume, or stop). - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.calls.updateRecording("CA...", "RE...", { Status: "paused" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/update.mdx deleted file mode 100644 index b1e249d7bc..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/calls/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/calls/update -description: Update an active call. -max-toc-depth: 3 ---- - - -Update an active call (e.g., redirect to new LAML, end the call). Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.calls.update("CA...", { Status: "completed" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/delete-recording.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/delete-recording.mdx deleted file mode 100644 index 3d08bfbbeb..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/delete-recording.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "deleteRecording" -slug: /reference/typescript/rest/compat/conferences/delete-recording -description: Delete a conference recording. -max-toc-depth: 3 ---- - - -Delete a conference recording. - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.conferences.deleteRecording("CF...", "RE..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get-participant.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get-participant.mdx deleted file mode 100644 index 9fed34087d..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get-participant.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "getParticipant" -slug: /reference/typescript/rest/compat/conferences/get-participant -description: Retrieve a specific participant in a conference. -max-toc-depth: 3 ---- - - -Retrieve a specific participant in a conference. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const participant = await client.compat.conferences.getParticipant("CF...", "CA..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get-recording.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get-recording.mdx deleted file mode 100644 index 1ad6485904..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get-recording.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "getRecording" -slug: /reference/typescript/rest/compat/conferences/get-recording -description: Retrieve a specific conference recording. -max-toc-depth: 3 ---- - - -Retrieve a specific conference recording. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const recording = await client.compat.conferences.getRecording("CF...", "RE..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get.mdx deleted file mode 100644 index c334da00f0..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/conferences/get -description: Retrieve a single conference by SID. -max-toc-depth: 3 ---- - - -Retrieve a single conference by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const conf = await client.compat.conferences.get("CF..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/index.mdx deleted file mode 100644 index b9f8e38746..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/index.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: "Conferences" -slug: /reference/typescript/rest/compat/conferences -description: Manage conferences with participants, recordings, and media streams. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/conferences/list -[get]: /docs/server-sdks/reference/typescript/rest/compat/conferences/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/conferences/update -[listparticipants]: /docs/server-sdks/reference/typescript/rest/compat/conferences/list-participants -[getparticipant]: /docs/server-sdks/reference/typescript/rest/compat/conferences/get-participant -[updateparticipant]: /docs/server-sdks/reference/typescript/rest/compat/conferences/update-participant -[removeparticipant]: /docs/server-sdks/reference/typescript/rest/compat/conferences/remove-participant -[listrecordings]: /docs/server-sdks/reference/typescript/rest/compat/conferences/list-recordings -[getrecording]: /docs/server-sdks/reference/typescript/rest/compat/conferences/get-recording -[updaterecording]: /docs/server-sdks/reference/typescript/rest/compat/conferences/update-recording -[deleterecording]: /docs/server-sdks/reference/typescript/rest/compat/conferences/delete-recording -[startstream]: /docs/server-sdks/reference/typescript/rest/compat/conferences/start-stream -[stopstream]: /docs/server-sdks/reference/typescript/rest/compat/conferences/stop-stream - -Manage conferences with participants, recordings, and streams. Conferences are -list/get/update only (they are created implicitly when a participant dials in -via LAML). - -Access via `client.compat.conferences` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const conferences = await client.compat.conferences.list(); -``` - -## **Methods** - -### Conference CRUD - - - - List conferences. - - - Retrieve a single conference by SID. - - - Update a conference (e.g., end it or set an announce URL). - - - -### Participants - - - - List participants in a conference. - - - Retrieve a specific participant in a conference. - - - Update a participant in a conference (mute or hold). - - - Remove a participant from a conference. - - - -### Recordings - - - - List recordings for a conference. - - - Retrieve a specific conference recording. - - - Update a conference recording (pause, resume, or stop). - - - Delete a conference recording. - - - -### Streaming - - - - Start a media stream on a conference. - - - Stop a media stream on a conference. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list-participants.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list-participants.mdx deleted file mode 100644 index 27544fe9b2..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list-participants.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "listParticipants" -slug: /reference/typescript/rest/compat/conferences/list-participants -description: List participants in a conference. -max-toc-depth: 3 ---- - - -List participants in a conference. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const participants = await client.compat.conferences.listParticipants("CF..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list-recordings.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list-recordings.mdx deleted file mode 100644 index 77d5e45919..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list-recordings.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "listRecordings" -slug: /reference/typescript/rest/compat/conferences/list-recordings -description: List recordings for a conference. -max-toc-depth: 3 ---- - - -List recordings for a conference. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const recordings = await client.compat.conferences.listRecordings("CF..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list.mdx deleted file mode 100644 index eac595fd21..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/conferences/list -description: List conferences. -max-toc-depth: 3 ---- - - -List conferences. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const conferences = await client.compat.conferences.list({ Status: "in-progress" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/remove-participant.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/remove-participant.mdx deleted file mode 100644 index 9b66c631d9..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/remove-participant.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "removeParticipant" -slug: /reference/typescript/rest/compat/conferences/remove-participant -description: Remove a participant from a conference. -max-toc-depth: 3 ---- - - -Remove a participant from a conference, ending their call leg. - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.conferences.removeParticipant("CF...", "CA..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/start-stream.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/start-stream.mdx deleted file mode 100644 index b0f93f880d..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/start-stream.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: "startStream" -slug: /reference/typescript/rest/compat/conferences/start-stream -description: Start a media stream on a conference. -max-toc-depth: 3 ---- - - -Start a media stream on a conference, sending real-time audio to a WebSocket URL. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const stream = await client.compat.conferences.startStream( - "CF...", - { Url: "wss://stream.example.com" } -); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/stop-stream.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/stop-stream.mdx deleted file mode 100644 index 7ed1dcca6a..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/stop-stream.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "stopStream" -slug: /reference/typescript/rest/compat/conferences/stop-stream -description: Stop a media stream on a conference. -max-toc-depth: 3 ---- - - -Stop a media stream on a conference. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.conferences.stopStream("CF...", "ST...", { Status: "stopped" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update-participant.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update-participant.mdx deleted file mode 100644 index f6971c428e..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update-participant.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "updateParticipant" -slug: /reference/typescript/rest/compat/conferences/update-participant -description: Update a participant in a conference (mute or hold). -max-toc-depth: 3 ---- - - -Update a participant in a conference (e.g., mute or hold). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.conferences.updateParticipant("CF...", "CA...", { Muted: true }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update-recording.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update-recording.mdx deleted file mode 100644 index 76e481957b..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update-recording.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "updateRecording" -slug: /reference/typescript/rest/compat/conferences/update-recording -description: Update a conference recording (pause, resume, or stop). -max-toc-depth: 3 ---- - - -Update a conference recording (e.g., pause, resume, or stop). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.conferences.updateRecording("CF...", "RE...", { Status: "paused" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update.mdx deleted file mode 100644 index 8065b4df25..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/conferences/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/conferences/update -description: Update a conference (e.g., end it or set an announce URL). -max-toc-depth: 3 ---- - - -Update a conference (e.g., end it, or set the announce URL). Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.conferences.update("CF...", { Status: "completed" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/create.mdx deleted file mode 100644 index 3eaaa60279..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/create.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/faxes/create -description: Send a new fax. -max-toc-depth: 3 ---- - - -Send a new fax. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const fax = await client.compat.faxes.create({ - To: "+15559876543", - From: "+15551234567", - MediaUrl: "https://example.com/document.pdf", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/delete-media.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/delete-media.mdx deleted file mode 100644 index ac48797ebc..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/delete-media.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "deleteMedia" -slug: /reference/typescript/rest/compat/faxes/delete-media -description: Delete a media item from a fax. -max-toc-depth: 3 ---- - - -Delete a media item from a fax. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.faxes.deleteMedia("FX...", "ME..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/delete.mdx deleted file mode 100644 index 5a8cebb682..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/delete.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/faxes/delete -description: Delete a fax record. -max-toc-depth: 3 ---- - - -Delete a fax record. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.faxes.delete("FX..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/get-media.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/get-media.mdx deleted file mode 100644 index b728e0646d..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/get-media.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "getMedia" -slug: /reference/typescript/rest/compat/faxes/get-media -description: Retrieve a specific media item from a fax. -max-toc-depth: 3 ---- - - -Retrieve a specific media item from a fax. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const item = await client.compat.faxes.getMedia("FX...", "ME..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/get.mdx deleted file mode 100644 index 18698ae1f1..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/faxes/get -description: Retrieve a single fax by SID. -max-toc-depth: 3 ---- - - -Retrieve a single fax by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const fax = await client.compat.faxes.get("FX..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/index.mdx deleted file mode 100644 index 5582299a66..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/index.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: "Faxes" -slug: /reference/typescript/rest/compat/faxes -description: Manage faxes with CRUD operations and media sub-resources. -max-toc-depth: 3 ---- - -[messages]: /docs/server-sdks/reference/typescript/rest/compat/messages -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/faxes/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/faxes/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/faxes/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/faxes/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/faxes/delete -[listmedia]: /docs/server-sdks/reference/typescript/rest/compat/faxes/list-media -[getmedia]: /docs/server-sdks/reference/typescript/rest/compat/faxes/get-media -[deletemedia]: /docs/server-sdks/reference/typescript/rest/compat/faxes/delete-media - -Manage faxes with CRUD operations and media sub-resources. The media sub-resource -pattern is identical to [`messages`][messages]. - -Access via `client.compat.faxes` on a [`RestClient`][restclient] instance. - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const faxes = await client.compat.faxes.list(); -``` - -## **Methods** - -### Fax CRUD - - - - List faxes in the account. - - - Send a new fax. - - - Retrieve a single fax by SID. - - - Update a fax resource. - - - Delete a fax record. - - - -### Media - - - - List media items attached to a fax. - - - Retrieve a specific media item from a fax. - - - Delete a media item from a fax. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/list-media.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/list-media.mdx deleted file mode 100644 index 888fcb5885..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/list-media.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "listMedia" -slug: /reference/typescript/rest/compat/faxes/list-media -description: List media items attached to a fax. -max-toc-depth: 3 ---- - - -List media items attached to a fax. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const media = await client.compat.faxes.listMedia("FX..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/list.mdx deleted file mode 100644 index edbd01d5af..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/faxes/list -description: List faxes in the account. -max-toc-depth: 3 ---- - - -List faxes in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const faxes = await client.compat.faxes.list(); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/update.mdx deleted file mode 100644 index 9b96825725..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/faxes/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/faxes/update -description: Update a fax resource. -max-toc-depth: 3 ---- - - -Update a fax resource. Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.faxes.update("FX...", { Status: "canceled" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/index.mdx deleted file mode 100644 index d86e8f2997..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/index.mdx +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: "Compat" -slug: /reference/typescript/rest/compat -description: Twilio-compatible REST API for calls, messages, faxes, conferences, phone numbers, and more. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[accounts]: /docs/server-sdks/reference/typescript/rest/compat/accounts -[calls]: /docs/server-sdks/reference/typescript/rest/compat/calls -[messages]: /docs/server-sdks/reference/typescript/rest/compat/messages -[faxes]: /docs/server-sdks/reference/typescript/rest/compat/faxes -[conferences]: /docs/server-sdks/reference/typescript/rest/compat/conferences -[phone-numbers]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers -[applications]: /docs/server-sdks/reference/typescript/rest/compat/applications -[laml-bins]: /docs/server-sdks/reference/typescript/rest/compat/laml-bins -[queues]: /docs/server-sdks/reference/typescript/rest/compat/queues -[recordings]: /docs/server-sdks/reference/typescript/rest/compat/recordings -[transcriptions]: /docs/server-sdks/reference/typescript/rest/compat/transcriptions -[tokens]: /docs/server-sdks/reference/typescript/rest/compat/tokens - -The `CompatNamespace` provides a Twilio-compatible LAML REST API through the -[`RestClient`][restclient]. It implements the familiar -`/2010-04-01/Accounts/{AccountSid}/` URL structure with 12 sub-resources, making it -straightforward to migrate existing Twilio integrations to SignalWire. - -Access via `client.compat` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const calls = await client.compat.calls.list(); -``` - - -The Compat namespace uses the same REST patterns as Twilio's API. If you are migrating -from Twilio, most code changes are limited to updating the client initialization to use -SignalWire credentials. Resource identifiers use SIDs (e.g., `CA...` for calls, `SM...` -for messages). - - -## **Sub-resources** - - - - Account and subproject management. - - - Call management with recording and stream sub-resources. - - - SMS/MMS messaging with media sub-resources. - - - Fax management with media sub-resources. - - - Conference management with participants, recordings, and streams. - - - Phone number management, search, and import. - - - Application configuration management. - - - LAML (cXML) script management. - - - Queue management with member operations. - - - Recording management. - - - Transcription management. - - - API token management. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/create.mdx deleted file mode 100644 index 8a0c80e0f3..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/create.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/laml-bins/create -description: Create a new LAML bin. -max-toc-depth: 3 ---- - - -Create a new LAML bin containing a cXML/LaML script. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const lamlBin = await client.compat.lamlBins.create({ - Name: "Greeting", - Contents: - '' + - "Hello!", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/delete.mdx deleted file mode 100644 index e5d78698f3..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/delete.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/laml-bins/delete -description: Delete a LAML bin. -max-toc-depth: 3 ---- - - -Delete a LAML bin. - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.lamlBins.delete("LB..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/get.mdx deleted file mode 100644 index ed0327a748..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/laml-bins/get -description: Retrieve a single LAML bin by SID. -max-toc-depth: 3 ---- - - -Retrieve a single LAML bin by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const lamlBin = await client.compat.lamlBins.get("LB..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/index.mdx deleted file mode 100644 index 5455ca3ee0..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/index.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "LAML Bins" -slug: /reference/typescript/rest/compat/laml-bins -description: Manage LAML bins (cXML/LaML scripts) with CRUD operations. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/laml-bins/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/laml-bins/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/laml-bins/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/laml-bins/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/laml-bins/delete - -Manage LAML bins with CRUD operations. LAML bins store reusable cXML/LaML scripts -that can be referenced by URL in call and message handling. - -Access via `client.compat.lamlBins` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const bins = await client.compat.lamlBins.list(); -``` - -## **Methods** - - - - List LAML bins in the account. - - - Create a new LAML bin. - - - Retrieve a single LAML bin by SID. - - - Update a LAML bin. - - - Delete a LAML bin. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/list.mdx deleted file mode 100644 index b952c9da74..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/laml-bins/list -description: List LAML bins in the account. -max-toc-depth: 3 ---- - - -List LAML bins in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const bins = await client.compat.lamlBins.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/update.mdx deleted file mode 100644 index 2350f173cf..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/laml-bins/update.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/laml-bins/update -description: Update a LAML bin. -max-toc-depth: 3 ---- - - -Update a LAML bin's content or name. Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.lamlBins.update("LB...", { - Name: "Greeting", - Contents: - '' + - "Goodbye!", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/create.mdx deleted file mode 100644 index 7f9915cef5..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/create.mdx +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/messages/create -description: Send a new SMS or MMS message. -max-toc-depth: 3 ---- - - -Send a new SMS or MMS message. - - - -## **Response Example** - - - -## **Example** - -```typescript {9,16} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -// Send an SMS -const msg = await client.compat.messages.create({ - To: "+15559876543", - From: "+15551234567", - Body: "Hello from SignalWire!", -}); - -// Send an MMS with an image -const mms = await client.compat.messages.create({ - To: "+15559876543", - From: "+15551234567", - Body: "Check this out", - MediaUrl: ["https://example.com/image.jpg"], -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/delete-media.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/delete-media.mdx deleted file mode 100644 index 9ede121e0a..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/delete-media.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "deleteMedia" -slug: /reference/typescript/rest/compat/messages/delete-media -description: Delete a media item from a message. -max-toc-depth: 3 ---- - - -Delete a media item from a message. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.messages.deleteMedia("SM...", "ME..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/delete.mdx deleted file mode 100644 index 6dceb9a2c3..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/delete.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/messages/delete -description: Delete a message record. -max-toc-depth: 3 ---- - - -Delete a message record. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.messages.delete("SM..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/get-media.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/get-media.mdx deleted file mode 100644 index b7451b2cec..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/get-media.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "getMedia" -slug: /reference/typescript/rest/compat/messages/get-media -description: Retrieve a specific media item from a message. -max-toc-depth: 3 ---- - - -Retrieve a specific media item from a message. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const item = await client.compat.messages.getMedia("SM...", "ME..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/get.mdx deleted file mode 100644 index e9e90a8f44..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/messages/get -description: Retrieve a single message by SID. -max-toc-depth: 3 ---- - - -Retrieve a single message by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const message = await client.compat.messages.get("SM..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/index.mdx deleted file mode 100644 index 5522400be3..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/index.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -title: "Messages" -slug: /reference/typescript/rest/compat/messages -description: Manage SMS and MMS messages with media sub-resources. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/messages/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/messages/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/messages/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/messages/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/messages/delete -[listmedia]: /docs/server-sdks/reference/typescript/rest/compat/messages/list-media -[getmedia]: /docs/server-sdks/reference/typescript/rest/compat/messages/get-media -[deletemedia]: /docs/server-sdks/reference/typescript/rest/compat/messages/delete-media - -Manage SMS and MMS messages with CRUD operations and media sub-resources. - -Access via `client.compat.messages` on a [`RestClient`][restclient] instance. - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const messages = await client.compat.messages.list(); -``` - -## **Methods** - -### Message CRUD - - - - List messages in the account. - - - Send a new SMS or MMS message. - - - Retrieve a single message by SID. - - - Update a message (e.g., redact the body). - - - Delete a message record. - - - -### Media - - - - List media items attached to a message. - - - Retrieve a specific media item from a message. - - - Delete a media item from a message. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/list-media.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/list-media.mdx deleted file mode 100644 index b99e6dc873..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/list-media.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "listMedia" -slug: /reference/typescript/rest/compat/messages/list-media -description: List media items attached to a message. -max-toc-depth: 3 ---- - - -List media items (images, files) attached to a message. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const media = await client.compat.messages.listMedia("SM..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/list.mdx deleted file mode 100644 index 197628c2c7..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/messages/list -description: List messages in the account. -max-toc-depth: 3 ---- - - -List messages in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const messages = await client.compat.messages.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/update.mdx deleted file mode 100644 index 6c3c0fe0a5..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/messages/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/messages/update -description: Update a message (e.g., redact the body). -max-toc-depth: 3 ---- - - -Update a message (e.g., redact the body of a sent message). Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.messages.update("SM...", { Body: "" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/delete.mdx deleted file mode 100644 index 598aa94919..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/delete.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/phone-numbers/delete -description: Release a phone number. -max-toc-depth: 3 ---- - - -Release a phone number from the account. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -await client.compat.phoneNumbers.delete("PN..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/get.mdx deleted file mode 100644 index 7a308f9f8a..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/get.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/phone-numbers/get -description: Retrieve a single phone number by SID. -max-toc-depth: 3 ---- - - -Retrieve a single phone number by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const number = await client.compat.phoneNumbers.get("PN..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/import-number.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/import-number.mdx deleted file mode 100644 index 9d056e6b21..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/import-number.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "importNumber" -slug: /reference/typescript/rest/compat/phone-numbers/import-number -description: Import an external phone number. -max-toc-depth: 3 ---- - - -Import an external phone number into the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const number = await client.compat.phoneNumbers.importNumber({ - number: "+15559876543", - number_type: "longcode", -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/index.mdx deleted file mode 100644 index 482aabad61..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/index.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: "Phone Numbers" -slug: /reference/typescript/rest/compat/phone-numbers -description: Manage phone numbers, search available inventory, and import numbers. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/list -[purchase]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/purchase -[get]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/delete -[importnumber]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/import-number -[listavailablecountries]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/list-available-countries -[searchlocal]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/search-local -[searchtollfree]: /docs/server-sdks/reference/typescript/rest/compat/phone-numbers/search-toll-free - -Manage incoming phone numbers with CRUD operations, search available inventory -by country, and import external numbers. - -Access via `client.compat.phoneNumbers` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const numbers = await client.compat.phoneNumbers.list(); -``` - -## **Methods** - -### Phone Number CRUD - - - - List incoming phone numbers in the account. - - - Purchase a new phone number. - - - Retrieve a single phone number by SID. - - - Update a phone number's configuration. - - - Release a phone number. - - - -### Import - - - - Import an external phone number. - - - -### Available Numbers - - - - List countries with available phone numbers. - - - Search for available local numbers in a country. - - - Search for available toll-free numbers in a country. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/list-available-countries.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/list-available-countries.mdx deleted file mode 100644 index c9c853cca1..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/list-available-countries.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "listAvailableCountries" -slug: /reference/typescript/rest/compat/phone-numbers/list-available-countries -description: List countries with available phone numbers. -max-toc-depth: 3 ---- - - -List countries that have phone numbers available for purchase. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const countries = await client.compat.phoneNumbers.listAvailableCountries(); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/list.mdx deleted file mode 100644 index 907ac49a22..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/list.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/phone-numbers/list -description: List incoming phone numbers in the account. -max-toc-depth: 3 ---- - - -List incoming phone numbers in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const numbers = await client.compat.phoneNumbers.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/purchase.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/purchase.mdx deleted file mode 100644 index d1556938ad..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/purchase.mdx +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: "purchase" -slug: /reference/typescript/rest/compat/phone-numbers/purchase -description: Purchase a new phone number. -max-toc-depth: 3 ---- - - -Purchase a new phone number for the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const number = await client.compat.phoneNumbers.purchase({ - PhoneNumber: "+15551234567", - FriendlyName: "Main Line" -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/search-local.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/search-local.mdx deleted file mode 100644 index fabd9068c4..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/search-local.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "searchLocal" -slug: /reference/typescript/rest/compat/phone-numbers/search-local -description: Search for available local numbers in a country. -max-toc-depth: 3 ---- - - -Search for available local phone numbers in a specific country. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const numbers = await client.compat.phoneNumbers.searchLocal("US", { AreaCode: "512" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/search-toll-free.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/search-toll-free.mdx deleted file mode 100644 index 81b70ddf20..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/search-toll-free.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "searchTollFree" -slug: /reference/typescript/rest/compat/phone-numbers/search-toll-free -description: Search for available toll-free numbers in a country. -max-toc-depth: 3 ---- - - -Search for available toll-free phone numbers in a specific country. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const numbers = await client.compat.phoneNumbers.searchTollFree("US", { Contains: "800" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/update.mdx deleted file mode 100644 index d1b2821678..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/phone-numbers/update.mdx +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/phone-numbers/update -description: Update a phone number's configuration. -max-toc-depth: 3 ---- - - -Update a phone number's configuration (e.g., change voice/SMS URLs). Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -await client.compat.phoneNumbers.update("PN...", { - VoiceUrl: "https://example.com/voice" -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/create.mdx deleted file mode 100644 index 1296506692..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/create.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/queues/create -description: Create a new queue. -max-toc-depth: 3 ---- - - -Create a new call queue. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const queue = await client.compat.queues.create({ - FriendlyName: "Support Queue", - MaxSize: 100 -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/dequeue-member.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/dequeue-member.mdx deleted file mode 100644 index 2e565b857f..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/dequeue-member.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: "dequeueMember" -slug: /reference/typescript/rest/compat/queues/dequeue-member -description: Dequeue a member from a queue. -max-toc-depth: 3 ---- - - -Dequeue a member from a queue, redirecting the call to a new LAML URL. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.queues.dequeueMember( - "QU...", "CA...", - { Url: "https://example.com/dequeue" } -); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/get-member.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/get-member.mdx deleted file mode 100644 index 5e215f4f92..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/get-member.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "getMember" -slug: /reference/typescript/rest/compat/queues/get-member -description: Retrieve a specific queue member. -max-toc-depth: 3 ---- - - -Retrieve a specific member from a queue by call SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const member = await client.compat.queues.getMember("QU...", "CA..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/get.mdx deleted file mode 100644 index d7ad7f7328..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/get.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/queues/get -description: Retrieve a single queue by SID. -max-toc-depth: 3 ---- - - -Retrieve a single queue by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const queue = await client.compat.queues.get("QU..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/index.mdx deleted file mode 100644 index 86cadadcac..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/index.mdx +++ /dev/null @@ -1,69 +0,0 @@ ---- -title: "Queues" -slug: /reference/typescript/rest/compat/queues -description: Manage call queues with CRUD operations and member management. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/queues/list -[create]: /docs/server-sdks/reference/typescript/rest/compat/queues/create -[get]: /docs/server-sdks/reference/typescript/rest/compat/queues/get -[update]: /docs/server-sdks/reference/typescript/rest/compat/queues/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/queues/delete -[listmembers]: /docs/server-sdks/reference/typescript/rest/compat/queues/list-members -[getmember]: /docs/server-sdks/reference/typescript/rest/compat/queues/get-member -[dequeuemember]: /docs/server-sdks/reference/typescript/rest/compat/queues/dequeue-member - -Manage call queues with CRUD operations and member sub-resources for dequeuing -callers. - -Access via `client.compat.queues` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const queues = await client.compat.queues.list(); -``` - -## **Methods** - -### Queue CRUD - - - - List queues in the account. - - - Create a new queue. - - - Retrieve a single queue by SID. - - - Update a queue. - - - Delete a queue. - - - -### Members - - - - List members in a queue. - - - Retrieve a specific queue member. - - - Dequeue a member from a queue. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/list-members.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/list-members.mdx deleted file mode 100644 index 7679c8b32a..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/list-members.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "listMembers" -slug: /reference/typescript/rest/compat/queues/list-members -description: List members in a queue. -max-toc-depth: 3 ---- - - -List members currently waiting in a queue. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const members = await client.compat.queues.listMembers("QU..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/list.mdx deleted file mode 100644 index e348cf3ed9..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/list.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/queues/list -description: List queues in the account. -max-toc-depth: 3 ---- - - -List queues in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const queues = await client.compat.queues.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/update.mdx deleted file mode 100644 index 7509a74156..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/queues/update -description: Update a queue. -max-toc-depth: 3 ---- - - -Update a queue's configuration. Uses POST (Twilio convention). - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -await client.compat.queues.update("QU...", { FriendlyName: "Support Queue", MaxSize: 200 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/delete.mdx deleted file mode 100644 index ab10ff1c46..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/delete.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/recordings/delete -description: Delete a recording. -max-toc-depth: 3 ---- - - -Delete a recording. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -await client.compat.recordings.delete("RE..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/get.mdx deleted file mode 100644 index 98438afffe..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/get.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/recordings/get -description: Retrieve a single recording by SID. -max-toc-depth: 3 ---- - - -Retrieve a single recording by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const recording = await client.compat.recordings.get("RE..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/index.mdx deleted file mode 100644 index 55b49b4ce5..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/index.mdx +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: "Recordings" -slug: /reference/typescript/rest/compat/recordings -description: Manage call recordings. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/recordings/list -[get]: /docs/server-sdks/reference/typescript/rest/compat/recordings/get -[delete]: /docs/server-sdks/reference/typescript/rest/compat/recordings/delete - -Manage call recordings with list, get, and delete operations. - -Access via `client.compat.recordings` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const recordings = await client.compat.recordings.list(); -``` - -## **Methods** - - - - List recordings in the account. - - - Retrieve a single recording by SID. - - - Delete a recording. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/list.mdx deleted file mode 100644 index b952ecb08c..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/recordings/list.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/recordings/list -description: List recordings in the account. -max-toc-depth: 3 ---- - - -List recordings in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const recordings = await client.compat.recordings.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/create.mdx deleted file mode 100644 index c23becb271..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/create.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: "create" -slug: /reference/typescript/rest/compat/tokens/create -description: Create a new API token. -max-toc-depth: 3 ---- - - -Create a new API token. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const token = await client.compat.tokens.create({ - name: "my-token", - permissions: ["voice", "messaging"], -}); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/delete.mdx deleted file mode 100644 index 1f9c4c5f07..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/delete.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/tokens/delete -description: Delete an API token. -max-toc-depth: 3 ---- - - -Delete an API token. - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.tokens.delete("token-id"); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/index.mdx deleted file mode 100644 index 1c35f70092..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/index.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: "Tokens" -slug: /reference/typescript/rest/compat/tokens -description: Manage API tokens. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[create]: /docs/server-sdks/reference/typescript/rest/compat/tokens/create -[update]: /docs/server-sdks/reference/typescript/rest/compat/tokens/update -[delete]: /docs/server-sdks/reference/typescript/rest/compat/tokens/delete - -Manage API tokens with create, update, and delete operations. - -Access via `client.compat.tokens` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -const token = await client.compat.tokens.create({ - name: "my-token", - permissions: ["voice", "messaging"], -}); -``` - -## **Methods** - - - - Create a new API token. - - - Update an API token. - - - Delete an API token. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/update.mdx deleted file mode 100644 index 2379ffc7e7..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/tokens/update.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "update" -slug: /reference/typescript/rest/compat/tokens/update -description: Update an API token. -max-toc-depth: 3 ---- - - -Update an API token. Uses PATCH. - - - -## **Response Example** - - - -## **Example** - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com", -}); - -await client.compat.tokens.update("token-id", { name: "updated-token" }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/delete.mdx deleted file mode 100644 index e2fcd00650..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/delete.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: "delete" -slug: /reference/typescript/rest/compat/transcriptions/delete -description: Delete a transcription. -max-toc-depth: 3 ---- - - -Delete a transcription. - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -await client.compat.transcriptions.delete("TR..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/get.mdx deleted file mode 100644 index d755394c5c..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/get.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "get" -slug: /reference/typescript/rest/compat/transcriptions/get -description: Retrieve a single transcription by SID. -max-toc-depth: 3 ---- - - -Retrieve a single transcription by SID. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const transcription = await client.compat.transcriptions.get("TR..."); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/index.mdx deleted file mode 100644 index a7e503405c..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/index.mdx +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: "Transcriptions" -slug: /reference/typescript/rest/compat/transcriptions -description: Manage call transcriptions. -max-toc-depth: 3 ---- - -[restclient]: /docs/server-sdks/reference/typescript/rest/client -[list]: /docs/server-sdks/reference/typescript/rest/compat/transcriptions/list -[get]: /docs/server-sdks/reference/typescript/rest/compat/transcriptions/get -[delete]: /docs/server-sdks/reference/typescript/rest/compat/transcriptions/delete - -Manage call transcriptions with list, get, and delete operations. - -Access via `client.compat.transcriptions` on a [`RestClient`][restclient] instance. - -```typescript {9} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); - -const transcriptions = await client.compat.transcriptions.list(); -``` - -## **Methods** - - - - List transcriptions in the account. - - - Retrieve a single transcription by SID. - - - Delete a transcription. - - diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/list.mdx deleted file mode 100644 index 83a3499bdc..0000000000 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/transcriptions/list.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "list" -slug: /reference/typescript/rest/compat/transcriptions/list -description: List transcriptions in the account. -max-toc-depth: 3 ---- - - -List transcriptions in the account. - - - -## **Response Example** - - - -## **Example** - -```typescript {8} -import { RestClient } from "@signalwire/sdk"; - -const client = new RestClient({ - project: "your-project-id", - token: "your-api-token", - host: "your-space.signalwire.com" -}); -const transcriptions = await client.compat.transcriptions.list({ PageSize: 20 }); -``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/index.mdx index b123080fe3..180566ee9e 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/index.mdx @@ -32,9 +32,9 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const results = await client.datasphere.documents.search({ query_string: "billing FAQ" }); -for (const doc of results.data ?? []) { - console.log(doc.id, doc.title); +const results = await client.datasphere.documents.search("billing FAQ"); +for (const chunk of results.chunks) { + console.log(chunk.document_id, chunk.text); } ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/search.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/search.mdx index d18cbac91a..892bcbd173 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/search.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/datasphere/search.mdx @@ -26,11 +26,11 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const results = await client.datasphere.documents.search({ - query_string: "How do I reset my password?", - count: 5, -}); -for (const chunk of results.data ?? []) { - console.log(chunk.text, "score:", chunk.score); +const results = await client.datasphere.documents.search( + "How do I reset my password?", + { count: 5 }, +); +for (const chunk of results.chunks) { + console.log(chunk.document_id, chunk.text); } ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/imported-numbers/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/imported-numbers/index.mdx index ad5956c4da..d57d05235f 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/imported-numbers/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/imported-numbers/index.mdx @@ -1,5 +1,5 @@ --- -title: "ImportedNumbersResource" +title: "ImportedNumbers" slug: /reference/typescript/rest/imported-numbers description: Imported Phone Numbers namespace for creating imported numbers. max-toc-depth: 3 diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/index.mdx index b6da0eb9b0..ab174d1098 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/index.mdx @@ -23,7 +23,7 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const messages = await client.logs.messages.list({ pageSize: 20 }); +const messages = await client.logs.messages.list({ page_size: 20 }); for (const msg of messages.data ?? []) { console.log(msg.from, "->", msg.to, msg.status); } diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/list.mdx index b1e759b7fa..7a258d7cae 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/list.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/logs/messages/list.mdx @@ -24,7 +24,7 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const messages = await client.logs.messages.list({ pageSize: 20 }); +const messages = await client.logs.messages.list({ page_size: 20 }); for (const msg of messages.data ?? []) { console.log(msg.from, "->", msg.to, msg.status); } diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/index.mdx index abd4b2ad7d..325fc4b76b 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/index.mdx @@ -24,9 +24,11 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const logs = await client.logs.voice.list({ pageSize: 5 }); +const logs = await client.logs.voice.list({ page_size: 5 }); for (const log of logs.data ?? []) { + if ('from' in log) { console.log(log.id, log.from, "->", log.to); + } } ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/list.mdx index 32638e5cad..0d3b243b81 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/list.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/logs/voice/list.mdx @@ -24,8 +24,10 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const calls = await client.logs.voice.list({ pageSize: 20 }); +const calls = await client.logs.voice.list({ page_size: 20 }); for (const call of calls.data ?? []) { + if ('duration' in call) { console.log(call.from, "->", call.to, call.duration); + } } ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/lookup/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/lookup/index.mdx index acdc4ee968..8e9f6c777d 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/lookup/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/lookup/index.mdx @@ -1,5 +1,5 @@ --- -title: "LookupResource" +title: "Lookup" slug: /reference/typescript/rest/lookup description: Phone Number Lookup namespace. max-toc-depth: 3 diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/messages/create.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/messages/create.mdx new file mode 100644 index 0000000000..5c6f7d29b3 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/messages/create.mdx @@ -0,0 +1,53 @@ +--- +title: "create" +slug: /reference/typescript/rest/messages/create +description: Send an SMS or MMS message. +max-toc-depth: 3 +--- + +Send an SMS or MMS message. Pass the destination and source numbers first, then +any other fields in `options`. A message with `media` is sent as MMS. + + + +## **Response Example** + + + +## **Examples** + +### Send an SMS + +```typescript {9-11} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const message = await client.messages.create("+15559876543", "+15551234567", { + body: "Your Bayview Taxi van is 5 minutes away.", +}); +console.log(message.id, message.status); +``` + +### Send an MMS with a status callback + +```typescript {9-14} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const message = await client.messages.create("+15559876543", "+15551234567", { + body: "Here is your receipt.", + media: ["https://example.com/receipts/4410.png"], + status_callback: "https://example.com/webhooks/message-status", + custom_variables: { ride_id: "ride-4410" }, +}); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/messages/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/messages/index.mdx new file mode 100644 index 0000000000..65b8656c64 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/messages/index.mdx @@ -0,0 +1,43 @@ +--- +title: "Messages" +slug: /reference/typescript/rest/messages +description: "Send SMS and MMS messages and redact message bodies." +max-toc-depth: 3 +--- + +[restclient]: /docs/server-sdks/reference/typescript/rest/client +[logs]: /docs/server-sdks/reference/typescript/rest/logs +[create]: /docs/server-sdks/reference/typescript/rest/messages/create +[update]: /docs/server-sdks/reference/typescript/rest/messages/update + +Send SMS and MMS messages from a phone number on your project, and redact the +body of a message you already sent. To read message history, use the read-only +message logs under [`client.logs.messages`][logs] instead. + +Access via `client.messages` on a [`RestClient`][restclient] instance. + +```typescript {9-11} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const message = await client.messages.create("+15559876543", "+15551234567", { + body: "Your Bayview Taxi van is 5 minutes away.", +}); +console.log(message.id, message.status); +``` + +## **Methods** + + + + Send an SMS or MMS message. + + + Redact the body of a sent message. + + diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/messages/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/messages/update.mdx new file mode 100644 index 0000000000..4111eee397 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/messages/update.mdx @@ -0,0 +1,30 @@ +--- +title: "update" +slug: /reference/typescript/rest/messages/update +description: Redact the body of a sent message. +max-toc-depth: 3 +--- + +Redact the body of a message you already sent. The only field that can be +changed is `body`, and it must be an empty string; any other value is rejected. + + + +## **Response Example** + + + +## **Example** + +```typescript {9} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const redacted = await client.messages.update("message-id", ""); +console.log(redacted.body); // "" +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/overview.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/overview.mdx index 66960ec5bb..4848bcb59c 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/overview.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/overview.mdx @@ -16,7 +16,10 @@ position: 0 [datasphere]: /docs/server-sdks/reference/typescript/rest/datasphere [logs]: /docs/server-sdks/reference/typescript/rest/logs [registry]: /docs/server-sdks/reference/typescript/rest/registry -[compat]: /docs/server-sdks/reference/typescript/rest/compat +[messages]: /docs/server-sdks/reference/typescript/rest/messages +[projects]: /docs/server-sdks/reference/typescript/rest/projects +[request-options]: /docs/server-sdks/reference/typescript/rest/request-options +[rest-error]: /docs/server-sdks/reference/typescript/rest/rest-error [mfa]: /docs/server-sdks/reference/typescript/rest/mfa The REST namespace provides an HTTP client for the SignalWire platform @@ -39,7 +42,7 @@ const client = new RestClient({ }); // Search for available numbers in area code 512 -const available = await client.phoneNumbers.search({ areaCode: "512", quantity: 3 }); +const available = await client.phoneNumbers.search({ areacode: "512", max_results: 3 }); for (const number of available.data ?? []) { console.log(`${number.number} - ${number.region}`); } @@ -51,25 +54,65 @@ console.log(`Purchased: ${purchased.number}`); // List your AI agent resources const response = await client.fabric.aiAgents.list(); for (const agent of response.data ?? []) { - console.log(`Agent: ${agent.name} (${agent.id})`); + console.log(`Agent: ${agent.display_name} (${agent.id})`); } // Query recent voice call logs -const logs = await client.logs.voice.list({ pageSize: 5 }); +const logs = await client.logs.voice.list({ page_size: 5 }); for (const log of logs.data ?? []) { - console.log(`Call from ${log.from} to ${log.to}`); + if ('from' in log) { + console.log(`Call from ${log.from} to ${log.to}`); + } } ``` All three constructor arguments can also be provided via environment variables: -`SIGNALWIRE_PROJECT_ID`, `SIGNALWIRE_API_TOKEN`, and `SIGNALWIRE_SPACE`. +`SIGNALWIRE_PROJECT_ID`, `SIGNALWIRE_API_TOKEN`, and `SIGNALWIRE_SPACE` (or +`SIGNALWIRE_REST_BASE_URL` for a full base URL, which takes precedence). When those are set, you can instantiate with `new RestClient()` and no arguments. -## Error Handling +## Pagination + +`list()` returns one page. `paginate()` returns an async iterator that follows +the server's next-page links and yields one item at a time, so you don't build +the page loop yourself. Query parameters apply to the first request only. + +```typescript {5} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient(); + +for await (const address of client.fabric.addresses.paginate()) { + console.log(address.name); +} +``` + +## Timeouts, retries, and cancellation -REST errors throw `RestError`: +Every resource method accepts a trailing `requestOptions` object that sets the +timeout, retry count, backoff, and an `AbortSignal` for that one call. Pass the +same object to the constructor to set a client-wide default. See +[`RequestOptions`][request-options]. + +```typescript {3,7} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ requestOptions: { timeout: 10, retries: 2 } }); + +const controller = new AbortController(); +const numbers = await client.phoneNumbers.list( + undefined, + { abortSignal: controller.signal }, +); +``` + +## Error handling + +REST errors throw [`RestError`][rest-error]. A request that never reaches the +server, such as a DNS failure or a timeout, throws `RestTransportError`, a +subclass of `RestError` with a `null` status code, so one `catch` handles both: ```typescript {6} import { RestClient, RestError } from "@signalwire/sdk"; @@ -82,6 +125,7 @@ try { if (e instanceof RestError) { console.log(`HTTP ${e.statusCode}: ${e.body}`); console.log(`URL: ${e.method} ${e.url}`); + console.log(`Request ID: ${e.requestId}`); } } ``` @@ -138,10 +182,16 @@ try { 10DLC brand and campaign registration. + Send SMS and MMS messages and redact message bodies. + + - Twilio-compatible LAML API for migration. + Create and manage projects and rotate signing keys. + +## **Response Example** + + + +## **Example** + +```typescript {9-12} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const project = await client.projects.create({ + name: "Bayview Taxi Staging", + protect_recordings: true, +}); +console.log(project.id); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/delete.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/projects/delete.mdx similarity index 53% rename from fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/delete.mdx rename to fern/products/server-sdks/pages/reference/typescript/rest/projects/delete.mdx index 4f1c8fc607..1b594133be 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/compat/queues/delete.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/projects/delete.mdx @@ -1,14 +1,13 @@ --- title: "delete" -slug: /reference/typescript/rest/compat/queues/delete -description: Delete a queue. +slug: /reference/typescript/rest/projects/delete +description: Delete a subproject. max-toc-depth: 3 --- +Delete a subproject. -Delete a queue. - - + ## **Example** @@ -21,5 +20,5 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -await client.compat.queues.delete("QU..."); +await client.projects.delete("project-id"); ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/projects/get.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/projects/get.mdx new file mode 100644 index 0000000000..89b0849c00 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/projects/get.mdx @@ -0,0 +1,29 @@ +--- +title: "get" +slug: /reference/typescript/rest/projects/get +description: Retrieve a project by ID. +max-toc-depth: 3 +--- + +Retrieve a project by ID. + + + +## **Response Example** + + + +## **Example** + +```typescript {9} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const project = await client.projects.get("project-id"); +console.log(project.name, project.region_preference); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/projects/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/projects/index.mdx new file mode 100644 index 0000000000..2cae3f4cf2 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/projects/index.mdx @@ -0,0 +1,58 @@ +--- +title: "Projects" +slug: /reference/typescript/rest/projects +description: "Create and manage projects in your project tree, and rotate signing keys." +max-toc-depth: 3 +--- + +[restclient]: /docs/server-sdks/reference/typescript/rest/client +[project]: /docs/server-sdks/reference/typescript/rest/project +[list]: /docs/server-sdks/reference/typescript/rest/projects/list +[get]: /docs/server-sdks/reference/typescript/rest/projects/get +[create]: /docs/server-sdks/reference/typescript/rest/projects/create +[update]: /docs/server-sdks/reference/typescript/rest/projects/update +[delete]: /docs/server-sdks/reference/typescript/rest/projects/delete +[rotate]: /docs/server-sdks/reference/typescript/rest/projects/rotate-signing-key + +List, create, update, and delete the projects in your project tree, and rotate +a project's signing key. All operations are scoped to the authenticated root +project and its subprojects. For API tokens of the current project, use the +singular [`client.project.tokens`][project] instead. + +Access via `client.projects` on a [`RestClient`][restclient] instance. + +```typescript {9} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const project = await client.projects.create({ name: "Bayview Taxi Staging" }); +console.log(project.id); +``` + +## **Methods** + + + + List the root project and its subprojects. + + + Retrieve a project by ID. + + + Create a subproject. + + + Update a project's name or protection settings. + + + Delete a subproject. + + + Issue a new signing key for a project. + + diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/projects/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/projects/list.mdx new file mode 100644 index 0000000000..2759545a3b --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/projects/list.mdx @@ -0,0 +1,31 @@ +--- +title: "list" +slug: /reference/typescript/rest/projects/list +description: List the authenticated root project and its subprojects. +max-toc-depth: 3 +--- + +List the authenticated root project and its subprojects. Use `paginate()` to +iterate every project across pages. + + + +## **Response Example** + + + +## **Example** + +```typescript {9} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +for await (const project of client.projects.paginate()) { + console.log(project.name, project.subproject ? "(subproject)" : "(root)"); +} +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/projects/rotate-signing-key.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/projects/rotate-signing-key.mdx new file mode 100644 index 0000000000..dff0c5ec55 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/projects/rotate-signing-key.mdx @@ -0,0 +1,33 @@ +--- +title: "rotateSigningKey" +slug: /reference/typescript/rest/projects/rotate-signing-key +description: Issue a new signing key for a project. +max-toc-depth: 3 +--- + +[security]: /docs/server-sdks/reference/typescript/core/security + +Issue a new signing key for a project. The response includes the new key in +`signing_key`; store it and update every service that validates +[webhook signatures][security] with it. + + + +## **Response Example** + + + +## **Example** + +```typescript {9-10} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const rotated = await client.projects.rotateSigningKey("project-id"); +console.log(rotated.signing_key); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/projects/update.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/projects/update.mdx new file mode 100644 index 0000000000..4484796a66 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/projects/update.mdx @@ -0,0 +1,33 @@ +--- +title: "update" +slug: /reference/typescript/rest/projects/update +description: Update a project's name or protection settings. +max-toc-depth: 3 +--- + +Update a project's name or protection settings. Pass the ID, then the typed +body, which always includes `name`; the optional `extras` argument merges +additional fields. + + + +## **Response Example** + + + +## **Example** + +```typescript {9-12} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + project: "your-project-id", + token: "your-api-token", + host: "your-space.signalwire.com" +}); + +const project = await client.projects.update("project-id", { + name: "Bayview Taxi Staging", + force_https_requests: true, +}); +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/pubsub/index.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/pubsub/index.mdx index 489fd0fbb4..5e4ca8dec9 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/pubsub/index.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/pubsub/index.mdx @@ -1,5 +1,5 @@ --- -title: "PubSubResource" +title: "PubSub" slug: /reference/typescript/rest/pubsub description: PubSub API namespace for token creation. max-toc-depth: 3 diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/recordings/list.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/recordings/list.mdx index c8d8297a53..f6e96e40ac 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/recordings/list.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/recordings/list.mdx @@ -24,8 +24,8 @@ const client = new RestClient({ host: "your-space.signalwire.com" }); -const result = await client.recordings.list({ pageSize: 20 }); +const result = await client.recordings.list({ page_size: 20 }); for (const rec of result.data ?? []) { - console.log(rec.id, rec["duration"], rec["state"]); + console.log(rec.id, rec.duration_in_seconds, rec.status); } ``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/request-options.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/request-options.mdx new file mode 100644 index 0000000000..0e668251d9 --- /dev/null +++ b/fern/products/server-sdks/pages/reference/typescript/rest/request-options.mdx @@ -0,0 +1,96 @@ +--- +title: "RequestOptions" +slug: /reference/typescript/rest/request-options +description: Per-request timeout, retry, backoff, and cancellation settings for REST calls. +max-toc-depth: 3 +--- + +[restclient]: /docs/server-sdks/reference/typescript/rest/client +[rest-error]: /docs/server-sdks/reference/typescript/rest/rest-error + +Every REST resource method accepts a trailing `requestOptions` argument that +controls the transport for that one call: how long to wait, whether to retry, +how to back off, and an `AbortSignal` to cancel. Pass the same object as the +`requestOptions` option of the [`RestClient`][restclient] constructor to set a +client-wide default. A per-request value overrides the client default field by +field; an unset field inherits. + +Pass a plain object literal, typed as `RequestOptionsInit`. The `RequestOptions` +class is exported too and is accepted anywhere the plain object is. + +```typescript {1} +import type { RequestOptionsInit } from "@signalwire/sdk"; +``` + +## **Properties** + + + Maximum seconds per attempt. When exceeded, the request throws a + `RestTransportError` (see [`RestError`][rest-error]). + + + + Number of retry attempts after the first failure, so total attempts are + `retries + 1`. Retries are off by default. + + +"} toc={true}> + HTTP statuses that trigger a retry. Defaults to `429`, `500`, `502`, `503`, + and `504`. `GET`, `PUT`, and `DELETE` retry on any status in the set. + `POST` and `PATCH` retry only on `429` and `503`, which mean the request was + not processed, so a partially applied write is never replayed. + + + + Base seconds for exponential backoff between retries, doubling each attempt. + A `Retry-After` response header is honored when present. + + + + Cancels the request. The signal is passed straight to `fetch`, so an + in-flight request is interrupted, and it is checked again before every retry. + + +## **Examples** + +### Client-wide default + +```typescript {4} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient({ + requestOptions: { timeout: 10, retries: 2 }, +}); + +const numbers = await client.phoneNumbers.list(); +``` + +### Per-request override with cancellation + +```typescript {6-8,11} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient(); +const controller = new AbortController(); + +const agents = client.fabric.aiAgents.list(undefined, { + timeout: 5, + abortSignal: controller.signal, +}); + +setTimeout(() => controller.abort(), 2000); +await agents; +``` + +### Retries on every page of an iteration + +`paginate()` forwards the same `requestOptions` to every page fetch. + +```typescript {4} +import { RestClient } from "@signalwire/sdk"; + +const client = new RestClient(); +for await (const address of client.fabric.addresses.paginate(undefined, { retries: 3 })) { + console.log(address.name); +} +``` diff --git a/fern/products/server-sdks/pages/reference/typescript/rest/rest-error.mdx b/fern/products/server-sdks/pages/reference/typescript/rest/rest-error.mdx index 8cd7c7bc02..26a23d8170 100644 --- a/fern/products/server-sdks/pages/reference/typescript/rest/rest-error.mdx +++ b/fern/products/server-sdks/pages/reference/typescript/rest/rest-error.mdx @@ -7,24 +7,27 @@ max-toc-depth: 3 Custom error class for REST API errors. Extends JavaScript's built-in `Error` class. Thrown when an HTTP request to the SignalWire REST API returns a non-success -status code. The `name` property is always `"RestError"`. +status code, or when the request never reaches the server. The `name` property is +`"RestError"`, or `"RestTransportError"` for the transport subclass below. Also exported as `SignalWireRestError` to match the Python SDK class name. ```typescript {1} -import { RestError } from '@signalwire/sdk'; +import { RestError } from "@signalwire/sdk"; ``` ## **Properties** - - HTTP status code returned by the API (e.g., `404`, `422`, `500`). + + HTTP status code returned by the API (e.g., `404`, `422`, `500`). `null` for + a `RestTransportError`, where no response was received. -"} toc={true}> - Response body from the API. Parsed as JSON when the response was valid - JSON; otherwise the raw text. Matches the Python SDK's - `SignalWireRestError.body` behavior. + + Response body from the API. A `SignalWireErrorBody` object (`code`, + `message`, and optional `more_info` and `status`) when the response was valid + JSON; otherwise the raw text. For a `RestTransportError`, the underlying + transport error message. @@ -35,14 +38,40 @@ import { RestError } from '@signalwire/sdk'; The HTTP method used (`"GET"`, `"POST"`, `"PUT"`, `"PATCH"`, `"DELETE"`). + | null"} toc={true}> + Response headers from the failed request. `null` for a transport failure. + + + + The platform request ID read from the response headers, or `null` when + absent. Quote it when you contact support about a failed request. + + - Always `"RestError"`. + `"RestError"`, or `"RestTransportError"` for a transport failure. - Human-readable summary: `"{method} {url} returned {statusCode}: {body}"`. + Human-readable summary: `"{method} {url} returned {statusCode}: {body}"` for + an HTTP error, or `"{method} {url} failed to reach the server: {body}"` for a + transport failure. Followed by `(request-id: ...)` when a request ID is + available. +## **RestTransportError** + +Thrown when a request never reaches a response: a connection refused, a DNS +failure, a TLS error, or a `RequestOptions` timeout. It extends `RestError`, so +one `catch (e instanceof RestError)` handles HTTP errors and transport failures +alike. `statusCode`, `headers`, and `requestId` are `null`, and `body` holds the +underlying transport error message. + +Also exported as `SignalWireRestTransportError`. + +```typescript {1} +import { RestTransportError } from "@signalwire/sdk"; +``` + ## **Example** ```typescript {9} @@ -60,6 +89,7 @@ try { if (e instanceof RestError) { console.log(`HTTP ${e.statusCode}: ${e.body}`); console.log(`Request: ${e.method} ${e.url}`); + console.log(`Request ID: ${e.requestId}`); } } ``` diff --git a/fern/products/server-sdks/sdk-source-sync.json b/fern/products/server-sdks/sdk-source-sync.json index 61debc1672..0086273f16 100644 --- a/fern/products/server-sdks/sdk-source-sync.json +++ b/fern/products/server-sdks/sdk-source-sync.json @@ -12,8 +12,8 @@ "repository": "https://github.com/signalwire/signalwire-typescript.git", "local_path": "temp/signalwire-typescript", "status": "active", - "synced_commit": "9140e11d438d0df40187f817dbccb4ea63cc3465", - "synced_at": "2026-06-03" + "synced_commit": "6a2aa09a3dce2221ba2e0dfc21ee6262dac8e6c2", + "synced_at": "2026-09-04" }, "go": { "repository": "https://github.com/signalwire/signalwire-go.git", diff --git a/fern/snippets/server-sdks/control-id-note.mdx b/fern/snippets/server-sdks/control-id-note.mdx new file mode 100644 index 0000000000..268c3976f6 --- /dev/null +++ b/fern/snippets/server-sdks/control-id-note.mdx @@ -0,0 +1,3 @@ +`control_id` is a caller-chosen identifier for this operation, unique per +active operation of this kind on the call. The TypeScript SDK types it as +optional, but the API requires it — a request that omits it is rejected. diff --git a/fern/snippets/server-sdks/npm-install.mdx b/fern/snippets/server-sdks/npm-install.mdx new file mode 100644 index 0000000000..55d5148d56 --- /dev/null +++ b/fern/snippets/server-sdks/npm-install.mdx @@ -0,0 +1,3 @@ +```bash +npm install @signalwire/sdk +```