Generate Batch (multiple leads)

Api ReferenceUpdated February 18, 2025

Generate Batch (multiple leads)

Generate personalized cold email sequences for multiple leads in one request. The API accepts the batch and returns immediately with a list_id. Processing runs asynchronously; you poll the list status and then export results when completed.

POST /api/v1/campaigns/:id/generate-batch


Path parameters

ParameterTypeDescription
idstring (UUID)Campaign ID (from GET /api/v1/campaigns).

Headers

HeaderRequiredDescription
Authorization or X-API-KeyYesAPI key.
Content-TypeYesapplication/json

Request body

FieldTypeRequiredDescription
leadsarrayYesArray of lead objects (at least one). Each lead must include a valid email.
leads[].namestringNoFull name.
leads[].titlestringNoJob title.
leads[].companystringNoCompany name.
leads[].emailstringYesEmail (required; used for mapping and export).
leads[].linkedin_urlstringNoLinkedIn profile URL.
leads[].company_websitestringNoCompany website.
optionsobjectNoSame as single-lead: list_name, email_count, email_signature, campaign_angle, approved_ctas.

Example request

curl -X POST "https://app.machfive.io/api/v1/campaigns/CAMPAIGN_ID/generate-batch" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "leads": [
      { "name": "Jane Doe", "title": "VP Marketing", "company": "Acme Inc", "email": "jane@acme.com" },
      { "name": "John Smith", "title": "CTO", "company": "Beta Co", "email": "john@beta.co" }
    ],
    "options": {
      "list_name": "API Batch Q1",
      "email_count": 3
    }
  }'

Response (202 Accepted)

The request returns immediately. Processing continues in the background.

{
  "list_id": "uuid-of-email_sequences-row",
  "status": "processing",
  "message": "Batch accepted. Processing will continue in the background. Poll list status or open in the UI."
}

The response may also include sequence_id (deprecated); use list_id only.

FieldTypeDescription
list_idstring (UUID)Use this to poll GET /api/v1/lists/:list_id and to export with GET /api/v1/lists/:list_id/export.
statusstring"processing".
messagestringHuman-readable confirmation.

Next steps

  1. Poll GET /api/v1/lists/:list_id until processing_status is completed or failed.
  2. When completed, call GET /api/v1/lists/:list_id/export?format=csv or ?format=json to download results.

See Lists for list status and export details.


Error responses

StatusErrorDescription
400BAD_REQUESTInvalid JSON, missing leads, or a lead missing/invalid email.
401UNAUTHORIZEDMissing or invalid API key.
402INSUFFICIENT_CREDITSNot enough credits for this many leads.
403FORBIDDENCampaign not in this workspace.
404NOT_FOUNDCampaign not found.
429WORKSPACE_LIMITToo many concurrent batch jobs; try again later.
500INTERNAL_ERRORFailed to enqueue or create list.

Error body: { "error": "CODE", "message": "..." } (and optionally detail).