# Integrate approval workflows

A policy can require multi-user approval for a mutation or signing request. Preserve the `request_id` returned with `202 Accepted`, then follow the [request lifecycle](/develop/signing/request-lifecycle). A pending request is not a completed result.

## Configure a policy

Use the [Administrative Policy](/guide/admin-policy/configure) or [Signing Policy](/guide/signing-policy/configure) editor to select an approval group, threshold, and expiry. API policy writers must supply all three fields of the `ExternalApproval` action:

```json
{
  "user_group_id": "treasury-approvers",
  "threshold": 2,
  "expires_in": 3600
}
```

This is the action's contents, not a complete policy update. Use the enclosing schema in the [API reference](/api-reference). `threshold` is 1 to 100; `expires_in` is seconds with a maximum of 2592000 (30 days). Choose a positive approval window for requests that need time for review.

## Find requests awaiting your decision

Set `CV_BASE` and `CV_TOKEN` to your vault URL and complete Authorization value, such as `ApiKey <uuid>`:

```bash
curl --fail-with-body --silent --show-error --get \
  "$CV_BASE/v1/approval-requests" \
  -H "Authorization: $CV_TOKEN" \
  --data-urlencode 'scope=my_approval_requests' \
  --data-urlencode 'statuses=pending' \
  --data-urlencode 'limit=20'
```

Follow `next_cursor` to read more results. You can also filter by `request_ids`, `initiators`, and `kinds`. Review each request's operation details, approval group, threshold, expiry, and recorded votes before deciding.

## Submit a decision

1. Save the specific approval record you reviewed as `approval.json`.
2. Create the vote body below. Copy `operation_details.raw` unchanged into `request`; it binds your vote to the operation you reviewed.
3. Sign the **vote request** using your own [mutation authentication](/develop/authentication/machine-users). Compute `TS_HEX`, `NONCE_HEX`, and `ASSERTION` for the exact path and bytes in `vote.json`.
4. Submit the vote:

```bash
REQUEST_ID=$(jq -er '.request_id' approval.json)
jq '{decision: "approve", request: .operation_details.raw}' approval.json > vote.json

# After computing the authentication headers for this vote.json:
curl --fail-with-body --silent --show-error \
  -X POST "$CV_BASE/v1/requests/$REQUEST_ID/vote" \
  -H "Authorization: $CV_TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Request-Timestamp: $TS_HEX" \
  -H "X-Request-Nonce: $NONCE_HEX" \
  -H "X-Request-Assertion: $ASSERTION" \
  --data-binary @vote.json
```

Use `decision: "reject"` and an optional `reason` when rejecting. A successful vote returns `204 No Content`, so do not parse a JSON response. Poll `GET /v1/requests/{request_id}` for the original operation's outcome. Even an approved request may still be processing.

## Cancel a pending request

An initiator can call `POST /v1/requests/{request_id}/cancel` while their request is awaiting approval. Sign the POST with an empty body using the normal mutation headers. Cancellation is not available after the operation has proceeded.

## Receive notifications

Subscribe to `request.approval_required` through [approval webhooks](/develop/webhooks). Notifications help you discover work; a webhook acknowledgment is not a vote. Read the current request before presenting a decision because it may already have been approved, rejected, cancelled, or expired.

## Votes that race with approval

Once a request has been approved, a concurrent rejection or denial cannot change it to rejected or failed. A conflicting rejection from an eligible voter returns a conflict; an ineligible voter still receives the eligibility error. Read the request status to determine its outcome.
