✦ Sprites 2 Docs

Getting Started

Set up access, learn the two ways to control Sprites, and create your first Sprite.

On this page

This page covers what you need before any of the feature guides: how to reach Sprites, how commands and responses look, and how to create and use your first Sprite.

What is a Sprite?

A Sprite is a Linux machine that you own for as long as you like. Here’s how it differs from a normal VM:

  • It sleeps on its own. When nothing has used it for a while (30 seconds by default), it stops running. You’re not paying for idle CPU.
  • It wakes on demand. An HTTP request, a command, or a scheduled job wakes it again, usually in about a second.
  • Its disk is persistent. Files you write are still there after it sleeps, restarts, or moves to another host.
  • You can snapshot and copy it. Checkpoints save its state, and forks create independent copies from a checkpoint.

Conventions used in these docs

Every example uses the organization slug my-org. Replace it with your own organization’s slug everywhere you see it.

Sprites live in clusters. Unless you say otherwise, a Sprite is created in the cluster named default. You refer to a Sprite in the default cluster by its name (dev) and to one in any other cluster as CLUSTER/NAME (review-123/planner).

Two ways to control Sprites

You can do almost everything two ways. Pick whichever suits you; most guides show both.

Option 1: The SSH control plane

Send commands over SSH to your organization’s address. Nothing to install:

ssh my-org@sprites.dev sprite list

There are two SSH addresses, and it’s worth learning the difference now:

AddressWhat it connects to
my-org@sprites.devThe control plane: commands that manage Sprites (sprite create, checkpoint, automation…)
NAME--CLUSTER--my-org@sprites.devThe inside of one Sprite: a shell, SCP, SFTP, Git (see Native SSH Access)

To see built-in help:

ssh my-org@sprites.dev help                 # every command
ssh my-org@sprites.dev help sprite create   # one command
ssh my-org@sprites.dev docs                 # the full reference

Option 2: The HTTP API

For applications and scripts, use the JSON API at https://api.sprites.dev/v1.

  1. Create a full-access organization token in the Fly.io dashboard at fly.io/dashboard/ORG/sprites.

  2. Put the token in an environment variable:

    export SPRITES_TOKEN=...   # your token
    

    Every HTTP example in these docs sends two headers:

    HeaderValueWhen
    AuthorizationBearer $SPRITES_TOKENEvery request
    Content-Typeapplication/jsonRequests with a JSON body (-d '{...}')
  3. Test it by listing your Sprites:

    curl -sS "https://api.sprites.dev/v1/sprites" -H "Authorization: Bearer $SPRITES_TOKEN"
    

The full API is also described as OpenAPI at https://api.sprites.dev/v1/openapi.json, which you can feed to client generators.

Watch out

These docs are for Sprites 2, which uses the /v1 API. The older OpenAPI document at https://api.sprites.dev/openapi.json describes Sprites 1.0 and lists endpoints that don’t exist in Sprites 2 (such as fs/read, fs/list, /suspend and /resume). Use /v1/openapi.json.

Tip

A full-access token can mint narrower tokens for each agent or customer. See Per-Agent Tokens for short-lived child tokens limited to particular Sprites and actions, and Restricted tokens below for long-lived ones.

Create your first Sprite

Step 1: create it.

ssh my-org@sprites.dev sprite create dev
# HTTP API
curl -sS -X POST "https://api.sprites.dev/v1/sprites" \
  -H "Authorization: Bearer $SPRITES_TOKEN" \
  -H "Content-Type: application/json" -d '{"name":"dev"}'

The call returns once the Sprite is running. By default it uses the Sprites base image: Ubuntu with a sprite user, sudo, and common tools.

Step 2: run a command in it.

ssh my-org@sprites.dev sprite exec dev 'uname -a && pwd'
# HTTP API
curl -sS -X POST "https://api.sprites.dev/v1/sprites/dev/exec" \
  -H "Authorization: Bearer $SPRITES_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"argv":["/bin/sh","-lc","uname -a && pwd"]}'

Step 3: open a shell in it.

ssh dev--default--my-org@sprites.dev

Step 4: look at it.

ssh my-org@sprites.dev sprite get dev

You’ll see its status, its url, and its configuration. The status names differ slightly between SSH and the HTTP API:

StateSSH (sprite get, sprite list)HTTP (GET /sprites/NAME)
Runningrunningrunning
Warm (stopped, quick to wake)warm_stoppedwarm
Cold (stopped, disk only)stoppedcold

A Sprite that has never been started shows as cold. You may also see error or deleting.

Step 5: clean up when you’re done.

ssh my-org@sprites.dev sprite delete dev
Watch out

Delete is permanent. Use checkpoints before anything risky.

Reading responses

Responses come in two shapes:

  • Reads (sprite get, sprite list, usage, pricing, and their HTTP equivalents) return a single JSON object, usually wrapped as {"data": ...}.
  • Operations that change a Sprite return NDJSON: one JSON object per line, each with a type.

Help text and usage errors are plain text.

Operations that change a Sprite (start, stop, exec, update, checkpoint, fork…) stream events and return HTTP 200 even when they fail. That means an error can arrive inside the stream:

{"type":"error","error":{"code":"exec_timeout","message":"Command timed out.","request_id":"GN4c..."}}

So always read to the last line and check for "type":"error". This includes invalid updates: PUT /sprites/NAME with a bad setting returns 200 with an invalid_config error in the body.

Errors that happen before the stream starts use normal HTTP status codes, with a body such as {"error":"sprite not found"}:

StatusMeaning
400Invalid request
401Bad or expired token
403Not allowed for this token
404Unknown Sprite
409Conflict: name already exists, or another operation is in progress
413Too large
429Rate limited: retry after a short delay

When an error includes a request_id, quote it when you report a problem.

Tip

When piping control-plane output into jq, use ssh -T. A forced terminal (ssh -t) can garble the output.

Quoting commands over SSH

The control plane receives your command as one line and splits it again. When a value contains spaces or *, wrap the whole remote command in double quotes and the value in single quotes:

ssh my-org@sprites.dev "automation create worker check-site --cron '*/5 * * * *' --wake"

For complex settings, many commands accept --input-json with the same fields as the HTTP API. Keep the JSON in a local variable so its quotes survive:

input='{"start":false,"config":{"max_cpus":2,"auto_idle":false}}'
ssh my-org@sprites.dev "sprite create worker --input-json '$input'"

Restricted tokens

Give each agent, customer, or CI job its own limited token instead of sharing your full-access one. There are two ways:

  • Child tokens expire after a ttl, can be limited to particular Sprites and actions (including exec), and can be revoked one by one. They’re the best fit for agents; see Per-Agent Tokens.
  • Restricted root tokens, below, don’t need a ttl and appear in GET /tokens, but can only create and read Sprites.

A request without ttl that contains only description, policy and privileges creates a restricted root token:

curl -sS -X POST "https://api.sprites.dev/v1/tokens" \
  -H "Authorization: Bearer $SPRITES_TOKEN" \
  -H "Content-Type: application/json" -d '{
    "description": "agent-7",
    "policy": {"name_prefix": "agent-7-", "label": "agent-7",
               "max_sprites_total": 5,
               "expires_at": "2026-12-31T00:00:00Z"}}'

The token in the response is shown once, so save it. The response doesn’t include the token’s id; find that with GET /tokens when you need to revoke it. Every policy field is optional:

  • name_prefix: only Sprites whose names start with this.
  • label: only Sprites with this label (it’s added to Sprites the token creates).
  • max_sprites_total: how many Sprites it may create.
  • expires_at: when it stops working.

A restricted token can create, list and read its Sprites, their logs, and their discovery info. Everything else (start, stop, exec, delete, checkpoints, services, automations…) needs a full-access token and returns 403.

List and revoke tokens:

curl -sS "https://api.sprites.dev/v1/tokens" -H "Authorization: Bearer $SPRITES_TOKEN"
curl -sS -X DELETE "https://api.sprites.dev/v1/tokens/TOKEN_ID" \
  -H "Authorization: Bearer $SPRITES_TOKEN"

Working inside a Sprite

Inside a Sprite, the sprite-env command manages the Sprite itself. Good first commands:

sprite-env help
sprite-env discover        # what this Sprite is allowed to reach
sprite-env service list    # supervised processes
Watch out

Don’t edit files under /.sprite directly; use sprite-env instead.

Next steps

Pick a feature from the features list. If you’re not sure where to start, these three cover the core ideas:

  1. Fast Creation and Wake-Up: how Sprites sleep and wake.
  2. Per-Service URLs: put a web app on the internet.
  3. Forking and Reusable Templates: prepare once, copy many times.