Approvals

An Approval is a sign-off gate. It blocks the associated task or workflow from progressing until an authorized person approves or rejects it. Use approvals for compliance checkpoints, legal reviews, or any step where a human decision is required before work continues.

When to use client.approvals

  • Requiring a manager to sign off before an offer letter goes out
  • Gating artifact acceptance (e.g., a contract must be approved before the deal closes)
  • Building compliance workflows where every step requires documented approval
  • Creating human-in-the-loop AI workflows where an agent's output needs review

Methods

MethodDescription
create(input)Create an approval request
list(opts?)List approvals in a project
approve(approvalId, input?)Approve the request
reject(approvalId, input?)Reject the request

approvals.create(input)

Parameters

ParameterTypeRequiredDescription
taskIdstringnoGate a specific task
artifactIdstringnoGate a specific artifact
instanceIdstringnoGate a workflow instance
requiredRoleIdstringnoOnly actors with this role can approve
requestedByActorIdstringnoWho is requesting approval
reasonstringnoExplanation shown to the approver
typescript
const { data: approval } = await client.approvals.create({
  taskId: 'tsk_abc123',
  reason: 'Contract requires legal sign-off before countersigning',
  requiredRoleId: 'role_legal',
})
 
console.log(approval.id, approval.status) // appr_... 'pending'

approvals.approve(approvalId, input?)

typescript
await client.approvals.approve('appr_abc123', {
  decidedByActorId: 'actor_alice',
  reason: 'Reviewed and approved — all terms acceptable',
})

approvals.reject(approvalId, input?)

typescript
await client.approvals.reject('appr_abc123', {
  decidedByActorId: 'actor_alice',
  reason: 'Clause 7 needs revision — see comments in the document',
})

Building an approval inbox

typescript
// Fetch all pending approvals for a project
const { data: pending } = await client.approvals.list({ projectId: 'proj_xyz' })
const pendingApprovals = pending.filter(a => a.status === 'pending')
 
for (const approval of pendingApprovals) {
  console.log(`Approval needed: ${approval.reason}`)
  console.log(`Task: ${approval.taskId}`)
}

Type reference

typescript
type ApprovalStatus = 'pending' | 'approved' | 'rejected'
 
interface Approval {
  id: string
  projectId: string
  executionId: string | null
  instanceId: string | null
  taskId: string | null
  artifactId: string | null
  requiredRoleId: string | null
  requestedByActorId: string | null
  decidedByActorId: string | null
  status: ApprovalStatus
  reason: string | null
  metadata: Record<string, unknown> | null
  createdAt: string
  decidedAt: string | null
}