Delete a topic

DELETE /api/v1/topics/{topicId} Deletes a topic. Only one that nothing carries can go.
Deleting a topic throws away the refusals people expressed. Everyone who declined it starts receiving that theme again, and there is no undo. Read optOutCount on Get a topic before you call this.

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.

Path parameters

ParameterTypeDescription
topicIdstringRequired. The topic to delete

Example

bash
curl -X DELETE -H "x-api-key: $AGENTMAIL_API_KEY" \
  "https://www.agentsmail.io/api/v1/topics/$TOPIC_ID"

Response

  • 200 OK — the id of what was removed.
  • 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 topic, or it belongs to another organization. The API never confirms that an id exists to a caller who has no right to it.
  • 409 Conflict — a campaign or a sequence still carries the topic. The message names them. Retrying will not help: detach them first, or keep the topic.
  • 429 Too Many Requests — over 120 requests in a minute for this key.

Response fields

FieldTypeDescription
successbooleanIndicates if the operation was successful
data.idstringIdentifier of what was removed

Example response

json
{
  "success": true,
  "data": {
    "id": "7c2e4b19"
  }
}

Agent recipe

Detach, then delete — and read the 409 message rather than retrying:
js
const usage = (await get(`/api/v1/topics/${topicId}`)).data

for (const campaign of usage.campaigns) {
  await patch(`/api/v1/campaigns/${campaign.id}`, {topicId: null})
}

const response = await del(`/api/v1/topics/${topicId}`)
if (response.status === 409) {
  // Something was attached in the meantime — the error names it
}
A campaign that has already gone out cannot be edited, so its topic cannot be detached: that topic stays, and that is deliberate — what was sent stays traceable.

Notes

  • The refusal is recomputed at deletion time, not taken from what you last read. A campaign created between your two calls blocks the deletion.
  • Detaching a topic from a published sequence whose steps carry {{topicOptOutUrl}} is itself refused. Open a draft, remove the shortcode, publish — or keep the topic.