# polymorfa api

> Make an authenticated request through the Polymorfa SDK.

## polymorfa api

Make an authenticated request through the Polymorfa SDK.

### Usage

```bash
polymorfa api ENDPOINT [flags]
```

### Arguments

- `ENDPOINT` (required). Relative API endpoint beginning with a slash.

### Flags

- `-F, --field <value>` (value, repeatable). Add a typed field using name=value: true, false, null and integers become JSON; @file or @- reads a file or stdin. Use name[sub]=v to nest and name[]=v to append.
- `-H, --header <value>` (value, repeatable). Add a request header using name:value.
- `-i, --include` (boolean). Include response metadata in human output, including each page with --paginate --slurp.
- `--input <value>` (value). Read a complete JSON body from a file or standard input (-).
- `-q, --jq <value>` (value). Filter the response with a jq expression (embedded jq 1.8). Strings print without quotes and keep their whitespace.
- `--max-pages <value>` (value). Fail instead of fetching more than this many pages. Defaults to 100.
- `-X, --method <value>` (value). HTTP method. Values: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS`. Default: `GET`.
- `--paginate` (boolean). Fetch every page by following page.nextCursor as the cursor query parameter (GET only).
- `-f, --raw-field <value>` (value, repeatable). Add a string field using name=value.
- `--slurp` (boolean). With --paginate, collect pages into one array before filtering or printing.
- `--surface <value>` (value, required). API credential surface. Values: `messaging`, `platform`.
- `-t, --template <value>` (value). Format the response with a Go-style template, such as {{range .data}}{{.id}}{{"\n"}}{{end}}.

Also accepts the [global flags](https://docs.polymorfa.com/cli#global-flags).

### Examples

```bash
polymorfa api /platform/projects --surface platform
```

```bash
polymorfa api /v1/campaigns --surface platform -X POST -f name=Launch -F dryRun=true -F audience[]=vip
```

```bash
polymorfa api /platform/customers --surface platform --paginate --jq '.data[].id'
```

```bash
polymorfa api /platform/customers --surface platform --paginate --slurp --jq 'map(.data | length) | add'
```

```bash
polymorfa api /platform/projects --surface platform --template '{{range .data}}{{.slug}}{{"\t"}}{{.name}}{{"\n"}}{{end}}'
```
