Skip to main content

Compensations

The Compensations router generates and tracks compensation plans for external actions that may need to be undone after a memory rollback. When you roll back memory state, Novyx scans trace ACTION steps in the rollback window and produces a reverse-chronological list of external actions to undo, with per-action acknowledgment tracking.

Base URL: https://novyx-ram-api.fly.dev

Tier: Pro+ (requires trace audit capability)


Preview Compensation Plan

POST /v1/compensations/preview

Generate a compensation plan for a time range. Scans trace ACTION steps between rollback_to and rollback_from and returns a list of external actions that may need to be undone, in reverse chronological order. The plan is persisted for tracking.

Request body

ParameterTypeRequiredDescription
rollback_fromstringYesISO 8601 timestamp: start of window (usually now)
rollback_tostringYesISO 8601 timestamp: rollback target

Response fields

FieldTypeDescription
compensation_idstringCompensation plan identifier
statusstringPlan status (pending, in_progress, completed)
rollback_fromstringWindow start
rollback_tostringWindow end
actionsarrayCompensation actions to perform (reverse chronological)
created_atstringISO 8601 timestamp

Each action includes:

FieldTypeDescription
indexnumberAction index within the plan
trace_idstringSource trace identifier
descriptionstringWhat needs to be undone
connectorstringConnector involved (github, slack, etc.)
statusstringpending, completed, failed, or skipped

Examples

from novyx import Novyx

nx = Novyx(api_key="nram_your_key")

plan = nx.compensation_preview(
rollback_from="2026-03-15T14:00:00Z",
rollback_to="2026-03-15T12:00:00Z"
)
print(f"Compensation ID: {plan['compensation_id']}")
print(f"Actions to undo: {len(plan['actions'])}")
for action in plan["actions"]:
print(f" [{action['connector']}] {action['description']}")

Response

{
"compensation_id": "comp_a1b2c3d4",
"status": "pending",
"rollback_from": "2026-03-15T14:00:00Z",
"rollback_to": "2026-03-15T12:00:00Z",
"actions": [
{
"index": 0,
"trace_id": "trace_xyz",
"description": "Revert Slack message posted to #deployments",
"connector": "slack",
"status": "pending"
},
{
"index": 1,
"trace_id": "trace_abc",
"description": "Close GitHub PR #42 that was auto-merged",
"connector": "github",
"status": "pending"
}
],
"created_at": "2026-03-15T14:05:00Z"
}

Errors

StatusCodeCause
403feature_not_availableRequires Pro or Enterprise plan

List Compensation Plans

GET /v1/compensations

List compensation plans for the current tenant.

Query parameters

ParameterTypeRequiredDefaultDescription
limitnumberNo20Max results (1-100)

Response fields

Returns an array of compensation plan objects (same structure as the preview response).

Examples

plans = nx.list_compensations(limit=10)
for plan in plans:
pending = sum(1 for a in plan["actions"] if a["status"] == "pending")
print(f"{plan['compensation_id']}: {pending} actions pending")

Errors

StatusCodeCause
403feature_not_availableRequires Pro or Enterprise plan

Get Compensation Plan

GET /v1/compensations/{compensation_id}

Get a compensation plan with all actions and their current statuses.

Path parameters

ParameterTypeDescription
compensation_idstringCompensation plan identifier

Examples

plan = nx.get_compensation("comp_a1b2c3d4")
for action in plan["actions"]:
print(f" [{action['status']}] {action['description']}")

Errors

StatusCodeCause
404compensation.not_foundCompensation plan not found

Acknowledge Action

PATCH /v1/compensations/{compensation_id}/actions/{action_index}

Mark a compensation action as completed, failed, or skipped. When all actions in a plan are acknowledged, the plan status automatically changes to completed.

Path parameters

ParameterTypeDescription
compensation_idstringCompensation plan identifier
action_indexnumberZero-based index of the action within the plan

Request body

ParameterTypeRequiredDescription
statusstringYesAction outcome: completed, failed, or skipped
detailstringNoOptional detail about the outcome (max 500 characters)

Response fields

Returns the updated compensation plan with all actions and their statuses.

Examples

# Mark the first action as completed
result = nx.acknowledge_compensation(
"comp_a1b2c3d4",
action_index=0,
status="completed",
detail="Slack message deleted successfully"
)

# Skip an action that can't be undone
result = nx.acknowledge_compensation(
"comp_a1b2c3d4",
action_index=1,
status="skipped",
detail="PR was already reverted by another process"
)

Errors

StatusCodeCause
404compensation.not_foundCompensation plan or action index not found
403feature_not_availableRequires Pro or Enterprise plan