Reten Docs

Create Activity

Create a new activity assigned to a commerce.

POST /api/activities

Create a new activity (TASK or MESSAGE) with commerce assignment, target resolution, and attribute resolution.

Auth: Required — CREATE_ACTIVITY permission

Request Body

FieldTypeRequiredDescription
typestringYesTASK or MESSAGE
reasonstringYesReason for creating the activity
channelstringYesSALESMAN, CALLCENTER, WHATSAPP, EMAIL, SMS, PUSH
commerce_idUUIDYesTarget commerce ID
idempotency_keystringYesUnique key per tenant (prevents duplicates)
scheduled_atISO 8601YesWhen the activity should be executed
suggested_execution_timeISO 8601NoSuggested time for execution
user_statusstringNoUser status context
scoreintegerNoPriority score
assignment_reasonstringNoReason for the assignment
target_criteriaarrayNoOverride target resolution criteria (objects with type, config, priority)
attribute_keysstring[]NoAttribute key names to resolve via policies
attributesarrayNoCaller-provided attribute values (objects with key, value, fallback)

Example

curl -X POST https://api.reten.ai/api/activities \
  -H "Authorization: Bearer <token>" \
  -H "x-tenant-id: <tenant-id>" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "MESSAGE",
    "reason": "Monthly promotion",
    "channel": "WHATSAPP",
    "commerce_id": "880e8400-e29b-41d4-a716-446655440000",
    "idempotency_key": "msg-2025-01-15-001",
    "scheduled_at": "2025-01-16T09:00:00.000Z",
    "attribute_keys": ["commerce_info"]
  }'
const response = await fetch("https://api.reten.ai/api/activities", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <token>",
    "x-tenant-id": "<tenant-id>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "MESSAGE",
    reason: "Monthly promotion",
    channel: "WHATSAPP",
    commerce_id: "880e8400-e29b-41d4-a716-446655440000",
    idempotency_key: "msg-2025-01-15-001",
    scheduled_at: "2025-01-16T09:00:00.000Z",
    attribute_keys: ["commerce_info"],
  }),
});
const activity = await response.json();
import requests

response = requests.post(
    "https://api.reten.ai/api/activities",
    headers={
        "Authorization": "Bearer <token>",
        "x-tenant-id": "<tenant-id>",
    },
    json={
        "type": "MESSAGE",
        "reason": "Monthly promotion",
        "channel": "WHATSAPP",
        "commerce_id": "880e8400-e29b-41d4-a716-446655440000",
        "idempotency_key": "msg-2025-01-15-001",
        "scheduled_at": "2025-01-16T09:00:00.000Z",
        "attribute_keys": ["commerce_info"],
    },
)
activity = response.json()

Response 201 Created

{
  "id": "ee0e8400-e29b-41d4-a716-446655440000",
  "type": "MESSAGE",
  "reason": {
    "code": "monthly_promotion",
    "label": "Promocion Mensual"
  },
  "channel": "WHATSAPP",
  "status": "READY",
  "userStatus": null,
  "idempotencyKey": "msg-2025-01-15-001",
  "scheduledAt": "2025-01-16T09:00:00.000Z",
  "commerceAssignment": {
    "commerceId": "880e8400-e29b-41d4-a716-446655440000"
  }
}

Error Responses

StatusDescription
400Validation error
404Commerce not found
409Idempotency key already exists