# Send test copies of a template

`POST /v1/templates/{slug}/test`

- Authentication: required (Bearer token)
- Required scope: `api.templates.test`

Sends one rendered copy of the template to each address in
`recipients`, so a person can look at the real thing in a real inbox.

**This is real email from the organization's own SES account and it
cannot be recalled.** It goes to no audience, list or segment: at most
ten individually named addresses, which need not be contacts.
**Consent and suppression are deliberately NOT applied** — a test send
reaches somebody who unsubscribed, bounced, or is on the SES
suppression list. That is the point (you are showing an email to a
colleague) and it means a successful test send is not evidence that a
real send to the same address would go out. To mail an actual audience,
use `POST /v1/broadcasts` and `POST /v1/broadcasts/{id}/send`, which
apply the filtering this path skips.

The whole recipient list is validated before anything is sent, so a
typo cannot leave you having delivered half the copies. The send loop
does not stop at a failure: `sent_to` and `failed` partition the list,
both always present, so a retry does not mail everyone else twice.

Render first with `POST /v1/templates/render` and check
`variables_unresolved` — a merge field you have not supplied arrives
blank, and unlike a render you cannot take this back.

Supply `variables` or `profile_id`, not both. Test sends are rate
limited per organization (and per user where the credential has one).

## Path parameters

- `slug` (string, required) — Template name (e.g. `welcome`).

## Request body

Content type: `application/json`

```json
{
  "recipients": [
    "user@example.com"
  ],
  "variables": {},
  "profile_id": "00000000-0000-0000-0000-000000000000"
}
```

## Example request

```bash
curl -X POST 'https://api.sendops.dev/v1/templates/string/test' \
  -H "Authorization: Bearer $SENDOPS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"recipients":["user@example.com"],"variables":{},"profile_id":"00000000-0000-0000-0000-000000000000"}'
```

## Responses

### 200 — Per-recipient outcomes

Content type: `application/json`

```json
{
  "slug": "string",
  "sent_to": [
    {
      "recipient": "string",
      "message_id": "string",
      "subject": "string"
    }
  ],
  "failed": [
    {
      "recipient": "string",
      "reason": "string"
    }
  ],
  "warning": "string"
}
```

### 401 — Missing, malformed, or unknown API key

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 403 — Either the credential lacks the required scope (`code: invalid_scope`), or it is bound to the `test` environment and this operation is irreversible (`code: test_environment_forbidden`). Branch on `code`: the first is fixed by granting the scope, the second only by using a live credential. See the "Live and test credentials" section of the API description.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 404 — Resource not found

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 422 — A query parameter, path value or body field failed validation.

The body is a `validation_failed` Problem. When the refusal is about a
reference — a segment key, template slug, topic or attribute name the
organization does not have — it additionally carries `validation_code`,
`field`, `line`/`column`, `missing`, `candidates` and `next_step`, so a
client can correct the call without a second round of guessing. See
`ValidationProblem`.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ],
  "validation_code": "invalid_syntax",
  "field": "string",
  "line": 0,
  "column": 0,
  "missing": [
    {
      "kind": "segment",
      "key": "string"
    }
  ],
  "candidates": {},
  "next_step": "string"
}
```

### 429 — Per-org rate limit exceeded

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 500 — Unexpected server-side failure. The `code` is `internal_error`. The
`request_id` field can be quoted to SendOps support to investigate.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```
