# Commands and input

How a method becomes a command, and how to give it its input.

## A command

A command is `opensend <group> <action>`, then the ids its path needs, in order, then the input as flags. A flag is the name of the field with dashes: `scheduledAt` is `--scheduled-at`.

```bash
opensend emails list --status bounced --limit 20
opensend domains update dom_02 --click-tracking
opensend domains update dom_02 --click-tracking=false
opensend webhooks create --url https://example.com/hooks/mail --events email.delivered,email.bounced
opensend emails send --tags '{"category":"receipt"}' --input '{"from":"Acme <hello@mail.example.com>","to":"ada@example.com","subject":"Hi","text":"Hello"}'
opensend emails list --limit 1 --all --max 2
opensend emails send --help
```

## Ids

Ids come first, in the order of the path. A run is named by its automation, then by itself:

```bash
opensend runs get auto_welcome run_01
```

A flag can give an id as well, and the words then fill the ids no flag gave.

## Flags

| Field | Flag |
| --- | --- |
| Text or a number | `--subject "Your receipt"`, `--limit 20` |
| A switch | `--click-tracking` for yes, `--click-tracking=false` for no |
| A list | `--to a@example.com,b@example.com`, or the flag once for each value. A comma inside quotes or angle brackets stays in its value |
| An object | `--tags '{"category":"receipt"}'`, as JSON |

- A switch never takes the next word, so `--click-tracking false` is an error and not a no.
- `--` ends the flags: every word after it is an id, even one that starts with a dash.

## The whole input at once

`--input` takes the whole input as one JSON object: as text, as `@file`, or as `-` to read it from standard input. A flag beside it wins over the same field in it.

```bash
opensend emails send --input @receipt.json --to ada@example.com
cat receipt.json | opensend emails send --input -
```

## Help

- `opensend <group>` lists the actions of a group.
- `--help` after a command lists its flags, marks the ones it needs and says what each is for.
- `--help --json` prints the same as JSON, for a program or an agent that builds commands.
- `opensend commands` lists every command.

## A request of your own

`api` sends any request to the API with your key, for a path the commands do not cover. Its input goes in the query of a `GET` or a `DELETE`, merged with any query in the path, and in the body of the others. A `DELETE` asks first, as a removal does.

```bash
opensend api GET /v1/domains --input '{"limit":5}'
```

## Every command

| Command | What it does |
| --- | --- |
| opensend emails send | Send email |
| opensend emails batch | Send emails in a batch |
| opensend emails update | Reschedule email |
| opensend emails cancel | Cancel email |
| opensend emails get | Retrieve email |
| opensend emails list | List emails |
| opensend inbound list | List received emails |
| opensend inbound get | Retrieve received email |
| opensend domains create | Add domain |
| opensend domains verify | Verify domain |
| opensend domains get | Retrieve domain |
| opensend domains list | List domains |
| opensend domains update | Update domain |
| opensend domains remove | Delete domain |
| opensend templates create | Create template |
| opensend templates get | Get template |
| opensend templates list | List templates |
| opensend templates update | Update template |
| opensend templates edit | Edit template design |
| opensend templates publish | Publish template |
| opensend templates test | Send test of template |
| opensend templates render | Render template design |
| opensend templates duplicate | Duplicate template |
| opensend templates versions | List template versions |
| opensend templates version | Get template version |
| opensend templates restore | Restore template version |
| opensend templates remove | Delete template |
| opensend templates starters | List template starters |
| opensend templates starter | Get template starter |
| opensend images add | Add image |
| opensend images upload | Upload image |
| opensend images list | List images |
| opensend images get | Retrieve image |
| opensend images remove | Delete image |
| opensend broadcasts create | Create broadcast |
| opensend broadcasts update | Update broadcast |
| opensend broadcasts send | Send broadcast |
| opensend broadcasts test | Send test of broadcast |
| opensend broadcasts duplicate | Duplicate broadcast |
| opensend broadcasts get | Retrieve broadcast |
| opensend broadcasts list | List broadcasts |
| opensend broadcasts remove | Delete broadcast |
| opensend audiences create | Create audience |
| opensend audiences list | List audiences |
| opensend audiences get | Retrieve audience |
| opensend audiences update | Rename audience |
| opensend audiences remove | Delete audience |
| opensend audiences join | Add contact to audience |
| opensend audiences leave | Remove contact from audience |
| opensend contacts create | Add contact |
| opensend contacts list | List contacts |
| opensend contacts get | Retrieve contact |
| opensend contacts update | Update contact |
| opensend contacts remove | Delete contact |
| opensend contact-properties create | Create contact property |
| opensend contact-properties list | List contact properties |
| opensend contact-properties get | Retrieve contact property |
| opensend contact-properties update | Update contact property |
| opensend contact-properties remove | Delete contact property |
| opensend topics create | Create topic |
| opensend topics list | List topics |
| opensend topics get | Retrieve topic |
| opensend topics update | Update topic |
| opensend topics remove | Delete topic |
| opensend suppressions create | Suppress an address |
| opensend suppressions list | List suppressed addresses |
| opensend suppressions remove | Remove a suppressed address |
| opensend automations create | Create automation |
| opensend automations update | Update automation |
| opensend automations publish | Publish automation |
| opensend automations pause | Pause automation |
| opensend automations resume | Resume automation |
| opensend automations test | Test automation |
| opensend automations enroll | Enrol in automation |
| opensend automations duplicate | Duplicate automation |
| opensend automations get | Retrieve automation |
| opensend automations list | List automations |
| opensend automations remove | Delete automation |
| opensend runs list | List runs |
| opensend runs get | Retrieve run |
| opensend runs cancel | Cancel run |
| opensend runs retry | Retry run |
| opensend events send | Send event |
| opensend events create | Define event |
| opensend events list | List events |
| opensend events get | Retrieve event |
| opensend events update | Update event |
| opensend events remove | Delete event |
| opensend webhooks create | Add webhook |
| opensend webhooks list | List webhooks |
| opensend webhooks update | Update webhook |
| opensend webhooks remove | Delete webhook |
| opensend webhooks test | Send test event |
| opensend webhooks deliveries | List webhook deliveries |
| opensend metrics get | Retrieve metrics |
| opensend logs list | List logs |
| opensend logs get | Retrieve log |
| opensend api-keys create | Create API key |
| opensend api-keys enroll | Enroll existing API key |
| opensend api-keys list | List API keys |
| opensend api-keys remove | Revoke API key |
| opensend imports inspect | Look into another account |
| opensend imports create | Start import |
| opensend imports get | Retrieve import |
| opensend imports list | List imports |
| opensend imports cancel | Cancel import |
| opensend workspace get | Retrieve workspace |
| opensend workspace update | Update workspace |
| opensend members invite | Invite member |
| opensend members list | List members |
| opensend members update | Update member |
| opensend members remove | Remove member |
| opensend billing plans | List plans |
| opensend billing checkout | Start checkout |
| opensend billing portal | Open billing portal |
| opensend billing invoices | List invoices |
| opensend server get | Retrieve server settings |
| opensend account get | Retrieve account |
| opensend methods list | List methods |
