Update, Delete & Branch
Update, Delete & Branch
Manage existing campaigns: rename them, delete them (with a data-preserving cascade), and branch a new campaign from an existing one at a chosen step.
All endpoints require the campaigns:write scope and operate only on campaigns in the API key's workspace.
Rename a campaign
PATCH /api/v1/campaigns/:id · scope campaigns:write
Updates a campaign's display name.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string (UUID) | Campaign ID. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | New campaign name (1–200 characters, trimmed). |
Example request
curl -X PATCH "https://app.machfive.io/api/v1/campaigns/CAMPAIGN_ID" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Q2 Enterprise Outreach" }'Response (200 OK)
{
"id": "uuid",
"name": "Q2 Enterprise Outreach",
"created_at": "2025-01-15T12:00:00.000Z"
}Error responses
| Status | Error | Description |
|---|---|---|
| 400 | BAD_REQUEST | Missing or invalid name. |
| 401 | UNAUTHORIZED | Missing or invalid API key. |
| 403 | FORBIDDEN | Key missing the campaigns:write scope. |
| 404 | NOT_FOUND | Campaign not found or not in this workspace. |
| 500 | INTERNAL_ERROR | Server error. |
Delete a campaign
DELETE /api/v1/campaigns/:id · scope campaigns:write
Deletes a campaign and its regenerable artifacts (configuration, system prompts, asset selections, previews, generated documents, conversations, etc.).
Your lead data is preserved. Lists that belonged to this campaign are detached and retained — their rows and uploaded/processed CSV files in storage are not deleted. After deletion, those lists have
campaign_id: nulland remain accessible via the Lists endpoints (and exportable). Credit usage history is also retained for auditing.
In-flight guard: If any list in the campaign is currently processing, the request returns
409 CONFLICT. Wait until those lists complete or fail, then retry.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string (UUID) | Campaign ID. |
Example request
curl -X DELETE "https://app.machfive.io/api/v1/campaigns/CAMPAIGN_ID" \
-H "Authorization: Bearer YOUR_API_KEY"Response (200 OK)
{ "id": "uuid", "deleted": true }Error responses
| Status | Error | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid API key. |
| 403 | FORBIDDEN | Key missing the campaigns:write scope. |
| 404 | NOT_FOUND | Campaign not found or not in this workspace. |
| 409 | CONFLICT | A list in this campaign is currently processing. detail.processing_status shows the current status. |
| 500 | INTERNAL_ERROR | Server error. |
Branch a campaign
POST /api/v1/campaigns/:id/branch · scope campaigns:write
Creates a new campaign that reuses the source campaign's configuration up to a chosen step. Everything from the branch step onward is left for you to (re)configure on the new campaign. This is synchronous and does not consume credits.
Path parameters
| Parameter | Type | Description |
|---|---|---|
id | string (UUID) | Source campaign ID to branch from. |
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <API_KEY> (or X-API-Key). |
Content-Type | Yes | application/json. |
Idempotency-Key | No | A unique key to safely retry. A replayed key returns the originally created campaign id; a failed run releases the key so you can retry. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name for the new (branched) campaign (1–200 characters). |
branch_from_step | string | Yes | The step to branch from. One of: target-audience, social-proof, lead-magnets, risk-reversal, value-propositions. Config from earlier steps is copied; this step and later are left open. |
target_audience | object | Conditional | Required only when branch_from_step is target-audience. The target-audience segment to seed the branch with (see below). |
is_custom_target_audience | boolean | No | Whether target_audience is a custom (user-defined) segment. Default false. |
target_audience object:
| Field | Type | Required | Description |
|---|---|---|---|
id | string (UUID) | Conditional | Required when is_custom_target_audience is false (selecting an existing segment). Omit for a custom segment. Branching from target-audience without an id for a non-custom segment returns 422 UNPROCESSABLE. |
segment_name | string | Yes | Name of the target segment. |
industry_vertical | string | No | Industry / vertical. |
company_size | string | No | Company size descriptor. |
annual_revenue | string | No | Annual revenue descriptor. |
geographic_location | string | No | Geographic location. |
decision_makers | string | string[] | No | Decision-maker title(s). |
additional_details | string | No | Extra context. |
Example request
curl -X POST "https://app.machfive.io/api/v1/campaigns/CAMPAIGN_ID/branch" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme – Mid-Market Variant",
"branch_from_step": "social-proof"
}'Response (201 Created)
{
"id": "new-campaign-uuid",
"source_campaign_id": "uuid"
}| Field | Type | Description |
|---|---|---|
id | string (UUID) | The newly created campaign. |
source_campaign_id | string (UUID) | The campaign it was branched from. |
Error responses
| Status | Error | Description |
|---|---|---|
| 400 | BAD_REQUEST | Invalid body (bad branch_from_step, or missing target_audience when branching from target-audience). |
| 401 | UNAUTHORIZED | Missing or invalid API key. |
| 403 | FORBIDDEN | Key missing the campaigns:write scope. |
| 404 | NOT_FOUND | Source campaign not found or not in this workspace. |
| 409 | CONFLICT | An Idempotency-Key was reused with a different body, or a request with the same key is still in flight. |
| 422 | UNPROCESSABLE | No active configuration found to branch from, or branching from target-audience without a target_audience.id for a non-custom segment. |
| 500 | INTERNAL_ERROR | Server error. |