> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with Sprites 2

> Create your first Sprites 2 Sprite, run commands in it, open a shell and put a web app online, using SSH or the HTTP API.

> [!WARNING]
>
> Sprites 2 is in public beta. This page applies only to Sprites 2. For Sprites 1, see the [Quickstart](https://docs.fly.io/sprites/quickstart.md).

This guide walks you through creating a Sprite, running a command in it, opening a shell, serving a web page and cleaning up. Every step shows both ways to control Sprites 2: SSH and the HTTP API.

## Before you begin

You need:

* A Sprites 2 organization, created with **Try the beta**. See [Get access](https://docs.fly.io/sprites/sprites-2/overview.md#get-access).
* An SSH client, for the SSH examples.
* A token for your Sprites 2 organization, for the HTTP API examples. Create one in the Fly.io dashboard at `fly.io/dashboard/ORG/sprites`.

The examples use `my-org` as the organization slug. Replace it with your Sprites 2 organization's slug.

## Two ways to control Sprites

**SSH.** Send commands to your organization's control plane at `my-org@sprites.dev`. There's nothing to install:

```bash theme={null}
ssh my-org@sprites.dev sprite list
```

The first time you connect with a new SSH key, the command prints a code and a URL. Open the URL in your browser, log in if asked, and enter the code. After that, the key works for that organization without asking again.

There are two SSH addresses:

| Address | Connects to |
| - | - |
| `my-org@sprites.dev` | The control plane, for commands that manage Sprites |
| `NAME--CLUSTER--my-org@sprites.dev` | The inside of one Sprite, for a shell, SCP, SFTP or Git |

**HTTP API.** For apps and scripts, use the JSON API. Set these variables once, and the examples on this page use them:

```bash theme={null}
export SPRITES_TOKEN=...   # your organization token
API=https://api.sprites.dev/v1
AUTH="Authorization: Bearer $SPRITES_TOKEN"
BETA="Sprites-Api-Beta: 2026-12-01"
JSON="Content-Type: application/json"
```

The full API is described in OpenAPI at `https://api.sprites.dev/openapi.json?version=beta-2026-12-01`.

> [!WARNING]
>
> Without `?version=beta-2026-12-01`, `https://api.sprites.dev/openapi.json` describes the Sprites 1 API.

## Create and use a Sprite

**1. Create a Sprite**

```bash SSH theme={null}
ssh my-org@sprites.dev sprite create dev
```

```bash HTTP API theme={null}
curl -sS -X POST "$API/sprites" -H "$AUTH" -H "$BETA" -H "$JSON" \
  -d '{"name":"dev"}'
```

The command returns once the Sprite is running. It starts from the Sprites base image: Ubuntu with a `sprite` user, `sudo` and common tools.

**2. Run a command**

```bash SSH theme={null}
ssh my-org@sprites.dev sprite exec dev 'uname -a && pwd'
```

```bash HTTP API theme={null}
curl -sS -X POST "$API/sprites/dev/exec" -H "$AUTH" -H "$BETA" -H "$JSON" \
  -d '{"argv":["/bin/sh","-lc","uname -a && pwd"]}'
```

**3. Open a shell**

Connect straight to the Sprite. `default` is the name of the cluster the Sprite was created in.

```bash theme={null}
ssh dev--default--my-org@sprites.dev
```

SCP and SFTP work at the same address:

```bash theme={null}
scp ./app.tar dev--default--my-org@sprites.dev:/tmp/app.tar
```

**4. Put a web page online**

In the Sprite's shell, register a service on port 8080. A service named `http` is the Sprite's main web server:

```bash theme={null}
sprite-env service register http --port 8080 --protocol http -- python3 -m http.server 8080
```

The Sprite's URL is `https://dev-ORGCODE.sprites.app/`. Run `sprite get dev` to see the exact URL. The `http` service also answers at its own service URL, `https://http--dev--default--my-org.sprites.app/`. The URL is private, so only your organization can open it: a browser signed in to Fly.io, or a request with your token.

To make it public:

```bash theme={null}
ssh my-org@sprites.dev sprite update dev --public
```

This opens both URLs.

Every other service you register gets its own URL in the form `https://SERVICE--SPRITE--CLUSTER--ORG.sprites.app/`, and you make each one public separately.

**5. Check its status**

```bash SSH theme={null}
ssh my-org@sprites.dev sprite get dev
```

```bash HTTP API theme={null}
curl -sS "$API/sprites/dev" -H "$AUTH" -H "$BETA"
```

The response shows the Sprite's status, URL and configuration. When nothing has used it for a while, the Sprite goes to sleep, and the next request or command wakes it.

| State | SSH | HTTP API |
| - | - | - |
| Running | `running` | `running` |
| Stopped, quick to wake | `warm_stopped` | `warm` |
| Stopped, disk only | `stopped` | `cold` |

**6. Delete it**

```bash SSH theme={null}
ssh my-org@sprites.dev sprite delete dev
```

```bash HTTP API theme={null}
curl -sS -X DELETE "$API/sprites/dev" -H "$AUTH" -H "$BETA"
```

> [!WARNING]
>
> Deleting a Sprite is permanent. Take a checkpoint before anything risky.

## Check responses for errors

Commands that change a Sprite, such as create, start, stop, exec, checkpoint and fork, stream their results as one JSON object per line. They return HTTP 200 even when they fail, so an error can arrive inside the stream:

```json theme={null}
{"type":"error","error":{"code":"exec_timeout","message":"Command timed out.","request_id":"GN4c..."}}
```

Read to the last line and check for `"type":"error"`. When an error includes a `request_id`, include it when you report a problem.

Errors that happen before the stream starts use normal HTTP status codes, such as `401` for a bad or expired token, `404` for an unknown Sprite and `429` when you're rate limited.

> [!TIP]
>
> When you pipe SSH control plane output into `jq`, use `ssh -T`. Forcing a terminal with `ssh -t` can garble the output.

## Next steps

* Read the [Sprites 2 overview](https://docs.fly.io/sprites/sprites-2/overview.md) for limits and what's not in the beta yet.
* Try the [Sprites 2 feature guides](https://sprites2-docs.fly.dev/) for forking, private networking, egress policies, scoped tokens and more.
* Run `ssh docs@sprites.dev` for the complete Sprites 2 reference. You don't need an account.
