Reten Docs

Delete Audience

Archives (soft delete) an audience criteria; responds 204 with no body. Fails with 409 if it is the project's root audience, and with 400 if another criteria references it as an operand.

DELETE /api/audience-criterias/:id

Archives an audience criteria. On deletion, the record is removed immediately from the resource table —which is why it stops appearing in GET /audience-criterias/:id (responds 404) and in GET /audience-criterias— and in its place a recoverable snapshot is kept in the trash for a configurable retention window.

Auth: Required — audience-criteria:delete permission

Path Parameters

ParameterTypeDescription
idUUIDAudience criteria ID. Must be a valid UUID (otherwise, 400).

Behavior

The endpoint validates in this order, and the first check that fails aborts the operation:

  1. Existence — if there is no audience criteria with that id in the active project, it responds 404 (Audience criteria not found).
  2. Not the root audience — the project's root audience cannot be deleted: it responds 409 with the message La audiencia raíz de un proyecto no se puede eliminar.
  3. Not referenced — if another audience criteria that still exists (not archived) references it as an operand in a composition, it responds 400 with the message Cannot delete an audience criteria that is referenced by another active audience criteria. You must remove that composition (or delete the criteria that references it) before you can delete this one.
  4. Archived — if it passes the three checks, the criteria is archived and the endpoint responds 204 No Content with no body.

Example

curl -X DELETE https://api.reten.ai/api/audience-criterias/f47ac10b-58cc-4372-a567-0e02b2c3d479 \
  -H "Authorization: Bearer <token>" \
  -H "x-tenant-id: <tenant-id>" \
  -H "x-project-id: <project-id>"
# → HTTP/1.1 204 No Content (empty body)
import axios from 'axios';

const id = 'f47ac10b-58cc-4372-a567-0e02b2c3d479';
await axios.delete(
  `https://api.reten.ai/api/audience-criterias/${id}`,
  { headers: { Authorization: 'Bearer <token>', 'x-tenant-id': '<tenant-id>', 'x-project-id': '<project-id>' } },
);
// The response is 204 with no body; axios does not reject (2xx).
import requests

criteria_id = "f47ac10b-58cc-4372-a567-0e02b2c3d479"
response = requests.delete(
    f"https://api.reten.ai/api/audience-criterias/{criteria_id}",
    headers={"Authorization": "Bearer <token>", "x-tenant-id": "<tenant-id>", "x-project-id": "<project-id>"},
)
response.raise_for_status()  # 204 No Content, response.content == b""

Response 204 No Content

Empty body. The criteria has been archived.

Error 400 — referenced by another audience

If another audience criteria uses it as an operand in a composition, the deletion is rejected with 400 and the criteria is not archived:

{
  "statusCode": 400,
  "message": "Cannot delete an audience criteria that is referenced by another active audience criteria",
  "error": "Bad Request"
}

Error Responses

StatusDescription
400Another audience criteria references it as an operand in a composition (exact message above), or the id is not a valid UUID.
401Missing or invalid Authorization: Bearer.
403The user lacks the audience-criteria:delete permission, or the x-tenant-id is not authorized.
404No audience criteria with that id exists in the active project (Audience criteria not found).
409The criteria is the project's root audience (La audiencia raíz de un proyecto no se puede eliminar).