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 organization | This endpoint |
|---|---|
OWNER | Allowed |
ADMIN | Allowed |
MEMBER | Refused — 403 |
Path parameters
| Parameter | Type | Description |
|---|---|---|
topicId | string | Required. 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 amemberof the organization, not anadmin.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
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the operation was successful |
data.id | string | Identifier of what was removed |
Example response
json
{
"success": true,
"data": {
"id": "7c2e4b19"
}
}Agent recipe
Detach, then delete — and read the409 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
}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.