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

# Any REST endpoint

> Call any Plivo REST endpoint the CLI does not wrap yet.

Call a Plivo REST endpoint using the profile saved by [browser login](https://plivo.com/docs/cli/install.md#log-in-with-a-browser). Environment credentials are not read. Start with a read of your account's numbers:

```bash theme={null}
plivo api GET /Number/ --query limit=5
```

## plivo api

Paths such as `/Number/` are relative to `/v1/Account/<auth_id>/`. Full paths beginning with `/v1/Account/` are used as given. Keep the trailing slash.

`GET` and `HEAD` do not need `--yes`. Writes with `POST`, `PUT`, `PATCH` or `DELETE` require it; `--dry-run` previews the request. For example, create `msg.json` with your sender and recipient:

```json msg.json theme={null}
{"src":"14155550100","dst":"14155550101","text":"Hello from Plivo"}
```

```bash theme={null}
plivo api POST /Message/ --body @msg.json --dry-run
# Sends a billed message:
plivo api POST /Message/ --body @msg.json --yes
```

`--body @-` reads JSON from standard input. With `--method`, omit the positional method:

```bash theme={null}
cat msg.json | plivo api --method POST /Message/ --body @- --dry-run
```

Here `--query` adds a URL parameter, not a JSON filter. Repeat it for multiple parameters.

* **Errors.** An HTTP error gets the same code and exit code as on any other command: a 404 is `RESOURCE_NOT_FOUND` (exit `1`), a 401 exits `2` and a 429 exits `4`. The HTTP status stays in `status_code`, and the API's own body in `context.upstream`. See [Exit codes](https://plivo.com/docs/cli/configure.md#exit-codes).
* **Redirects.** A redirect is not followed. A 3xx exits `3` and names where it pointed, which is usually a missing trailing slash on the path.
* **Secrets.** Auth tokens and passwords in the response read `[REDACTED]` unless you add `--show-secrets`.
* **Paths.** A path with a control character in it is refused before any request.

| Command | What it does |
| - | - |
| `plivo api` | Call a REST path without a dedicated CLI command |

> [accordion] plivo api
>
> **Usage**
>
> ```text theme={null}
> plivo api <method> <path> [flags]
> ```
>
> **Flags**
>
> | Flag | Description |
> | - | - |
> | `--body <string>` | request body: literal JSON, @path/to/file, or @- for stdin |
> | `--explain` | narrate in plain English before executing |
> | `--header <stringArray>` | extra header as 'Key: Value' (repeatable; overrides defaults) |
> | `--method <string>` | HTTP method (alternative to the positional arg; useful when piping) |
> | `--query <stringArray>` | URL query param as key=value (repeatable; not a JMESPath filter here) |
