Skip to the page

Command line

Every method of the API as a command, for a terminal or a script.

Get it

The command comes with the SDK package, which is not on npm yet. Until it is published, run it from the repository, in packages/opensend.

Text
Usage: opensend <command>   opensend login [--key <key>] [--url <address>]   Save the key, and the address of a server of your own  opensend logout                                  Forget them  opensend whoami                                  Say who the key belongs to  opensend methods                                 List every command  opensend <group> <action> [id] [--flags]         Call the API, for example:   opensend emails send --from "Acme <hello@mail.example.com>" --to ada@example.com \    --subject "Your receipt" --text "Thanks for your order."  opensend domains list  opensend emails get em_02c41d09b7e4 Every command takes --help, and --json with the whole input as JSON.OPENSEND_API_KEY and OPENSEND_API_URL win over what login saved.

Sign in

Give the key once. It is checked with a request, then saved. On a server of your own, give its address as well, with --url. Leave the key out and the command asks for it.

Shell
opensend login --key os_...opensend whoamiopensend logout
  • The key and the address are saved in ~/.config/opensend/config.json, or under $XDG_CONFIG_HOME when that is set. Only you can read the file.
  • OPENSEND_API_KEY and OPENSEND_API_URL in the environment win over the saved values, which suits a script or a CI job.
  • whoami says who the key belongs to, and logout forgets the saved values.

Run a command

A command is opensend <group> <action>, then the id when the method acts on one thing, then the input as flags. A flag is the name of the field with dashes: scheduledAt is --scheduled-at.

Shell
opensend emails list --status bounced --limit 20opensend domains update dom_02 --click-trackingopensend domains update dom_02 --click-tracking falseopensend webhooks create --url https://example.com/hooks/mail --events email.delivered,email.bouncedopensend emails send --tags '{"category":"receipt"}' --json '{"from":"Acme <hello@mail.example.com>","to":"ada@example.com","subject":"Hi","text":"Hello"}'opensend emails send --help
Field
Text or a number
Flag
--subject "Your receipt", --limit 20
Field
A switch
Flag
--click-tracking for yes, --click-tracking false for no
Field
A list
Flag
--to a@example.com,b@example.com, or the flag once per value
Field
An object
Flag
--tags '{"category":"receipt"}', as JSON
  • --json takes the whole input as one JSON object. A flag beside it wins over the same field in it.
  • --help after a command lists its flags and marks the ones it needs.
  • opensend <group> lists the actions of a group, and opensend methods lists every command.

Output

A command prints the answer of the API as JSON and ends with status 0. When it fails it prints the code and the message of the error on the error stream and ends with status 1, so a script can stop on it.

Shell
opensend emails get em_02 | jq -r .status

Every command

Emails

What it does
Send email
What it does
Send emails in a batch
What it does
Reschedule email
What it does
Cancel email
What it does
Retrieve email
What it does
List emails

Received emails

What it does
List received emails
What it does
Retrieve received email

Domains

What it does
Add domain
What it does
Verify domain
What it does
Retrieve domain
What it does
List domains
What it does
Update domain
What it does
Delete domain

Templates

What it does
Create template
What it does
Get template
What it does
List templates
What it does
Update template
What it does
Edit template design
What it does
Publish template
What it does
Send test of template
What it does
Render template design
What it does
Duplicate template
What it does
List template versions
What it does
Get template version
What it does
Restore template version
What it does
Delete template
What it does
List template starters
What it does
Get template starter

Images

What it does
Add image
What it does
Upload image
What it does
List images
What it does
Retrieve image
What it does
Delete image

Broadcasts

What it does
Create broadcast
What it does
Update broadcast
What it does
Send broadcast
What it does
Send test of broadcast
What it does
Duplicate broadcast
What it does
Retrieve broadcast
What it does
List broadcasts
What it does
Delete broadcast

Audiences

What it does
Create audience
What it does
List audiences
What it does
Retrieve audience
What it does
Rename audience
What it does
Delete audience
What it does
Add contact to audience
What it does
Remove contact from audience

Contacts

What it does
Add contact
What it does
List contacts
What it does
Retrieve contact
What it does
Update contact
What it does
Delete contact

Contact properties

What it does
Create contact property
What it does
List contact properties
What it does
Retrieve contact property
What it does
Update contact property
What it does
Delete contact property

Topics

What it does
Create topic
What it does
List topics
What it does
Retrieve topic
What it does
Update topic
What it does
Delete topic

Suppressions

What it does
Suppress an address
What it does
List suppressed addresses
What it does
Remove a suppressed address

Automations

What it does
Create automation
What it does
Update automation
What it does
Publish automation
What it does
Pause automation
What it does
Resume automation
What it does
Test automation
What it does
Enrol in automation
What it does
Duplicate automation
What it does
Retrieve automation
What it does
List automations
What it does
Delete automation

Runs

What it does
List runs
What it does
Retrieve run
What it does
Cancel run
What it does
Retry run

Events

What it does
Send event
What it does
Define event
What it does
List events
What it does
Retrieve event
What it does
Update event
What it does
Delete event

Webhooks

What it does
Add webhook
What it does
List webhooks
What it does
Update webhook
What it does
Delete webhook
What it does
Send test event
What it does
List webhook deliveries

Metrics

What it does
Retrieve metrics

Logs

What it does
List logs
What it does
Retrieve log

API keys

What it does
Create API key
What it does
Enroll existing API key
What it does
List API keys
What it does
Revoke API key

Imports

What it does
Look into another account
What it does
Start import
What it does
Retrieve import
What it does
List imports
What it does
Cancel import

Workspace

What it does
Retrieve workspace
What it does
Update workspace
What it does
Close workspace

Members

What it does
Invite member
What it does
List members
What it does
Update member
What it does
Remove member

Billing

What it does
List plans
What it does
Start checkout
What it does
Open billing portal
What it does
List invoices

Server

What it does
Retrieve server settings
What it does
Update server settings

Account

What it does
Retrieve account

Methods

What it does
List methods

Assistant

What it does
Ask the assistant
What it does
List chats
What it does
Retrieve chat
What it does
Keep chat
What it does
Forget chat