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

# cast deploy

> Deploy an agent to Castari

# cast deploy

Deploy an agent to Castari.

## Usage

```bash theme={null}
cast deploy [slug]
```

## Arguments

| Argument | Description | Required                                              |
| -------- | ----------- | ----------------------------------------------------- |
| `slug`   | Agent slug  | No (read from `castari.json` if in project directory) |

## Examples

### Deploy from a Castari project directory

If you're inside a directory with a `castari.json` file, just run:

```bash theme={null}
cast deploy
```

The CLI reads the `slug` field from `castari.json`. If no `slug` field is present, it derives the slug from the `name` field.

### Deploy a specific agent

```bash theme={null}
cast deploy my-agent
```

Deploys the agent with slug `my-agent`, pulling code from its configured git repository.

## What Happens During Deploy

<Steps>
  <Step title="Fetch Code">
    Code is pulled from the agent's configured git repository.
  </Step>

  <Step title="Create Sandbox">
    An isolated E2B sandbox is created for your agent.
  </Step>

  <Step title="Install Dependencies">
    `npm install` runs inside the sandbox.
  </Step>

  <Step title="Inject Secrets">
    Any secrets you've set become environment variables.
  </Step>

  <Step title="Ready">
    Agent status becomes `active`. Ready to invoke.
  </Step>
</Steps>

## Agent Configuration

Your agent needs a `castari.json` file:

```json theme={null}
{
  "name": "my-agent",
  "slug": "my-agent",
  "version": "0.1.0",
  "entrypoint": "src/index.ts",
  "runtime": "node"
}
```

## Redeploying

Running `cast deploy` on an already-deployed agent will redeploy it:

1. Previous sandbox is destroyed
2. New sandbox is created
3. Latest code is deployed

<Warning>
  Redeploying does not preserve sandbox state. All files and data in the sandbox are lost.
</Warning>

## Errors

| Error                     | Cause                      | Fix                                                   |
| ------------------------- | -------------------------- | ----------------------------------------------------- |
| `Agent not found`         | Invalid slug               | Check `cast agents list` for correct slug             |
| `castari.json not found`  | Not in a project directory | Specify the slug explicitly or `cd` to your project   |
| `npm install failed`      | Dependency error           | Check `package.json`, run `npm install` locally first |
| `Authentication required` | Not logged in              | Run `cast login`                                      |

## See Also

* [cast init](/cli/init) — Create a new agent from a template
* [cast invoke](/cli/invoke) — Invoke a deployed agent
* [Your First Agent](/first-agent) — Understand agent structure
