> ## Documentation Index
> Fetch the complete documentation index at: https://libops-renovate-github-com-libops-sitectl-0-x.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# API

> Log in to ArchivesSpace and call arbitrary REST API paths through sitectl.

Log in and use the returned session token for authenticated API calls:

```bash theme={null}
ARCHIVESSPACE_PASSWORD=admin \
  sitectl archivesspace api login

sitectl archivesspace api request GET repositories/2/resources --session "$ARCHIVESSPACE_SESSION"
```

API helpers accept:

* `--url` for the base API URL, defaulting to `http://localhost/api`
* `--session` for the `X-ArchivesSpace-Session` header
* `--query name=value` for repeated query parameters
* `--data` or `--file` for JSON request bodies on arbitrary requests

Use `api request` when you need a path that does not have a named shortcut:

```bash theme={null}
sitectl archivesspace api request GET repositories/2/archival_objects --query page=1 --session "$ARCHIVESSPACE_SESSION"
sitectl archivesspace api request POST repositories/2/resources --file resource.json --session "$ARCHIVESSPACE_SESSION"
```

## Reference

### `api login`

Log in to ArchivesSpace and print the session response

```bash theme={null}
sitectl archivesspace api login
```

| Flag         | Default                | Description                                                  |
| ------------ | ---------------------- | ------------------------------------------------------------ |
| `--password` |                        | ArchivesSpace password. Defaults to ARCHIVESSPACE\_PASSWORD. |
| `--url`      | `http://localhost/api` | Base ArchivesSpace API URL.                                  |
| `--username` | `admin`                | ArchivesSpace username.                                      |

### `api request`

Call an arbitrary ArchivesSpace API path

```bash theme={null}
sitectl archivesspace api request METHOD PATH
```

| Flag          | Default                | Description                                                |
| ------------- | ---------------------- | ---------------------------------------------------------- |
| `--data`      |                        | JSON request body.                                         |
| `--file`      |                        | Path to a JSON request body file.                          |
| `-q, --query` | `[]`                   | Additional query parameter as name=value. May be repeated. |
| `--session`   |                        | ArchivesSpace session token for X-ArchivesSpace-Session.   |
| `--url`       | `http://localhost/api` | Base ArchivesSpace API URL.                                |
