Generate a personalized cold email sequence for one lead . This is a synchronous request: the response is returned when generation is done, which can take 3–10 minutes . Use a long client timeout (at least 300 seconds, preferably 600).
POST /api/v1/campaigns/:id/generate
Parameter Type Description idstring (UUID) Campaign ID (from GET /api/v1/campaigns).
Header Required Description Authorization or X-API-KeyYes API key. Content-TypeYes application/json
Field Type Required Description leadobject Yes Lead data for personalization. lead.namestring No Full name. lead.titlestring No Job title. lead.companystring No Company name. lead.emailstring Yes Email (required; used for mapping and exports). lead.linkedin_urlstring No LinkedIn profile URL. lead.company_websitestring No Company website. optionsobject No List/generation options (see below).
Option Type Description list_namestring Display name for the list in the UI (default: derived from lead). email_countnumber Number of emails in sequence (1–5; default from campaign or 3). email_signaturestring Signature appended to generated emails. campaign_anglestring Context/angle for personalization. approved_ctasstring or string[] CTAs to use (e.g. "Direct Meeting CTA, Lead Magnet CTA" or array).
curl -X POST "https://app.machfive.io/api/v1/campaigns/CAMPAIGN_ID/generate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"lead": {
"name": "Jane Doe",
"title": "VP Marketing",
"company": "Acme Inc",
"email": "jane@acme.com",
"company_website": "https://acme.com"
},
"options": {
"list_name": "API: jane@acme.com",
"email_count": 3
}
}'
{
"lead_id" : "lead_xyz789" ,
"list_id" : "uuid-of-email_sequences-row" ,
"sequence" : [
{ "step" : 1 , "subject" : "..." , "body" : "..." },
{ "step" : 2 , "subject" : "..." , "body" : "..." },
{ "step" : 3 , "subject" : "..." , "body" : "..." }
],
"credits_remaining" : 94
}
Field Type Description lead_idstring Internal lead identifier. list_idstring (UUID) List/sequence row ID (for status or export if needed). sequencearray Generated emails: step, subject, body per step. credits_remainingnumber Credits left in the workspace after this request.
The response may also include sequence_id (deprecated); use list_id only.
Status Error Description 400 BAD_REQUEST Invalid JSON, missing lead, missing/invalid lead.email, or campaign has no vector store. 401 UNAUTHORIZED Missing or invalid API key. 402 INSUFFICIENT_CREDITS Not enough credits; message includes upgrade guidance. 403 FORBIDDEN Campaign not in this workspace. 404 NOT_FOUND Campaign not found. 500 INTERNAL_ERROR Generation failed.
Error body shape: { "error": "CODE", "message": "Human-readable message" }.