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

# api

> Call the Diversion API using your CLI sign-in.

Use `dv api` to send an authenticated request from your terminal. The command uses your existing CLI sign-in and account permissions. If you need to sign in, run [`dv login`](https://docs.diversion.dev/cmd-ref/login).

## Make a request

Run `dv help api` to check that your CLI includes the command. Then list the repositories you can access.

```bash theme={null}
dv api /repos
```

Use an endpoint path such as `/repos`. The CLI adds the API base URL, including `/v0`. Quote the path when it has query parameters. [List user's repositories](https://docs.diversion.dev/api-reference/repository-management/list-users-repositories.md).

```bash theme={null}
dv api '/repos?owned=true'
```

To inspect one repository, replace `REPO_ID` with a `repo_id` from the list. [Get repository details](https://docs.diversion.dev/api-reference/repository-manipulation/get-repository-details.md).

```bash theme={null}
dv api /repos/REPO_ID
```

## Choose a method and send JSON

```bash theme={null}
dv api <path> [-X <method>] [-d '<json>']
```

`GET` is the default method. Use `-X` to set a different method and `-d` to pass a JSON request body. Find the method and body fields for your endpoint in the [API reference](https://docs.diversion.dev/api-reference/introduction.md).

## Use the response in a script

The command writes the response body to standard output. For HTTP errors, it still writes the body, prints the status to standard error, and exits with a nonzero code.

In Bash, enable `pipefail` so a failed request makes the pipeline fail even if `jq` succeeds. This example prints one repository name per line.

```bash theme={null}
set -o pipefail
dv api /repos | jq -r '.items[].repo_name'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.