Skip to content
View as Markdown

POST Generate Email Body

POST
/ai/generate-email-body

Generate a complete email — subject suggestions, preview text, and body — from a short brief. This is what the “Write with AI” button in the campaign editors calls.

tone and length are validated against a fixed list and silently fall back to friendly / medium when the value is not recognised, so an unexpected value never fails the request.

Body sanitisation depends on context.output_format: gutenberg_blocks is filtered with filter_block_content(), anything else with wp_kses_post().

The call blocks for up to 45 seconds while the provider responds.

Required capability: fcrm_manage_emails

Enforced by AiPolicy::generateEmailBody().

Authorizations

ApplicationPasswords

WordPress Application Passwords — use Basic auth with your WordPress username and an application password in the format: username:application_password

Type
API Key (header: Authorization)

Request Body

application/json
JSON
{
"prompt": "string",
"tone": "friendly",
"audience": "string",
"length": "medium",
"cta": "string",
"context": {
"output_format": "string"
}
}

Responses

Generated email content.

application/json
JSON
{
"email_body": "string",
"subject_suggestions": [
"string"
],
"preview_text": "string",
"provider": "string",
"model": "string"
}

Playground

Authorization
Body

Samples

Powered by VitePress OpenAPI