Skip to main content
The types in this reference are exported from @telnyx/edge-runtime (TypeScript) and describe version ≥ 0.9.0 — the first release that exports SqlDatabase and wires the env binding. They describe the env binding, the in-function surface. Running SQL from outside a function — schema changes, ad-hoc queries, migrations — goes over a separate REST path, covered in the CLI reference.
The SQL Databases Runtime API is a single binding type plus the statement and result types its methods return. A database declared as [storage.sqldb.<NAME>] in telnyx.toml resolves on env.<NAME> as a SqlDatabase.

Getting the Binding

Read the binding off the imported env — not the env argument of fetch(request, env). The object handed to fetch carries actor bindings only: env.DB on it is undefined, and the call fails at runtime with Cannot read properties of undefined (reading 'prepare') even though it type-checks cleanly. The generated types deliberately declare the binding in both places, so the compiler will not catch this.
Declaring the binding is covered in the Quick Start. The binding resolves at runtime from telnyx.toml; run telnyx-edge types after editing the manifest to regenerate telnyx-env.d.ts, which types env.<NAME> as a SqlDatabase. That command checks the @telnyx/edge-runtime version declared in package.json and fails with @telnyx/edge-runtime <version> does not export SqlDatabase (requires >= 0.9.0) when the floor is not met.
  • SqlDatabase — the method-by-method reference
  • Quick Start — create a database, bind it, query it
  • How SQL Databases Work — one primary per database, and what that means for consistency
  • Bindings — how bindings resolve on env
  • CLItelnyx-edge storage sqldb for provisioning, ad-hoc SQL, and migrations
  • Limits — database and value size, bound parameters, and query performance
  • Stateful Actor SQL — a different product: the private embedded SQLite at ctx.storage.sql, visible to one actor instance only and called synchronously