Sendry Docs
API Reference

AI

Generate subject lines, preview text, and alt-text, and search resources for @mention insertion.

The AI endpoints generate email copy and resolve @mention references to your own broadcasts, templates, and automations. Generation uses the org's configured AI provider, falling back to the server default (DeepSeek, then Gemini, then Anthropic).

All endpoints require Authorization: Bearer <api_key>. Generation endpoints require full_access scope; mention search accepts read_only and above.


Generate subject

POST /v1/ai/generate-subject

Requires full_access scope. Returns up to count subject-line suggestions (default 3), each under 70 characters.

Request body

FieldTypeRequiredDescription
promptstringYesWhat the email is about, the campaign goal, or seed instructions. 1-2000 characters.
contextstringNoFree-form context: existing draft body, brand voice notes, audience description. Max 8000 characters.
tonestringNoTone hint, e.g. friendly, urgent, professional. Max 40 characters.
languagestringNoTarget language as an ISO-639 name or code, e.g. en, French, pt-BR. Defaults to English.
countintegerNoNumber of alternatives to return (1-6). Default 3.

@slug tokens in prompt or context are resolved to the matching broadcast, template, or automation before generation. See Search mentions.

Example request

{
  "prompt": "Announce the new analytics dashboard to Pro users",
  "tone": "friendly",
  "language": "en",
  "count": 3
}

Response

{
  "suggestions": [
    "Your new analytics dashboard is live",
    "See your numbers like never before",
    "Analytics just got a whole lot clearer"
  ],
  "model": "deepseek-chat"
}

If the provider returns no usable lines, the request fails with 502 ai_empty_response.


Generate preview

POST /v1/ai/generate-preview

Requires full_access scope. Returns up to count inbox preview-text (preheader) suggestions (default 3), ideally 40-90 characters. Provide at least one of subject, prompt, or context, otherwise the request returns 400 missing_input.

Request body

FieldTypeRequiredDescription
subjectstringNo*Subject line the preview should complement. Max 300 characters.
promptstringNo*Goal of the email. Max 2000 characters.
contextstringNo*Free-form context. Max 8000 characters.
languagestringNoTarget language. Defaults to English.
countintegerNoNumber of alternatives to return (1-6). Default 3.

Example request

{
  "subject": "Your new analytics dashboard is live",
  "prompt": "Encourage Pro users to open the email and try the dashboard"
}

Response

{
  "suggestions": [
    "Log in and see your metrics at a glance",
    "Everything you shipped this month, in one view",
    "Your fastest path to better reports"
  ],
  "model": "deepseek-chat"
}

Generate alt-text

POST /v1/ai/generate-alt-text

Requires full_access scope. Returns a single line of alt-text under 125 characters. Provide either imageUrl or imageDescription, otherwise the request returns 400 missing_input.

Request body

FieldTypeRequiredDescription
imageUrlstringNo*URL of the image. Max 2048 characters.
imageDescriptionstringNo*Short description of what the image shows. Max 2000 characters.
contextstringNoSurrounding email context. Max 8000 characters.
languagestringNoTarget language. Defaults to English.

Example request

{
  "imageUrl": "https://cdn.acme.com/hero-dashboard.png",
  "imageDescription": "A product dashboard with a revenue chart and weekly metrics"
}

Response

{
  "altText": "Product dashboard showing a rising revenue chart and weekly metrics",
  "model": "deepseek-chat"
}

Search mentions

GET /v1/ai/mention-search

Requires read_only scope. Returns up to limit items per type, ordered by recency. Use the returned slug as the @mention token in a generation prompt.

Query parameters

ParameterTypeDefaultDescription
qstringCase-insensitive search term. Max 200 characters.
typesstringall threeComma-separated subset of broadcast, template, automation.
limitstring10Max results per type (1-25).

Response

{
  "data": [
    {
      "id": "tpl_abc123",
      "type": "template",
      "name": "Onboarding Welcome",
      "slug": "onboarding-welcome",
      "preview": "Welcome to Acme"
    }
  ]
}
FieldTypeDescription
idstringResource ID.
typestringbroadcast, template, or automation.
namestringDisplay name.
slugstringKebab-case @mention token, e.g. onboarding-welcome.
previewstringOptional preview: the subject for broadcasts, template subject, or body excerpt.

On this page