Skip to main content
A Stateful Actor project ships from one module that exports two things, wired together by a binding declared in telnyx.toml.

Two Exports

One module exports the actor class and a fetch handler — an ordinary Edge Compute function that calls the actor through a binding on env. The deploy pipeline routes each export to the right runtime.
import { type ActorNamespace, type ActorStub } from "@telnyx/edge-runtime";
import { Account } from "./account";
export { Account };

type AccountStub = ActorStub & Pick<Account, "debit">;
interface AccountNamespace extends ActorNamespace {
  idFromName(name: string): AccountStub;
}
interface Env { ACCOUNT: AccountNamespace }

export default {
  async fetch(req: Request, env: Env): Promise<Response> {
    const acct = new URL(req.url).pathname.slice(1);      // /acct_123
    const { amount } = (await req.json()) as { amount: number };
    const result = await env.ACCOUNT.idFromName(acct).debit(amount);
    return Response.json(result);
  },
};

The Binding

env.ACCOUNT is declared in telnyx.toml as an [[actors]] entry — binding is the property on env, type is the class to instantiate per name:
name = "account-svc"
main = "src/index.ts"

[[actors]]
binding = "ACCOUNT"   # the property on env — your handle
type    = "Account"   # the class to instantiate per name
See the Runtime API for the full telnyx.toml actor block. The Quick Start builds and deploys exactly this shape — the Account actor plus its fetch handler — end to end.

Next Steps