What you will learn
- Tell the public API from the internal server by prefix, port and credential
- Say who uses each door and what the internal server offers a gateway
- Explain how an api-key identifies a gateway and the organisation it belongs to
- Say who opens the connection between a gateway and AMS, and how news travels down it
Before you start
- AMS at a glance Not started In progress Done
- JWT, JWKS, issuer, audience and scope Not started In progress Done
On this page
AMS has one front desk and one staff entrance. People and tools go to the front desk and show a signed token. Gateways use the staff entrance and show a key. They are two servers in one process, and they trust different things. Knowing which is which makes many errors easy to read.
The front door: the public API
The public API serves the prefix /api/v1. By default its container port is 8080, and the on-prem chart’s Service passes it on from port 9000. It has 243 routes, and all of them are mounted behind the token check. A request goes through a chain of steps: recover from panics, CORS, a correlation id, a request log, then the JWT check. After that each route runs its own checks for the audit trail, the organisation, the scope and the path parameters.
Six routes are registered on the server’s root mux and need no token: a health check, the service’s configuration (its path is /api/v1/config), the public keys that verify agent tokens, two discovery documents, and a small check that the reverse proxy asks before it issues a certificate for an environment’s identity server. The MCP endpoint for AI assistants also sits on the root, with the same token check.
The caller is a person or a tool. It sends a JWT (JSON Web Token)A signed token whose contents, called claims, say who you are and which organisation you belong to. Anyone with the public key can check the signature.See it in the glossary in the Authorization header.
The staff entrance: the internal server
The Internal serverThe second server inside AMS, by default on port 9243 with HTTPS. Gateways use it with an api-key header. It has no JWT check.Analogy:The staff entrance, next to the front desk.See it in the glossary is a second server in the same process. It serves the prefix /api/internal/v1, by default on port 9243, and its chart Service is amp-api-gateway-manager. Under that prefix it has 12 routes: 11 REST routes and one WebSocket. It exists for gateways.
What does a gateway ask for here?
| Route | What it is for |
|---|---|
| LLM provider, LLM proxy, MCP proxy and agent by id | The full definition of something that was deployed to this gateway. |
| Key lists for providers, proxies and agents | The hashes of the API keys that the gateway should accept. |
| Deployments | A list that the gateway reconciles against on connect. In this version AMS always answers with an empty list. |
| Applications and subscription plans | Further data that the gateway syncs from AMS. Applications come with their key bindings, and the subscription plans list is empty today. |
| A manifest, sent to AMS | The list of policies this gateway has installed. |
The WebSocket at /api/internal/v1/ws/gateways/connect | The live line that carries news. |
This server has no JWT check in its handler chain. It serves HTTPS with a certificate that it loads from its certificate directory or, if there is none, generates itself (self-signed). It asks for no certificate from the caller. If TLS is switched off in the chart, it serves plain HTTP.
How a gateway proves itself
Each of the 11 REST handlers on this server, and the WebSocket upgrade, reads the api-key header and checks it. A missing key gets a 401, and so does a key that does not check out. When the key is good, AMS learns two things from the gateway it finds: which gateway is calling, and which organisation it belongs to. Handlers then read only that organisation’s data.
On-prem, the key is the registration token that an install job asked AMS to mint. AMS stores a salted hash of it, not the token. On Choreo Cloud, Choreo Labs’ own services register the gateway instead (the provisioner, or platform-api’s bootstrap), and the gateway still reaches AMS with a registration token.
Who opens the line
The gateway-controller opens the WebSocket. AMS does not dial out to the gateway. It dials AMS over TLS and shows the registration token in the api-key header. It shows no certificate of its own, so this is not mutual TLS. If the line drops, it reconnects, waiting longer each time, from 1 second up to 5 minutes.
The line opens
AMS checks the key and accepts the socket. It pings the connection every 20 seconds, and by default it gives up on a connection that does not answer within 30.
Something changes
When, for example, an MCP proxy is deployed, AMS writes an event into EventHub, its event log in Postgres.
News goes down the line
A polling loop checks the log every 2 seconds and passes new events to the gateway’s open connection. For a deployment, the message names what changed and does not carry the full definition.
The gateway fetches the details
The gateway calls the internal REST routes with its key and asks for the definition. A small message first and the details on request keeps the line light.
Your turn
Under Try it, play flow F11 and stop at the step where the gateway-controller connects. Which side opens the connection? Then open the credentials map and click the row for the gateway registration token: who holds it and who checks it? Finish with the matcher that pairs each address and credential with its door.
Recap
- The public API is at
/api/v1, by default on 8080 (service port 9000 in the chart). People and tools use it with a JWT. - The internal server is at
/api/internal/v1, by default on 9243 over HTTPS. Gateways use it with an api-key header. It has no JWT check. - The api-key identifies one gateway and its organisation, so a gateway reads only its own organisation’s data.
- The gateway-controller opens the WebSocket. News travels down it as small messages, and the details come over REST.
Wrap up
Recap
Tick each one when you could explain it to a colleague.
Finished?
Chapter complete. Every lesson in this chapter is done.
Progress cannot be saved in this browser, so it will be forgotten when you leave this page.
Quick check
Spotted something wrong or unclear in this lesson? Report an inaccuracy (opens GitHub in a new tab)