> ## Documentation Index
> Fetch the complete documentation index at: https://docs.groundtech.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Transaction Approvals

> How organization approvals work, when they are required, and what to verify before signing.

Portfolio wallet operations can require cryptographic approval before execution. When that happens, Ground creates a signing activity and exposes it through the Ground Portal and Ground approval API.

> [!NOTE]
>
> Sign approvals with your registered passkey or machine key. Ground receives the signature, never your private signing key.

## Set up a signer

A Ground API key authenticates API requests. A customer passkey or registered machine signing key produces the cryptographic approval stamp for Portfolio Wallet activities. Configure both when the selected workflow requires customer approval. MicroVault shareholders and gToken holders instead use their wallet signers for their onchain transactions and ownership proofs; a Portal machine signing key does not replace those wallets.

### Enroll a signer

1. Open [Settings → Signing](https://portal.groundtech.co/dashboard/settings?tab=policies). Confirm the organization and **Sandbox** environment. Sandbox signers, keys, and quorum settings are separate from production.
2. Enroll an active signer using the appropriate path:

   * **No customer signers:** the organization owner selects **Enable signing**,
     chooses **Password manager** or **Hardware key**, and completes passkey
     creation. Review and authorize the change to your organization's signing authority.
   * **Existing signers:** an active signer opens **Signers → Add signer**, selects
     an eligible organization admin, and clicks **Invite**. The invitee selects
     **Create signing key** and completes the passkey ceremony. The inviter then
     selects **Finalize** and approves the enrollment with their passkey.

   A passkey awaiting finalization is not an active signer.
3. For human approval, retain the passkey flow and use [Approvals](https://portal.groundtech.co/approvals) to review pending activities. For backend approval, an active signer sees **Machine Signing Keys** on the Signing page. Click **Add machine key**.
4. Enter **Key name**. The browser generates a P-256 keypair and displays **Private key (PEM, save now)** and **Public key (hex)**. Save the private PEM in the backend's secret store and retain its matching public hex key. Check **I have saved the private key in a secure location.**, click **Register key**, and authorize registration with your passkey. Confirm the public key appears in the machine-key table before using it.
5. Follow [Transaction Approvals](https://docs.groundtech.co/v3/docs/portfolio-wallets/transaction-approvals.md) to fetch the matching pending activity, verify the transaction, obtain `signingRequest`, sign it locally, and submit the vote. Use the key-format instructions there when loading the Portal's PEM export. Continue tracking the withdrawal until receiver delivery.
6. For production, select **Production** on the same [Signing page](https://portal.groundtech.co/dashboard/settings?tab=policies) and complete the required enrollment and key registration for that environment. Check the production quorum; registering a machine key does not bypass it.

A machine key acts as its human signer's identity with the same authority and quorum requirements. Authorize its use for the intended automation. The private key is shown only during generation and is never submitted to Ground. If it was not saved, cancel before registration and generate a new pair; an already registered key with a lost private key must be replaced through the Signing page.

## When approvals happen

> [!NOTE]
>
> **Set up signing before you need to withdraw.** In production, a request that
> would take your organization's cumulative withdrawals above $200 returns   `withdrawal_signing_required` until an organization owner enables signing and
>     enrolls a signer. Exactly $200 is allowed without signing. The total includes
> pending withdrawals across all organization wallets; cancelled and failed
> withdrawals do not count. Set up signing in
> [Ground Portal → Settings → Signing](https://portal.groundtech.co/dashboard/settings?tab=policies).

* **Withdrawals** (`POST /v3/wallets/{id}/withdrawals`): when signing is enabled, each payout leg transitions to `pending_customer_approval` when it's ready for signing.

At most one approval can be outstanding per `walletId + chain`. If multiple activities become ready on the same chain, later activities queue behind the earlier approval automatically.

## Approving a signing policy change

For an existing organization, Ground can remove its own policy-editing
permissions using its existing authority. That one-time removal does not require
your signature or change your root signers. After removal, policy changes require
your configured root quorum through the flow below.

Ground may ask your organization to approve a policy change when enabling a new
chain or a new transaction route. A policy approval is separate from approving
an individual withdrawal. It is effective only after your root quorum approves it and the change completes.

1. In the Portal **Approvals** tab, select the policy change row in **Pending Activities**
   to open its details in the side drawer. Review the current policy and proposed policy for each
   step. The Portal checks the live policy and your signer eligibility before
   offering the approval action for the current step. Technical verification fingerprints are
   available under **Technical verification details** inside the exact policy change.
2. Each configured root signer opens the same proposal, reviews the full request,
   and selects **Begin signing**. The drawer guides them through each remaining
   signature, naming the policy being signed and marking applied changes complete. The drawer
   shows who has approved and how many more approvals are needed. Your first
   signature counts toward quorum; each root user counts once. A machine
   root signer can use the activity-approval API with the
   displayed activity ID. Those votes also appear in the proposal details.
3. Sign each change when prompted. If more root approvals are required, the
   drawer waits for quorum before advancing. You can close it and return to
   continue from the current change. After the proposal is applied, it appears as a **Completed** row in
   **Completed Activities**. Select the row to open a side pane with its explanation, signer
   votes and exact policy changes. Then poll the wallet or feature status again.

## Exporting your signing policies

If signing policy export is enabled for your organization, open
**Settings → Signing → Signing policy export** and select
**Export signing policies**. The JSON download contains a timestamp, your
organization and signing-account IDs, the current root quorum, and the current
policy names, IDs, effects, conditions, consensus rules and notes. Keep this
snapshot with your organization's signing records; it contains no private keys.

When export is being enabled through a policy proposal, the export control
appears after every step is approved and verified. Partial approvals and
rejected proposals leave it unavailable. If an export fails, retry; contact
Ground if the failure persists.

## Detecting a pending approval

When a withdrawal payout needs approval, `payoutLegs[].status` and the external payout step `state` become `pending_customer_approval`. Poll `GET /v3/wallets/:id/withdrawals/:withdrawalId` or subscribe to `portfolio_wallet.withdrawal.status_changed` to detect this state.

After detecting a pending payout, call `GET /v3/approvals/pending` to fetch the approval details for the authenticated organization. Match payout approvals with `activityKind: "external_payout"` and the expected `withdrawalId`.

## Approving an activity

1. Fetch the matching activity from `GET /v3/approvals/pending`.
2. [Verify its transaction details](#verify-before-you-approve).
3. Prepare the approval with `POST /v3/approvals/{activityId}/prepare`.
4. Sign the returned `signingRequest` with your registered signing key.
5. Submit `customerApprovalStamp` to `POST /v3/approvals/{activityId}/vote`.

Processing continues once the required number of customers approve. Your passkey
and machine keys count as the same customer.

Enable signing and register a machine key in
[Settings → Signing](https://portal.groundtech.co/dashboard/settings?tab=policies).
Your API key authenticates requests; your signing key authorizes activities.
Keep them separate and never send your private signing key to Ground.

Fetch the activity from `GET /v3/approvals/pending`, verify its amount,
recipient, chain, and token, then use its `activityId` unchanged. The example below
prepares and submits a vote using a registered P-256 machine key. Set `BASE_URL`,
`GROUND_API_KEY`, `ACTIVITY_ID`, and `SIGNING_KEY_PATH` (the exported PEM file).
`ACTION` defaults to `approve`; use `reject` to reject the activity.

```javascript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { readFile } from "node:fs/promises";
import { createPrivateKey, createPublicKey, sign } from "node:crypto";

const { BASE_URL, GROUND_API_KEY, ACTIVITY_ID, SIGNING_KEY_PATH } = process.env;
const action = process.env.ACTION || "approve";
async function post(path, body) {
  const response = await fetch(`${BASE_URL}${path}`, {
    method: "POST",
    headers: { Authorization: `Bearer ${GROUND_API_KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify(body),
  });
  const payload = await response.json();
  if (!response.ok) throw new Error(payload.error || `HTTP ${response.status}`);
  return { httpStatus: response.status, ...payload };
}

const prepared = await post(`/v3/approvals/${encodeURIComponent(ACTIVITY_ID)}/prepare`, { action });
if (action === "approve" && !prepared.signingRequest) throw new Error("Missing signing request");
let customerApprovalStamp;
const request = prepared.signingRequest;
if (request) {
  if (request.version !== 1) {
    throw new Error("Unsupported signing request");
  }
  const key = createPrivateKey(await readFile(SIGNING_KEY_PATH));
  customerApprovalStamp = {
    version: 1,
    context: request.context,
    publicKey: createPublicKey(key).export({ type: "spki", format: "der" }).toString("base64"),
    signature: sign("sha256", Buffer.from(request.payload, "base64"), key).toString("base64"),
  };
}
const result = await post(`/v3/approvals/${encodeURIComponent(ACTIVITY_ID)}/vote`, {
  action, customerApprovalStamp,
});
console.log(result);
```

Version 1 uses P-256 with SHA-256, a base64 payload, and a base64 DER signature.
Sign the decoded bytes unchanged. Do not serialize the JSON again or pre-hash
it before calling `sign("sha256", ...)`. Return `context` unchanged. Prepare
again after five minutes; existing votes remain on the same activity.

For passkeys, the Portal handles signing. Custom browser integrations use the
returned `signingRequest.webauthn.challenge` unchanged with user verification
required. Submit `version`, `context`, and a `webauthn` object containing
`credentialId`, `authenticatorData`, `clientDataJSON`, and `signature`, each encoded
as base64url, in `customerApprovalStamp`.

Votes return HTTP `202` while pending or processing and `200` when
terminal. `approvalProgress` counts distinct customers; a person's passkey and
machine key count as one vote. Partially approved activities stay pending.
`currentUserApproved: true` means your vote is recorded. The pending list returns
`approvalStatus: null` and `canApprove: false` when status cannot be verified.
A null progress count means the count is unknown, not zero.

Prepare rejections too. When `signingRequest` is null, submit only
`{ action: "reject" }`; otherwise sign normally. A submitting transaction cannot
be cancelled. Refresh the activity list after a `409`; a replacement payout needs
fresh approvals. If preparation returns `503`, retry when status is available.
Approval completion is separate from payout settlement—monitor the withdrawal
until it completes.

## Verify before you approve

> [!WARNING]
>
> Never blindly approve an activity. Always verify the transaction details match what you expect before signing.

When your system receives a pending approval, verify the activity before signing. Once an approved transaction is broadcast, it cannot be reversed.

### Withdrawal payouts

1. **Destination address** -- confirm the pending activity's `destinationAddress` matches the address your system originally submitted in the withdrawal request. Reject it if the address does not match.
2. **Amount** -- confirm the displayed amount is reasonable for the withdrawal and yield source. Asynchronous sources may not exactly match the originally requested amount.
3. **Chain and token** -- confirm `destinationChain` and `destinationToken` match your request, including the exact sandbox network. Validate the destination using the network's [address format](https://docs.groundtech.co/v3/docs/portfolio-wallets/supported-chains.md#network-keys-and-address-formats).
4. **Withdrawal correlation** -- match the pending approval to a withdrawal your system initiated. Reject orphaned, expired, or unexpected approvals.

Compare validated EVM addresses using their canonical form. Compare Solana, Stellar, and TRON addresses exactly; never lowercase base58 addresses. Match the withdrawal ID, network, token, and receiver to your persisted request. Check the actual payout against your approved gross amount, fees, and acceptable realized-proceeds bounds before signing.

After verification, use the prepare, local-sign, and vote procedure above.

## Automation patterns

Use withdrawal webhooks as the primary trigger and periodic reads
as a backstop. For either trigger, fetch the current approval, verify it, and
follow the prepare/sign/vote procedure above. An event alone never authorizes a vote.

## Status updates

Subscribe to these events to monitor progress:

* `portfolio_wallet.withdrawal.status_changed`
* `portfolio_wallet.withdrawal.payout.status_changed`
* `portfolio_wallet.approval.status_changed`

If approval-related execution fails, the withdrawal eventually moves to `failed` with a `failureReason`.

Approval authorizes signing. Continue tracking each payout and its withdrawal until `completed`; see [Withdraw Funds](https://docs.groundtech.co/v3/docs/portfolio-wallets/withdraw-funds.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.