Skip to content

Approvals

One approval engine serves every product: expenses, leave, timesheets and more land in the same inbox. The approval endpoints need no product of their own; each decision checks the record’s product and that the task is yours. Full details: Approvals API.

Recipe: approve from a chat bot

List what waits for you:

Terminal window
curl -s "$OPEX/api/approvals/inbox" -H "X-API-Key: $OPEX_API_KEY" \
| jq '{items: [.items[] | {taskId, instanceId, product, title, requesterName, stageName, rev}]}'
{
"items": [
{
"taskId": "f138717f-b73d-4d5c-96fc-93070828a9b7",
"instanceId": "60e3aa79-1fcb-46be-8775-7be3cb0bdd78",
"product": "expenses",
"title": "Expense Grab from Budi Santoso",
"requesterName": "Budi Santoso",
"stageName": "Project manager approval",
"rev": 0
},
{
"taskId": "df3142c7-6855-4339-ac0d-4bc521a6ace5",
"instanceId": "f308531f-81a3-4edc-89c6-bf412d1d30b5",
"product": "leave",
"title": "Annual leave for Budi Santoso",
"requesterName": "Budi Santoso",
"stageName": "Approval",
"rev": 0
}
]
}

Decide one task:

Terminal window
curl -s -X POST "$OPEX/api/approvals/tasks/f138717f-b73d-4d5c-96fc-93070828a9b7/decide" \
-H "X-API-Key: $OPEX_API_KEY" -H "content-type: application/json" \
-d '{"decision":"approved","comment":"Approved, enjoy the trip"}'
{
"instanceId": "60e3aa79-1fcb-46be-8775-7be3cb0bdd78",
"status": "pending",
"currentStage": 1,
"outcome": "advanced"
}

outcome tells you what your decision did: recorded (the stage needs more approvers), advanced (on to the next stage, here admin validation), or approved / rejected (the request is decided). Use "decision":"rejected" to reject.

Sending the same decision again, or deciding a task someone else already settled, answers 409:

{ "error": "approval_conflict" }

Treat it as “already handled”: refresh the inbox and move on.

Recipe: show where a request stands

Terminal window
curl -s "$OPEX/api/approvals/instances/60e3aa79-1fcb-46be-8775-7be3cb0bdd78" -H "X-API-Key: $OPEX_API_KEY" \
| jq '{status, definitionName, stages: [.stages[] | {name, status}]}'
{
"status": "pending",
"definitionName": "Standard expense approval",
"stages": [
{ "name": "Project manager approval", "status": "approved" },
{ "name": "Admin validation", "status": "pending" },
{ "name": "Country Manager approval", "status": "upcoming" }
]
}

Expenses and leave requests carry their approval_instance_id, so you can link from a record to its timeline.