extended property, then read it back from the SDK or a processor.
Every resource the API Server manages (Agents, Domains, Peers, Trunks, Numbers, Credentials, and ACLs) has an optional extended field. It holds any JSON object. Routr stores it as-is and returns it with the resource.
When to use it
- Link a resource to a record in your own system, for example a CRM user ID on an Agent.
- Give a processor or middleware the data it needs to change signaling, for example a preferred codec or a tenant ID.
Prerequisites
- An API Server backed by PostgreSQL (
pgdata). This is the backend infonoster/routr-oneand the Helm chart. - The SDK:
npm install --save @routr/sdk.
Write custom data
1
Create a resource with extended data
This script creates an Agent with an external ID in Replace the
extended. It connects to the API Server on localhost:51908 without TLS:index.js
domainRef and credentialsRef values with refs from your server (rctl domains get, rctl credentials get). If your API Server uses TLS, drop insecure and pass cacert instead.2
Update it later
Pass
extended to the matching update* method. The object you send replaces the stored one, so include every key you want to keep:Read custom data
The SDK decodesextended back into a plain object. This call prints the external ID of an Agent:
rctl <resource> describe <ref> prints the field under Extended. The -x, --extended flag on get commands is unrelated: it only adds table columns. See rctl.
Use custom data in signaling
A processor reads resources from the API Server over gRPC, so it seesextended like any other field. The Connect processor already uses it in two places:
- Request metadata. When Connect routes a call, it copies the
extendedobject of the relevant resource (the caller for calls that start at an Agent, the Number forfrom-pstn) into the outgoingMessageRequest.metadata. Post-processor middlewares can read it there. - Access keys on Numbers. For
peer-to-pstn, if a Number hasextended.accessKeyId, Connect only lets requests use that Number when they carry a matchingX-Access-Key-Idheader. Otherwise it answers403 Forbidden.
Pitfalls
- Keep it small and flat.
extendedtravels as a protobufStruct. Store IDs and flags, not large documents. - Don’t put secrets in it. Anyone with API access can read
extended. - Metadata is string-keyed.
MessageRequest.metadatais amap<string, string>, so prefer string values for data that signaling needs.
Related
Manage resources with the SDK
Create and manage every resource type from code.
API Server
Backends, ports, and configuration.
SDK reference
Every SDK class and method.
Build a processor
Use your data to make routing decisions.