Sprite Internal Network
Let Sprites talk to each other only through explicit, per-service grants, waking the destination when needed.
On this page
What it is
By default, Sprites cannot reach each other. To let one Sprite use a service on another, you create a service grant: a permission that says “these source Sprites may use this named service on these target Sprites.”
- A grant is for one service, not a whole machine. Granting access to a database doesn’t open the web server.
- The platform checks the caller, the destination, the service name, and the grant on every connection.
- No guest IP addresses are exposed; you reach services by name.
- An incoming connection can wake the destination Sprite, so a database Sprite can sleep between uses.
Why it matters: you control exactly which services may talk. For example, an app Sprite can reach Postgres on another Sprite that idles when nobody is using it.
Key ideas
Services. A grant targets a named service registered on the target Sprite, either HTTP or TCP.
Scope. A grant is either:
| Scope | Matches |
|---|---|
cluster | Sprites in one cluster. Can name Sprites directly. |
org | Sprites across your whole organization, matched by label. |
Matching. Prefer exact Sprite names. Use labels when a changing pool of Sprites needs the same access (e.g. every Sprite labeled api).
Addresses. Inside a Sprite, granted services have DNS names:
| Kind | Address |
|---|---|
| HTTP, same cluster | http://SERVICE--SPRITE.sprite.internal/ |
| TCP, same cluster | SERVICE--SPRITE.sprite.internal:PORT |
| HTTP, another cluster | http://SERVICE--SPRITE--CLUSTER.sprite.internal/ |
| TCP, another cluster | SERVICE--SPRITE--CLUSTER.sprite.internal:PORT |
The short form resolves within the caller’s own cluster. To reach a Sprite in a different cluster (with an org-scoped grant), include the cluster name.
Step by step: an app Sprite using Postgres on another Sprite
We’ll set up a cluster called review-123 with two Sprites:
storageruns PostgreSQL as a TCP service nameddb.appis our application, labeledapi, which needs the database.
1. Create the two Sprites
ssh my-org@sprites.dev sprite create review-123/storage
ssh my-org@sprites.dev sprite create review-123/app --label api
# HTTP API
curl -sS -X POST "https://api.sprites.dev/v1/sprites" \
-H "Authorization: Bearer $SPRITES_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"storage","cluster_id":"review-123"}'
curl -sS -X POST "https://api.sprites.dev/v1/sprites" \
-H "Authorization: Bearer $SPRITES_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"app","cluster_id":"review-123","labels":["api"]}'
2. Register Postgres as a TCP service on storage
Install PostgreSQL in storage, then, inside storage, register it:
sprite-env service register db \
--port 5432 \
--protocol tcp \
--description 'PostgreSQL for the app' \
--restart always \
-- sudo -u postgres /usr/lib/postgresql/18/bin/postgres \
-D /var/lib/postgresql/18/main \
-c config_file=/etc/postgresql/18/main/postgresql.conf
--protocol tcp matters: TCP services carry raw byte streams for databases, caches and queues, with full duplex, half-close and backpressure. Bulk transfers and COPY behave like they would on a local network.
3. Grant app access to db
From your machine:
ssh my-org@sprites.dev "service-grant create api-to-db \
--scope cluster \
--cluster review-123 \
--source-label api \
--target storage/db \
--description 'API Sprites use the storage PostgreSQL database'"
# HTTP API
curl -sS -X POST "https://api.sprites.dev/v1/clusters/review-123/service-grants" \
-H "Authorization: Bearer $SPRITES_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id":"api-to-db","source":{"labels_all":["api"]},"target_ref":"storage/db",
"description":"API Sprites use the storage PostgreSQL database"}'
This lets any Sprite labeled api in review-123 reach the db service on storage. To allow only the one Sprite, use --source app (HTTP "source_ref":"app") instead of --source-label api.
4. Connect from app
Inside app, use the service’s internal name and its declared port:
psql "host=db--storage.sprite.internal port=5432 user=app dbname=app"
Or in your app’s configuration:
export DATABASE_URL=postgres://app:secret@db--storage.sprite.internal:5432/app
If storage is asleep, the connection wakes it. Once the connection closes and storage goes idle, it sleeps again.
When storage wakes from cold, the database needs a moment to start, and the very first connection can fail with FATAL: the database system is starting up. Configure your client or connection pool to retry. Wakes from warm, and HTTP services, don’t have this problem.
5. Confirm what app can see
ssh my-org@sprites.dev sprite discover review-123/app
Or inside the Sprite:
sprite-env discover
discover is the source of truth for what a Sprite may reach. Don’t guess routes.
HTTP services work the same way
Allow planner to call the files HTTP service on storage, naming both Sprites exactly:
ssh my-org@sprites.dev "service-grant create planner-files \
--scope cluster \
--cluster review-123 \
--source planner \
--target storage/files \
--description 'Planner reads and writes build artifacts'"
Then, inside planner:
curl http://files--storage.sprite.internal/artifacts
Organization-wide grants
An org-scoped grant uses labels on both sides and works across clusters. Let every Sprite labeled worker call the api service on every Sprite labeled backend:
ssh my-org@sprites.dev "service-grant create workers-to-api \
--scope org \
--service api \
--source-label worker \
--target-label backend \
--description 'Workers may call the backend API service'"
# HTTP API
curl -sS -X POST "https://api.sprites.dev/v1/service-grants" \
-H "Authorization: Bearer $SPRITES_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id":"workers-to-api","service_name":"api","source":{"labels_all":["worker"]},
"target":{"labels_all":["backend"]},
"description":"Workers may call the backend API service"}'
labels_all matches Sprites that carry every listed label. From another cluster, address the service with its cluster, e.g. http://api--backend-1--prod.sprite.internal/.
To manage labels:
ssh my-org@sprites.dev sprite label add worker job-1 job-2
ssh my-org@sprites.dev sprite update api --add-label backend
Managing grants
ssh my-org@sprites.dev service-grant list --scope cluster --cluster review-123
ssh my-org@sprites.dev service-grant get db api-to-db --scope cluster --cluster review-123
ssh my-org@sprites.dev service-grant delete db api-to-db --scope cluster --cluster review-123
# HTTP API
curl -sS "https://api.sprites.dev/v1/clusters/review-123/service-grants" \
-H "Authorization: Bearer $SPRITES_TOKEN"
curl -sS "https://api.sprites.dev/v1/clusters/review-123/service-grants/db/api-to-db" \
-H "Authorization: Bearer $SPRITES_TOKEN"
curl -sS -X DELETE "https://api.sprites.dev/v1/clusters/review-123/service-grants/db/api-to-db" \
-H "Authorization: Bearer $SPRITES_TOKEN"
curl -sS "https://api.sprites.dev/v1/sprites/review-123/storage/service-grants" \
-H "Authorization: Bearer $SPRITES_TOKEN" # grants naming a Sprite
Note that get, update and delete take the service name and grant ID together.
Granting platform capabilities
Besides your own services, a grant can authorize built-in capabilities:
sprite.mailbox: deliver to another Sprite’s mailbox (see Mailbox Automations).- Lifecycle capabilities:
sprite.sprite.exec,.start,.stop,.create,.checkpoint,.restore,.fork,.destroy.
Grant these only when the source genuinely needs that operation.
Good to know
- Cluster forks copy the cluster’s service grants to the new cluster (see Forking).
- Grants belong to the Sprite, not its filesystem, so they’re never part of a checkpoint.
- If a service is still starting when a connection arrives, the connection waits for it to listen, for up to 60 seconds. A TCP connection is closed if it never comes up.