# Send test of template

`opensend templates test`

Sends the template as it is saved now, published or not, to the addresses you give, with "[Test]" before the subject. It needs a subject and a message. It is a real email and counts as one. A test key may send it to test addresses only, and the email is then simulated.

Needs the scope: `emails:send`

## Flags

- `<id>` (string, required): The id of the item. Up to 64 characters.
- `--to` (string | string[], required): Who gets the test: one address, or up to 50.
- `--from` (string): The sender of the test, on a verified domain. Without it, the one of the template. Up to 500 characters.
- `--variables` (Record<string, string>): A value for a variable, by name, for this test only. A variable with no value and no default stays in the message as `{{NAME}}`.

## Returns

The command prints the answer: as JSON when its output goes to a file or another program, and as a table or a list of fields in a terminal. When the API refuses, the error goes to the error stream and the command ends with a code that names the failure. [Output and scripts](https://opensend.sh/docs/scripting) lists the codes.

- `object` ("email"): Always `email`.
- `id` (string): The id of the email.
- `from` (string): The sender.
- `to` (string[]): Who the email is for.
- `subject` (string): The subject line.
- `status` (string): Where the email is: `scheduled`, `queued`, `sent`, `delivered`, `delayed`, `bounced`, `complained`, `failed` or `canceled`, and `opened` or `clicked` once the recipient acts. One of: `queued`, `sent`, `delivered`, `delayed`, `bounced`, `opened`, `clicked`, `complained`, `failed`, `scheduled`, `canceled`.
- `mode` (string): `live` for a real email. `test` for an email of the sandbox: it was sent with a test key or to test addresses, nothing left the service and what happened to it is simulated. One of: `live`, `test`.
- `domain` (string): The domain it was sent from.
- `cc` (string[]): Who got a copy.
- `bcc` (string[]): Who got a copy without the others seeing.
- `replyTo` (string | null): The address replies go to, or `null`.
- `scheduledAt` (string | null): When it is due to be sent, or `null` for an email sent at once.
- `createdAt` (string): When the API accepted the email.
- `html` (string | null): The message as HTML, or `null`.
- `text` (string | null): The message as plain text, or `null`.
- `headers` (Record<string, string>): The extra headers you sent, by name.
- `tags` (Record<string, string>): The tags you sent, by name.
- `attachments` (object[]): The files that were attached. Their content is not kept.
- `attachments[].filename` (string): The name of the file.
- `attachments[].contentType` (string | null): The media type of the file, or `null` when none was given.
- `attachments[].size` (integer | null): The size of the file in bytes, or `null` when it was given by address.
- `templateId` (string | null): The id of the template it was built from, or `null`.
- `automation` (object | null): The automation run that sent it, or `null` for an email you sent yourself.
- `automation.id` (string): The id of the automation.
- `automation.runId` (string): The id of the run.
- `automation.stepId` (string): The id of the step that sent it.
- `events` (object[]): What has happened to the email, oldest first.
- `events[].type` (string): What happened: the status the email moved to. One of: `queued`, `sent`, `delivered`, `delayed`, `bounced`, `opened`, `clicked`, `complained`, `failed`, `scheduled`, `canceled`.
- `events[].at` (string): When it happened.
- `events[].detail` (string): More about it, such as the reason for a bounce. Often empty.

## Example

CLI:

```bash
opensend templates test tmpl_06 \
  --to you@example.com \
  --from 'Acme <hello@mail.example.com>' \
  --variables '{"NAME":"Ada"}'
```

Answer:

```json
{
  "object": "email",
  "id": "em_10",
  "from": "Acme <hello@mail.example.com>",
  "to": [
    "you@example.com"
  ],
  "subject": "[Test] Welcome to Acme",
  "status": "queued",
  "mode": "live",
  "domain": "mail.example.com",
  "cc": [],
  "bcc": [],
  "replyTo": null,
  "scheduledAt": null,
  "createdAt": "2026-11-27T09:30:00.000Z",
  "html": "<h1>Welcome, Ada</h1><p>Here is how to get started.</p>",
  "text": null,
  "headers": {},
  "tags": {},
  "attachments": [],
  "templateId": null,
  "automation": null,
  "events": [
    {
      "type": "queued",
      "at": "2026-11-27T09:30:00.000Z",
      "detail": "Accepted by the API and queued."
    }
  ]
}
```
