Skip to main content
env.MY_TELNYX is a ready-to-use, authenticated Telnyx client handle — call it like any Telnyx API client, with auth already wired in (no new Telnyx(...), no API key to manage). Calls take the shape env.MY_TELNYX.<resource>.<method>(...), using resource and method names — not raw HTTP paths:
  • <resource> — a camelCase property: messages, calls, balance, availablePhoneNumbers, …
  • <method> — a method on the resource: .send, .dial, .list, .retrieve, …
The names don’t always track the HTTP API (messages.send is POST /messages, but messages.cancelScheduled is DELETE /messages/{id}), so discover them rather than guessing from endpoints:
import { env } from "@telnyx/edge-runtime";

await env.MY_TELNYX.messages.send({ from, to, text });                              // POST /messages
await env.MY_TELNYX.calls.dial({ connection_id, from, to });                        // POST /calls
await env.MY_TELNYX.availablePhoneNumbers.list({ filter: { country_code: "US" } }); // GET /available_phone_numbers
await env.MY_TELNYX.balance.retrieve();                                             // GET /balance
Each method returns the API response; list and retrieve calls expose the payload on .data.

Errors

Calls reject on API errors. Catch and inspect:
try {
  await env.MY_TELNYX.messages.send({ from, to, text });
} catch (err) {
  // err.status (e.g. 400), err.message, err.error (parsed body)
}