{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/functions/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["partial"]},"type":"markdown"},"seo":{"title":"Developer Documentation","siteUrl":"https://developers.sinch.com","llmstxt":{"title":"Sinch Developer Documentation","description":"LLMs.txt containing a map of all the documentation files for Sinch.","sections":[{"title":"SMS API","description":"The SMS API allows you to send and receive SMS messages with a few easy steps. You can also send bulk SMS messages to multiple customers using the Sinch SMS service.","includeFiles":["docs/sms/**/*.md","docs/sms/**/*.yaml"],"excludeFiles":["docs/sms/index.md"]},{"title":"Numbers API","description":"The Numbers API enables you to search for, view, and activate numbers. It's considered a precursor to other APIs in the Sinch product family. The numbers API can be used in tandem with any of our APIs that perform messaging or calling.","includeFiles":["docs/numbers/**/*.md","docs/numbers/**/*.yaml"],"excludeFiles":["docs/numbers/index.md"]},{"title":"Conversation API","description":"Send and receive messages globally on many popular channels with ease and confidence when using Sinch's Conversation API. Conversation API is the preferred API for sending mobile messages on SMS and other social channels with Sinch. It is a simple API with unified error messages, consistent request payloads, and common webhook payloads that are channel-agnostic.","includeFiles":["docs/conversation/**/*.md","docs/conversation/**/*.yaml"],"excludeFiles":["docs/conversation/index.md"]},{"title":"Voice API","description":"The Voice API works as a big telephony switch. The Voice API handles incoming phone calls (also known as incoming call “legs”), sets up outgoing phone calls (or outgoing call “legs”), and bridges the two. The incoming call leg may come in over a data connection (from a smartphone or web application using the Sinch SDKs) or through a local phone number (from the PSTN network). Similarly, the outgoing call leg can be over data (to another smartphone or web application using the Sinch SDKs) or the PSTN network.","includeFiles":["docs/voice/**/*.md","docs/voice/**/*.yaml"],"excludeFiles":["docs/voice/index.md"]},{"title":"Verification API","description":"The Verification API is a platform for phone number verification. It consists of the API and different software development kits (the Sinch SDKs) that you integrate with your smartphone or web application and cloud based back-end services. Together they enable SMS, Flashcall, Phone Call and Data verification in your application.","includeFiles":["docs/verification/**/*.md","docs/verification/**/*.yaml"],"excludeFiles":["docs/verification/index.md"]},{"title":"Provisioning API","description":"Provisioning API allows you to programmatically set up your senders, accounts and templates on your favorite messaging platforms on the Conversation API. For now, you can create your first WhatsApp channel through Meta's Embedded sign up, you can configure your first SMS App and configure your webhooks. As development continues, we will be adding the most commonly used channels.","includeFiles":["docs/provisioning-api/**/*.md","docs/provisioning-api/**/*.json"],"excludeFiles":["docs/provisioning-api/index.md"]},{"title":"Elastic SIP Trunking API","description":"With Elastic SIP Trunking you can create and manage your SIP trunks and phone numbers programmatically.","includeFiles":["docs/est/**/*.md","docs/est/**/*.yaml"],"excludeFiles":["docs/est/index.md"]},{"title":"Fax API","description":"Send and receive HIPAA compliant faxes on our modern fax platform using our developer-friendly API.","includeFiles":["docs/fax/**/*.md","docs/fax/**/*.yaml"],"excludeFiles":["docs/fax/index.md"]},{"title":"In-app Voice and Video SDK","description":"The In-app Voice and Video SDK enables you to add voice and video calling capabilities directly into your mobile or web application using the Sinch SDKs.","includeFiles":["docs/in-app-calling/**/*.md"],"excludeFiles":["docs/in-app-calling/index.md"]}],"hide":false,"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"handlers","__idx":0},"children":["Handlers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you know Express or ASP.NET MVC, you already know 90% of the Sinch runtime. This page is the other 10% — the conventions Sinch uses to decide which of your handlers runs when a request comes in."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"the-mental-model","__idx":1},"children":["The mental model"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node runtime is effectively Express with conventions."]}," You export handlers, the runtime maps URL paths to them, you get a request and return a response."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["C# runtime is ASP.NET MVC with controllers."]}," You extend a base controller, override the methods you care about, and dependency injection wires up services and SDK clients."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["That's it. Everything below is the specifics."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"nodejs-named-exports-are-routes","__idx":2},"children":["Node.js: named exports are routes"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["function.ts"]}," file exports an object (or individual named exports). Each export becomes an HTTP endpoint."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import type { VoiceFunction, FunctionContext, FunctionRequest } from '@sinch/functions-runtime';\nimport { IceSvamlBuilder } from '@sinch/functions-runtime';\n\nexport default {\n  // POST /ice — voice callback, auto-detected by name\n  async ice(context, data) {\n    return new IceSvamlBuilder().say('Welcome!').hangup().build();\n  },\n\n  // GET /status — custom HTTP endpoint\n  async status(context, request) {\n    return { statusCode: 200, body: { ok: true } };\n  },\n\n  // GET /health — custom HTTP endpoint\n  async health(context, request) {\n    return { statusCode: 200, body: { healthy: true } };\n  },\n} satisfies VoiceFunction;\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"routing-rules","__idx":3},"children":["Routing rules"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Request path"},"children":["Request path"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Export called"},"children":["Export called"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Treated as"},"children":["Treated as"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /ice"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ice"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /ace"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ace"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /pie"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pie"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /dice"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["dice"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /notify"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["notify"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /webhook/conversation"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["conversationWebhook"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Conversation"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /api/health"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["health"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Custom HTTP"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /api/v2/users"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["users"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Custom HTTP"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["default"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["home"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Custom HTTP root"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The rules in plain English:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The last segment of the URL path is matched to an export name."]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/v2/users"]}," → export ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["users"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ice"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ace"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pie"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["dice"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["notify"]}," are voice callbacks regardless of path."]}," They get the callback payload as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data"]}," and should return SVAML."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/webhook/<service>"]}," is a special pattern."]}," It maps to a camelCase name with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Webhook"]}," suffixed — ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/webhook/conversation"]}," → ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["conversationWebhook"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["default"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["home"]}," both catch ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /"]},"."]}," Use whichever feels more natural; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["home"]}," is TypeScript-friendlier since ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["default"]}," is a reserved word."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"voice-callbacks-vs-custom-endpoints","__idx":4},"children":["Voice callbacks vs custom endpoints"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Handler type"},"children":["Handler type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Signature"},"children":["Signature"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Returns"},"children":["Returns"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["(context, data: Voice.IceRequest)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["SVAML (from a builder)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Custom endpoint"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["(context, request: FunctionRequest)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{ statusCode, body }"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Return any plain ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{ statusCode, body, headers? }"]}," object:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"return { statusCode: 200, body: { status: 'healthy' } };\nreturn { statusCode: 400, body: { error: 'Missing required field: name' } };\nreturn { statusCode: 404, body: { error: 'Not found' } };\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"c-extend-a-controller","__idx":5},"children":["C#: extend a controller"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"public class FunctionController : SinchVoiceController\n{\n    public FunctionController(\n        FunctionContext context,\n        IConfiguration configuration,\n        ILogger<FunctionController> logger)\n        : base(context, configuration, logger) { }\n\n    public override async Task<IActionResult> Ice(IceCallbackModel data)\n    {\n        return Ok(new IceSvamletBuilder()\n            .Instructions.Say(\"Welcome!\")\n            .Action.Hangup()\n            .Build());\n    }\n\n    public override Task<IActionResult> Pie(PieCallbackModel data) => ...;\n    public override Task<IActionResult> Ace(AceCallbackModel data) => ...;\n    public override Task<IActionResult> Dice(DiceCallbackModel data) => ...;\n}\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"the-four-base-controllers","__idx":6},"children":["The four base controllers"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Base class"},"children":["Base class"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"When to use"},"children":["When to use"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchVoiceController"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Voice callback handling. Override ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Ice"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Ace"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Pie"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Dice"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchConversationController"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Conversation API webhooks (SMS, WhatsApp, Messenger, etc.)."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ElevenLabsController"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["ElevenLabs AI voice agent webhooks."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchController"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Plain HTTP controllers (your own REST endpoints)."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can have more than one controller in your project — extend ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchVoiceController"]}," for voice and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchController"]}," for your custom API endpoints side by side."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"custom-http-endpoints","__idx":7},"children":["Custom HTTP endpoints"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For non-voice endpoints, use a regular ASP.NET MVC controller that extends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchController"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"[Route(\"api\")]\npublic class MyController : SinchController\n{\n    public MyController(FunctionContext context, IConfiguration config, ILogger<MyController> logger)\n        : base(context, config, logger) { }\n\n    [HttpGet(\"status\")]\n    public IActionResult GetStatus() => Ok(new { status = \"healthy\" });\n}\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"dependency-injection-and-startup","__idx":8},"children":["Dependency injection and startup"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Implement ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ISinchFunctionInit"]}," to register services, configure middleware, or map extra routes. The runtime discovers it automatically — there is no ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Program.cs"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"csharp","header":{"controls":{"copy":{}}},"source":"public class FunctionInit : ISinchFunctionInit\n{\n    public void ConfigureServices(IServiceCollection services, IConfiguration configuration)\n    {\n        services.AddScoped<ICustomerService, CustomerService>();\n        services.AddHttpClient<IMyApiClient, MyApiClient>();\n    }\n\n    public void ConfigureApp(SinchWebApplication app)\n    {\n        app.LandingPageEnabled = true;\n        app.MapGet(\"/custom\", () => Results.Ok(new { status = \"ok\" }));\n    }\n}\n","lang":"csharp"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your middleware runs after the platform middleware, so billing and logging cannot be bypassed."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"node-extension-points","__idx":9},"children":["Node extension points"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"setup--startup-hook-and-websockets","__idx":10},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setup()"]}," — startup hook and WebSockets"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Node functions can export a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setup()"]}," function that runs once before the server accepts requests. Use it for initialization and to register WebSocket endpoints (for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["connectStream"]}," in SVAML)."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import type { SinchRuntime, FunctionContext } from '@sinch/functions-runtime';\n\nexport function setup(runtime: SinchRuntime) {\n  runtime.onStartup(async (context: FunctionContext) => {\n    // Create tables, seed data, warm caches\n  });\n\n  runtime.onWebSocket('/stream', (ws, req) => {\n    ws.on('message', (data) => {\n      // Handle binary audio frames\n    });\n  });\n}\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SinchRuntime"]}," is intentionally narrow — you cannot reach the Express app or add middleware. That is on purpose: the runtime guarantees platform middleware (billing, logging, validation) runs regardless of what your function does."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"multi-file-node-projects","__idx":11},"children":["Multi-file Node projects"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["function.ts"]}," is the entry point, and all endpoints must be exported from it. Other files in the project root are internal modules you import from."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"function.ts          ← entry point, all exports live here\nharness.ts           ← shared business logic\nvoice.ts             ← voice handler implementations\napi.ts               ← REST endpoint implementations\nassets/              ← private files (context.assets())\npublic/              ← static files (served at /)\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Relative imports use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".js"]}," extensions because the shared tsconfig uses NodeNext:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"typescript","header":{"controls":{"copy":{}}},"source":"import { handleMessage } from './harness.js';\nimport { handleIce } from './voice.js';\n","lang":"typescript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Keep all source files at the project root — the runtime expects them flat."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"when-something-goes-wrong","__idx":12},"children":["When something goes wrong"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On startup, both runtimes log the set of detected handlers:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Detected functions:\n  POST /webhook/conversation  → conversationWebhook\n  GET  /api/health            → health\n  POST /ice                   → ice (voice)\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If a request hits a path with no matching export, the error response lists the handlers you do have. That is almost always the first thing to check when a callback is not firing — make sure Sinch's callback URL matches a handler name, and make sure it is actually exported."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"related","__idx":13},"children":["Related"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"#"},"children":["Voice callbacks"]}," — ICE/ACE/PIE/DICE lifecycle and payloads"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"#"},"children":["SVAML"]}," — what voice handlers return"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"#"},"children":["Context object"]}," — the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["context"]}," argument every handler receives"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"#"},"children":["Node.js runtime"]}," / ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#"},"children":["C# runtime"]}," — per-runtime reference"]}]}]},"headings":[{"value":"Handlers","id":"handlers","depth":1},{"value":"The mental model","id":"the-mental-model","depth":2},{"value":"Node.js: named exports are routes","id":"nodejs-named-exports-are-routes","depth":2},{"value":"Routing rules","id":"routing-rules","depth":3},{"value":"Voice callbacks vs custom endpoints","id":"voice-callbacks-vs-custom-endpoints","depth":3},{"value":"C#: extend a controller","id":"c-extend-a-controller","depth":2},{"value":"The four base controllers","id":"the-four-base-controllers","depth":3},{"value":"Custom HTTP endpoints","id":"custom-http-endpoints","depth":3},{"value":"Dependency injection and startup","id":"dependency-injection-and-startup","depth":3},{"value":"Node extension points","id":"node-extension-points","depth":2},{"value":"setup() — startup hook and WebSockets","id":"setup--startup-hook-and-websockets","depth":3},{"value":"Multi-file Node projects","id":"multi-file-node-projects","depth":2},{"value":"When something goes wrong","id":"when-something-goes-wrong","depth":2},{"value":"Related","id":"related","depth":2}],"frontmatter":{"seo":{"title":""}},"lastModified":"2026-04-15T14:23:23.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/functions/concepts/handlers","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}