Retivo

External Actions API

Register action types, dispatch actions, report outcomes, push custom events, and get recommendations

Action Types

Register Action Type

POST /api/external/action-types

Register what your external system can do. Returns a webhook_secret for verifying dispatches (only shown once).

FieldTypeRequiredDescription
namestringYesMachine-readable name (snake_case, e.g., grant_points)
descriptionstringYesHuman-readable description for the AI decision engine
providerstringYesYour platform identifier
parameters_schemaobjectYesJSON Schema for the action's parameters
delivery_webhookstringYesURL where Retivo sends dispatched actions
domainstringNoCategory tag (e.g., loyalty, gamification)
estimated_cost_usdstringNoCost per execution for budget tracking

Response (201):

{
  "action_type": {
    "id": "at_abc123",
    "name": "grant_points",
    "webhook_secret": "64-char-hex-string"
  }
}

List Action Types

GET /api/external/action-types?provider=smile-io&domain=loyalty&active=true

Update Action Type

PUT /api/external/action-types/{id}

Deactivate Action Type

DELETE /api/external/action-types/{id}

Soft-delete — sets active to false.


Actions (Dispatch Log)

List Actions (Pull Reconciliation)

GET /api/external/actions?status=dispatched&since=2026-04-25T00:00:00Z&limit=50
ParamTypeDescription
statusstringFilter: pending, dispatched, delivered, completed, failed, expired
providerstringFilter by provider
user_idstringFilter by user
sincestringISO-8601 timestamp — only actions after this time
limitnumberMax results (1-100, default 50)

Report Outcome

POST /api/external/actions/{actionId}/outcome
FieldTypeRequiredDescription
statusstringYescompleted, ignored, rejected, or partial
resultobjectNoArbitrary result data from your system

Response (200):

{
  "recorded": true,
  "action_id": "ea_xyz789",
  "outcome_status": "completed"
}

Returns 409 if an outcome was already reported for this action.


Custom Events

Push Events (Batch)

POST /api/external/events

Push up to 100 custom events. Events are broadcast to webhook subscribers AND ingested into the data pipeline.

{
  "events": [
    {
      "type": "custom.reward.redeemed",
      "user_id": "user-123",
      "data": { "reward_type": "discount", "value": 20 },
      "timestamp": "2026-04-26T10:30:00Z"
    }
  ]
}

Event types must use the custom. prefix with lowercase dot notation.

Push Single Event

POST /api/external/events/emit

Same fields as a single event in the batch endpoint.


Recommendations

Get Recommendation

POST /api/decisions/recommend

Ask Retivo what your system should do for a specific user.

FieldTypeRequiredDescription
user_idstringYesTarget user
domainstringNoScope to domain (e.g., loyalty)
available_actionsstring[]YesAction types your system can execute
contextobjectNoExtra context from your system

Response:

{
  "user_id": "user-123",
  "domain": "loyalty",
  "recommendation": {
    "action": "grant_points",
    "parameters": { "amount": 300 },
    "confidence": 0.82,
    "reasoning": "User hasn't redeemed in 14 days..."
  },
  "alternatives": [...],
  "user_context": {
    "lifecycle_stage": "active",
    "activation_score": 72,
    "engagement_score": 45,
    "risk_level": "medium"
  }
}

Pre-Built Platform Connectors

List Platforms

GET /api/external/platforms

Returns all available pre-built connectors and their connection status.

Connect Platform

POST /api/external/platforms/{platformId}/connect

Auto-registers action types from the platform's template.

{
  "credentials": {
    "api_key": "sk_live_..."
  }
}

Disconnect Platform

POST /api/external/platforms/{platformId}/disconnect

Webhook Dispatch Format

When Retivo dispatches an action, your delivery_webhook receives:

{
  "action_id": "ea_xyz789",
  "action_type": "grant_points",
  "user_id": "user-123",
  "parameters": { "amount": 500, "reason": "re-engagement bonus" },
  "reasoning": "User completed onboarding but hasn't engaged since",
  "confidence": "0.82",
  "tenant_id": "tenant-uuid",
  "timestamp": "2026-04-26T10:30:00Z"
}
HeaderDescription
X-Retivo-SignatureHMAC-SHA256 hex digest of the body
X-Retivo-TimestampISO-8601 dispatch time
X-Retivo-Action-IdUnique action ID for idempotency

Retry schedule: 30s → 2m → 10m → 30m → 2h (5 retries max).

Permissions

EndpointRequired Permission
Action type CRUDmanage or full
Report outcomemanage or full
Push eventsingest or full
Get recommendationdecide or full
List actionsread or full
Platform connect/disconnectAdmin role

On this page