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

# Sub-Accounts

> Isolated sub-accounts with their own API keys and spend limits. Not yet generated in the Python SDK: use the REST API or the CLI.

<Warning>
  **Not generated in the Python SDK yet.** The `zavudev` package does not expose a `sub-accounts`
  resource today, so there is nothing to call. The endpoints exist and are stable:
  use the REST API below, the [CLI](/guides/cli/overview), or the
  [TypeScript SDK](/sdks/typescript/sub-accounts), which does cover it. See the
  [coverage table](/sdks/overview#coverage).
</Warning>

Sub-accounts are isolated projects under your team, each with its own API keys
and spending cap. Every charge still bills to the parent team's balance.

<Note>
  These endpoints require a **parent project** API key. A sub-account key calling
  them receives `403`.
</Note>

## Create a sub-account

```bash theme={null}
curl -X POST https://api.zavu.dev/v1/sub-accounts \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Client ABC",
    "externalId": "client_123",
    "creditLimit": 100000
  }'
```

`creditLimit` is in cents. The response includes `apiKey`, and that is the only
time it is returned.

```bash CLI theme={null}
npx zavudev sub-accounts create --data '{"name":"Client ABC"}'
```

## Retrieve, list and update

```bash theme={null}
curl https://api.zavu.dev/v1/sub-accounts/jx7abc123 \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"

curl "https://api.zavu.dev/v1/sub-accounts?limit=50" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"

curl -X PATCH https://api.zavu.dev/v1/sub-accounts/jx7abc123 \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "creditLimit": 250000 }'
```

## Spending

```bash theme={null}
curl https://api.zavu.dev/v1/sub-accounts/jx7abc123/balance \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

Returns the parent team's `balance` alongside this sub-account's `totalSpent`
and `creditLimit`, all in cents.

## API keys

```bash theme={null}
# List
curl https://api.zavu.dev/v1/sub-accounts/jx7abc123/api-keys \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"

# Create (the full key is returned once)
curl -X POST https://api.zavu.dev/v1/sub-accounts/jx7abc123/api-keys \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Production Key", "environment": "live" }'

# Revoke
curl -X DELETE https://api.zavu.dev/v1/sub-accounts/jx7abc123/api-keys/key_id \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

## Deactivate

```bash theme={null}
curl -X DELETE https://api.zavu.dev/v1/sub-accounts/jx7abc123 \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

Remaining balance returns to the parent team and every API key is revoked.

<CardGroup cols={2}>
  <Card title="Sub-accounts guide" icon="sitemap" href="/guides/sub-accounts/overview">
    When to use them, and how billing works
  </Card>

  <Card title="API reference" icon="code" href="/api-reference/create-sub-account">
    Every field on the endpoints
  </Card>
</CardGroup>
