Legacy send endpoints

The /send/{project}/raw/email and /send/{project}/template/email compatibility endpoints, and how to migrate to /messages/email.

When to use these endpoints

Relayit keeps two older send endpoints so existing integrations keep working:

  • POST /send/{project}/raw/email sends inline HTML or text.
  • POST /send/{project}/template/email sends a Template by slug.

They run through the same pipeline as POST /messages/email, so Domains, Templates, suppression, and limits behave the same way.

Use them only if you already have code that calls them. New integrations should use POST /messages/email. It supports more features (multiple recipients, cc, bcc, reply-to, tags, custom headers, scheduling, idempotency) and returns more precise errors.

Authentication and path

  • {project} is your Project slug. Find it under Settings > Project details.
  • Send the API key in x-api-key (or X-API-Key). The key must belong to the Project in the path.
StatusBody messageWhen
401Unauthorized or the key errorThe key is missing or invalid.
404Project not foundThe key is valid but belongs to a different Project than {project}.

Raw email

bash
curl -X POST https://api.relayit.io/send/my-project/raw/email \
  -H "x-api-key: $RELAYIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "[email protected]",
    "from": "[email protected]",
    "payload": {
      "subject": "Your receipt",
      "html": "<p>Thanks for your order.</p>",
      "text": "Thanks for your order."
    }
  }'

payload needs a non-empty subject and at least one of html or text.

Template email

bash
curl -X POST https://api.relayit.io/send/my-project/template/email \
  -H "x-api-key: $RELAYIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "[email protected]",
    "from": "[email protected]",
    "template": {
      "slug": "welcome-email",
      "props": { "name": "Jane" }
    }
  }'

template.slug accepts a slug or a tmpl_ id. props is passed as the Template variables.

Shared fields

FieldTypeDescription
tostringOne recipient email address.
fromstringOptional plain email address (no display name). When omitted, Relayit uses noreply@ your Project's oldest verified Domain, or the sandbox address if the Project has no verified Domain and the Sandbox Domain is active.
contactobjectOptional. name and externalIdentifiers (string map) for the recipient.
appstringOptional App attribution. Ignored unless appEnvironment is also set.
appEnvironmentstringOptional App Environment attribution. Ignored unless app is also set.
attachmentsarrayUp to 20. Each has filename and either content (base64) or path (URL), plus optional contentType and contentId.

If you omit from and the Project has no verified Domain and no usable Sandbox Domain, the request fails with 400 and the message No sender identity available; pass from or provision Sandbox Domain.

Responses

Success returns 201:

json
{
  "id": "msg_01jbxk3c1ef6h8w2m4n9qz7r5t",
  "status": "queued"
}

Errors use { "message": "...", "details": [...] }:

StatusExample bodyMeaning
400{ "message": "Validation error", "details": ["Invalid from address"] }Bad from address.
400{ "message": "The 'from' address is not a verified sending domain for this Project.", "details": ["invalid_from_address"] }Accept error. details[0] is the same code that /messages/email returns.
429{ "message": "Monthly email send limit exceeded", "details": ["monthly_limit_exceeded"] }Limit reached. No retry_after_seconds.
500{ "message": "Something went wrong", "details": [] }Server error.

The accept error codes are listed in Errors and limits.

Migrate to /messages/email

The move is mostly renaming fields.

Legacy/messages/email
POST /send/{project}/raw/emailPOST /messages/email (the Project comes from the API key)
POST /send/{project}/template/emailPOST /messages/email with template
payload.subjectsubject
payload.htmlhtml
payload.texttext
template.slugtemplate.id (slug or tmpl_ id)
template.propstemplate.variables
to (one address)to (address, list, or Contact objects, up to 50)
contact.nameto: { "email": "...", "first_name": "..." }
contact.externalIdentifiersto: { "email": "...", "properties": { ... } }
app and appEnvironment body fieldsapp and environment headers
attachments[].contentTypeattachments[].content_type
attachments[].contentIdattachments[].content_id
from optional, defaults to noreply@ a verified Domain or sandboxfrom required
Response { id, status }Response { id, stripped? }
Errors 400 with details: [code]Errors 422 with code and details object
401 for bad keys403 with code: "invalid_api_key"

Before:

json
{
  "to": "[email protected]",
  "from": "[email protected]",
  "contact": { "name": "Jane" },
  "app": "shop",
  "appEnvironment": "production",
  "template": { "slug": "welcome-email", "props": { "name": "Jane" } }
}

After:

bash
curl -X POST https://api.relayit.io/messages/email \
  -H "x-api-key: $RELAYIT_API_KEY" \
  -H "app: shop" \
  -H "environment: production" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "[email protected]",
    "to": { "email": "[email protected]", "first_name": "Jane" },
    "template": { "id": "welcome-email", "variables": { "name": "Jane" } }
  }'

Things to check when you switch:

  • Always set from. There is no default sender.
  • Handle 422 with code instead of 400 with details.
  • If you only sent one of app or appEnvironment before, it was ignored. On /messages/email sending only one header is a 400 error.
  • Add an Idempotency-Key header to make retries safe.