Reten Docs

Create Activity

Create a new activity assigned to a commerce.

POST /api/activities

Create a new TASK activity with commerce assignment.

Auth: Required — CREATE_ACTIVITY permission

Request Body

FieldTypeRequiredDescription
typestringYesTASK
reasonstringYesReason for creating the activity
channelstringYesSALESMAN, CALLCENTER
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
activity_detailsobjectNoType-specific details — shape depends on type (see below)

activity_details

For type: "TASK", the activity_details object carries route/operator assignment:

FieldTypeRequiredDescription
assigned_route_idUUIDNoAssigned route
assigned_route_external_idstringNoAssigned route by external ID
assigned_operator_idUUIDNoAssigned operator
assigned_operator_external_idstringNoAssigned operator by external ID

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": "TASK",
    "reason": "monthly_visit",
    "channel": "SALESMAN",
    "commerce_id": "880e8400-e29b-41d4-a716-446655440000",
    "idempotency_key": "task-2025-01-15-001",
    "scheduled_at": "2025-01-16T09:00:00.000Z",
    "activity_details": {
      "assigned_route_id": "dd0e8400-e29b-41d4-a716-446655440000",
      "assigned_operator_id": "cc0e8400-e29b-41d4-a716-446655440000"
    }
  }'
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: "TASK",
    reason: "monthly_visit",
    channel: "SALESMAN",
    commerce_id: "880e8400-e29b-41d4-a716-446655440000",
    idempotency_key: "task-2025-01-15-001",
    scheduled_at: "2025-01-16T09:00:00.000Z",
    activity_details: {
      assigned_route_id: "dd0e8400-e29b-41d4-a716-446655440000",
      assigned_operator_id: "cc0e8400-e29b-41d4-a716-446655440000",
    },
  }),
});
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": "TASK",
        "reason": "monthly_visit",
        "channel": "SALESMAN",
        "commerce_id": "880e8400-e29b-41d4-a716-446655440000",
        "idempotency_key": "task-2025-01-15-001",
        "scheduled_at": "2025-01-16T09:00:00.000Z",
        "activity_details": {
            "assigned_route_id": "dd0e8400-e29b-41d4-a716-446655440000",
            "assigned_operator_id": "cc0e8400-e29b-41d4-a716-446655440000",
        },
    },
)
activity = response.json()

Response 201 Created

{
  "id": "ee0e8400-e29b-41d4-a716-446655440000",
  "type": "TASK",
  "reason": {
    "code": "monthly_visit",
    "label": "Visita Mensual"
  },
  "channel": "SALESMAN",
  "status": "READY",
  "userStatus": null,
  "idempotencyKey": "task-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