fetch API (available natively in Node.js 18+ and on modern edge runtimes). There is no TypeScript-specific SDK package yet, the recommended pattern is a thin typed wrapper module in your own codebase that centralizes the base URL, authentication header, and error handling. The example below mirrors the operations published in /api-reference/openapi.json and is a good starting point for production server code.
When to use this
- Server-side Node.js services that trigger outbound calls from CRM events, scheduled jobs, or upstream webhooks.
- Edge runtimes (Cloudflare Workers, Vercel Edge Functions, Netlify Edge Functions) where you need a low-latency request path.
- Internal tools and dashboards built with Next.js, Remix, or similar frameworks where DialNexa operations run in route handlers.
DIALNEXA_API_KEY must stay server-side. For browser-side voice call embedding, use the React SDK. For mobile apps, see the React Native SDK.
Triggering an outbound call
Recommended patterns
- Type every request and response. The examples above declare explicit
CreateCallRequestandCreateCallResponsetypes, keep this discipline so a wrong field name surfaces at compile time rather than at runtime. - Centralize the client. Wrap the snippet above in a single module (for example
dialnexaClient.ts) and import it from every route handler and worker. - Use environment variables for the API key. Never inline keys in source. Make sure your bundler does not expose them to the client.
- Set explicit timeouts. Pass an
AbortSignalfromAbortSignal.timeout(30_000)if your runtime supports it. - Retry on transient failures only. Retry HTTP 502/503/504 and network errors with exponential backoff. Do not retry 4xx responses, those indicate a payload that needs to be fixed. See Errors.
- Validate webhook deliveries. For inbound events from DialNexa, verify the signing secret before trusting the payload. See Webhook secrets.
This example is generated from the currently published schema in
/api-reference/openapi.json: agent_id and to_phone_number are required.Related pages
- API Introduction: base URLs, authentication, request and response shape.
- Trigger a Call: full OpenAPI schema for the operation above.
- Errors: error format and codes returned by every endpoint.
- Dynamic Variables: injecting context into agent prompts via
metadata. - Authentication: how API keys are sent and verified.