Mail API reference

Mail API · Templates

post/v1/workspaces/{workspace_id}/templates/{name}/test-sendAuth

Send a test rendering of the template to an arbitrary recipient. Bypasses the suppression list and the ordinary send limits (test sends have their own: 30 per hour per workspace); subject is auto-prefixed with [TEST]; missing variables render as [varname] placeholders.

Path parameters

workspace_id*string · uuid

Id of the workspace.

name*string

Name of the template.

Headers

Idempotency-Keystring

Opaque client-generated string (1–256 chars, `[A-Za-z0-9._:-]`) used to deduplicate retries within a 24h window. A retry with the same key and body returns the original response with `Idempotent-Replay: true`.

Request body

from*string

Sender. Either a bare address (`hello@acme.com`) or a display name plus the address in angle brackets (`Acme <hello@acme.com>`; quote a name that contains a comma: `"Acme, Inc." <hello@acme.com>`). The display name is at most 200 characters. The address's domain must itself be an active (verified) sending domain of the workspace; a verified subdomain does not cover its parent (with only `mail.acme.com` verified, `hello@acme.com` is refused with 422 `from_domain_not_verified`). Same rules as a normal send.

Example: "Acme <hello@acme.com>"

to*string · email

Recipient address for the test email. Suppression-list and rate-limit checks are bypassed for test sends, so a recently-bounced address is still reachable for QA.

dataobject

Variable values to render into the template. Keys correspond to the dotted paths returned by the /variables endpoint.

Example: {"name":"Alice","code":"123456"}

Response · 202

id*string · uuid

Id of the stored message (`outbound_message.id`). Pass it to `GET /messages/{id}` and match it against `data.email_id` on webhook events. Null only if the message log write failed; the send itself was still queued.

Example: "4f8b2c1e-9a3d-4e57-b6f0-2d1c8e7a9b05"

accepted*boolean

Always true on a 202.

Example: true

from*string

The From field as sent, display name included.

Example: "Acme <hello@acme.com>"

to*object

The `to` field as sent: one address, or the array.

Example: "user@example.com"

subject*string

The rendered subject line.

email_id*string · uuid

The email this send created (`GET /emails/{id}`): one email, one message per recipient. Equals `id` for a send whose first message was recorded.

Example: "4f8b2c1e-9a3d-4e57-b6f0-2d1c8e7a9b05"

Example

Request

POST https://api.mail.productcraft.co/v1/workspaces/{workspace_id}/templates/{name}/test-send
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "from": "Acme <hello@acme.com>",
  "to": "user@example.com",
  "data": {
    "name": "Alice",
    "code": "123456"
  }
}

Response

{
  "id": "4f8b2c1e-9a3d-4e57-b6f0-2d1c8e7a9b05",
  "accepted": true,
  "from": "Acme <hello@acme.com>",
  "to": "user@example.com",
  "subject": "string",
  "email_id": "4f8b2c1e-9a3d-4e57-b6f0-2d1c8e7a9b05"
}