Reten Docs
Activity Results

Create Activity Result

Create a task activity result.

POST /api/activity-results/tasks

Create a result for a task activity. Results can be linked to existing Reten activities or created as standalone entries.

Auth: Required — CREATE_ACTIVITY permission

Request Body

FieldTypeRequiredDescription
activity_idUUIDNoReten activity ID (one of activity_id or provider_activity_id)
provider_activity_idstringNoExternal provider activity ID
commerce_external_idstringYesExternal ID of the commerce
occurred_atISO 8601YesWhen the result occurred
statusstringYesPENDING, COMPLETED, NOT_EXECUTED, CANCELED, TRANSFERRED
external_statusstringNoProvider-specific status string
hard_overridebooleanNoSkip state transition validation
raw_payloadobjectNoRaw provider payload (stored as-is)
task_resultobjectYesTask-specific result details (see below)

task_result Object

FieldTypeRequiredDescription
resultstringYesTask result type code (e.g., success, not_home)
commentstringNoFree text comment
contact_typestringNoINBOUND or OUTBOUND
operator_external_idstringNoExternal ID of the operator
future_scheduled_atISO 8601NoSuggested date for a follow-up activity
payloadobjectNoAdditional task-specific data

Example

curl -X POST https://api.reten.ai/api/activity-results/tasks \
  -H "Authorization: Bearer <token>" \
  -H "x-tenant-id: <tenant-id>" \
  -H "Content-Type: application/json" \
  -d '{
    "provider_activity_id": "ext-123",
    "commerce_external_id": "store-001",
    "status": "COMPLETED",
    "occurred_at": "2025-01-16T14:30:00.000Z",
    "task_result": {
      "result": "success",
      "comment": "Order placed successfully",
      "contact_type": "OUTBOUND"
    }
  }'
import axios from 'axios';

const response = await axios.post(
  'https://api.reten.ai/api/activity-results/tasks',
  {
    provider_activity_id: 'ext-123',
    commerce_external_id: 'store-001',
    status: 'COMPLETED',
    occurred_at: '2025-01-16T14:30:00.000Z',
    task_result: {
      result: 'success',
      comment: 'Order placed successfully',
      contact_type: 'OUTBOUND',
    },
  },
  {
    headers: {
      Authorization: 'Bearer <token>',
      'x-tenant-id': '<tenant-id>',
    },
  }
);

Response 201 Created

{
  "id": "770e8400-e29b-41d4-a716-446655440000",
  "activityId": "ee0e8400-e29b-41d4-a716-446655440000",
  "source": "RETEN_ACTIVITY",
  "resultStatus": "COMPLETED",
  "occurredAt": "2025-01-16T14:30:00.000Z",
  "taskDetails": {
    "result": "success",
    "comment": "Order placed successfully",
    "contactType": "OUTBOUND"
  },
  "createdAt": "2025-01-16T14:30:05.000Z",
  "updatedAt": "2025-01-16T14:30:05.000Z"
}

Notes

  • If activity_id or provider_activity_id matches an existing activity, source is RETEN_ACTIVITY
  • If no activity is found, source is STANDALONE
  • For standalone results, a placeholder commerce is auto-created if needed
  • Updates enforce temporal guard (occurred_at must be after existing result's updatedAt)
  • The parent activity's status is synced based on the result status

Error Responses

StatusDescription
400Validation error — invalid or missing fields
401Missing or invalid authentication token
404Activity not found (when activity_id is provided)
409Stale event — occurred_at is older than existing result
409Invalid state transition (unless hard_override: true)