Maileditor Docs
PluginAPI referenceEmbedded API

AI text

Generate or rewrite copy inside the editor on the plugin owner's AI key.

Requires Authorization: Bearer {session_token} from the session endpoint and the embedded headers.

Generation runs on the key the owner attached through the AI Credentials tab. There is no fallback key, and the provider is not selectable per request. curation.ai.is_available in the bootstrap response tells the editor whether this endpoint will work.

Generate text

POST /public/plugin/v1/ai-text-generate
Content-Type: application/json
FieldTypeRequiredNotes
messagestringyesWhat to write or rewrite. Max 5000 characters
promptstringnoExtra instructions layered on top of the default copywriting prompt. Max 2000 characters
prompt_template_idintegernoOne of MailEditor's stored prompt templates. Replaces the default prompt

If both prompt and prompt_template_id are sent, the template wins. prompt overrides the default behaviour wherever they conflict, so "translate this message into Spanish" works. message is always treated as content, never as instructions.

{ "message": "Write a headline for a summer sale on running shoes" }

200

{
  "message": "AI text generated successfully",
  "result": {
    "ai_text": "SUMMER SALE — UP TO 40% OFF",
    "provider": "anthropic",
    "model": "claude-haiku-4-5-20251001"
  }
}

Errors

StatuserrorMeaning
403ai_not_configuredThis plugin has no AI key
403no_ai_credentialA key exists but could not be read
502ai_generation_failedThe provider refused, was unreachable, or answered in an unreadable shape. The provider's response is not included
402quota_exceededThe period's generations are used up. result.feature is ai_generations
422message missing or over 5000 characters
429Rate limited

Allowance and throttling

Generations are checked against the ai_generations plan feature before the provider is called, so a refused generation costs nothing. Every plan allows unlimited generations, because they run on your own provider key. A plugin with no active subscription cannot generate.

LimitKeyed on
20 per minutesession token
200 per hoursession token
2000 per dayplugin

On this page