Edit a draft campaign

PATCH /api/v1/campaigns/{campaignId} Edits a draft campaign. A campaign is created with a copy of its template's HTML, then lives on its own: this endpoint edits that copy — the HTML actually sent — without touching the template. A campaign that has already been sent or is sending is frozen and returns 400. Every field is optional; only those you send are changed. Mailchimp merge tags in the HTML are converted as on template creation; any unsupported tag is returned in unsupportedTags.

Authorization

Role in the organizationThis endpoint
OWNERAllowed
ADMINAllowed
MEMBERRefused — 403
A key carries the role its creator holds in this organization — never a role on AgentsMail itself. See API keys.

Request body

FieldTypeRequiredDescription
contentstringnoThe HTML of the email
subjectstringno1 to 200 characters
namestringno1 to 100 characters
listIdstringnoRetargets the campaign; must belong to the org
tagIdstringnoNarrows the target to a tag, or null to clear
templateIdstringnoRe-links the source template; must belong to the org
sendingIdentityIdstringnoChanges the signing address, or null to fall back to the default

Example

bash
curl -X PATCH -H "x-api-key: $AGENTMAIL_API_KEY" -H "content-type: application/json" \
  https://www.agentsmail.io/api/v1/campaigns/$CAMPAIGN_ID \
  -d '{ "content": "<html><body><p>Hi {{firstName}}</p><a href=\"{{unsubscribeUrl}}\">Unsubscribe</a></body></html>" }'

Response

  • 200 OK — the call succeeded.
  • 401 Unauthorized — missing or invalid key, or its owner left the organization.
  • 403 Forbidden — the key's owner is a member of the organization, not an admin.
  • 404 Not Found — no such resource, or it belongs to another organization. The API never confirms that an id exists to a caller who has no right to it.
  • 429 Too Many Requests — over 120 requests in a minute for this key.

Response fields

FieldTypeDescription
successbooleanIndicates if the operation was successful
data.idstringUnique identifier for the campaign
data.namestringIts internal name
data.subjectstringThe subject recipients see
data.statusstringdraft, scheduled, sending, sent, failed
data.listIdstringThe list it targets
data.tagIdstringnull
data.segmentIdstringnull
data.scheduledAtstringnull
data.sentAtstringnull
data.createdAtstringISO creation date
data.updatedAtstringISO date of the last change

Example response

json
{
  "success": true,
  "data": {
    "id": "4d19c0a2",
    "name": "Newsletter",
    "subject": "August news",
    "status": "subscribed",
    "listId": "0b7c51e8",
    "tagId": "7c2ef4b1",
    "segmentId": "3f81aa2c",
    "scheduledAt": "2026-08-23T10:22:05.000Z",
    "sentAt": "2026-08-23T10:22:05.000Z",
    "createdAt": "2026-08-23T10:22:05.000Z",
    "updatedAt": "2026-08-23T10:22:05.000Z"
  }
}