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

# holydocs api

Make authenticated requests to the HolyDocs management API from the command line.

## Usage

```bash
holydocs api <get|post|put|patch|delete> <path> [options]
```

`holydocs api` is the scripting escape hatch for HolyDocs. It reuses your saved CLI authentication and sends requests to the HolyDocs API with `Authorization: Bearer ...` and your saved `X-Organization-Id` when available.

Paths are resolved relative to `https://api.holydocs.com/api/v1` by default, so:

```bash
holydocs api get /projects
```

maps to:

```bash
GET https://api.holydocs.com/api/v1/projects
```

If you pass a path that already starts with `/api/`, the CLI uses it as-is.

## Options

| Option | Description | Default |
|---|---|---|
| `--json <json>` | Inline JSON request body, or `@path/to/body.json` | None |
| `-H, --header <header...>` | Extra headers in `KEY:VALUE` format | None |
| `--raw` | Print the raw response body instead of pretty JSON | Pretty JSON when response is JSON |

## Examples

### List Projects

```bash
holydocs api get /projects
```

### Set a Custom Domain

```bash
holydocs api put /domains/proj_abc123 \
  --json '{"customDomain":"docs.example.com"}'
```

### Verify a Custom Domain

```bash
holydocs api post /domains/proj_abc123/verify
```

### Remove a Custom Domain

```bash
holydocs api delete /domains/proj_abc123
```

### Send a Body from a File

```bash
holydocs api patch /projects/proj_abc123 \
  --json @./project-update.json
```

### Add Extra Headers

```bash
holydocs api get /projects \
  -H "X-Debug-Trace:true"
```

## Authentication

`holydocs api` requires the same authentication as other API-backed CLI commands:

1. Run [`holydocs login`](/cli/login) once
2. Or set `HOLYDOCS_API_KEY`

```bash
HOLYDOCS_API_KEY=hd_a1b2c3d4e5f67890a1b2c3d4e5f67890 \
holydocs api get /projects
```

If you authenticated with `holydocs login`, the command automatically reuses your saved `apiUrl`, `apiKey`, and `orgId`.

## Output

- JSON responses are pretty-printed by default
- Non-JSON responses are printed as plain text
- Use `--raw` to print the raw body without formatting

## Related

- [API Authentication](/api/authentication)
- [Domains API](/api/domains)
- [holydocs login](/cli/login)