> ## 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.

# API Conventions

> Authentication, environments, pagination, idempotency, rate limiting, and error handling.

This page covers the conventions shared across all Portfolio Wallet API endpoints.

## Asset IDs

Read shared catalog UUIDs from [List assets](https://docs.groundtech.co/api-reference/list-assets-v3.md). Holdings use `assetId`; manual movements use `fromAssetId` and `toAssetId`. The wallet ID supplies ownership context. [Balances and Yield](https://docs.groundtech.co/v3/docs/portfolio-wallets/balances-and-yield.md) explains actual holdings versus strategy targets.

## Base path

Wallet resources use the `/v3/wallets` path prefix. Supporting APIs use their own `/v3/*` prefixes, including `/v3/activity`, `/v3/accounting`, `/v3/webhooks`, `/v3/address-book`, `/v3/approvals`, and `/v3/system`.

## Authentication

Protected endpoints require a Bearer token in the `Authorization` header. A missing or invalid token returns `401`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X GET "https://sandbox.groundtech.co/v3/wallets" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

A successful request returns `200`. See [List wallets](https://docs.groundtech.co/v3/api-reference/list-wallets.md) for complete response examples.

## Environments

Use separate keys and base URLs for sandbox test funds and production live funds; see [API-key setup](https://docs.groundtech.co/v3/docs/overview/reach-the-api.md). Network identifiers and available assets differ. Use the [Supported Chains](https://docs.groundtech.co/v3/docs/portfolio-wallets/supported-chains.md) matrix to select the token, network key, and test funding source.

## Pagination

Paginated endpoints such as wallet and withdrawal lists use `limit` and `cursor`. Finite catalogs such as [List assets](https://docs.groundtech.co/api-reference/list-assets-v3.md) return all visible entries without pagination. Check each endpoint for its list envelope and limits.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X GET "$BASE_URL/v3/wallets/$WALLET_ID/withdrawals?limit=25" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

The response includes a `nextCursor` field. Pass it as `cursor` to fetch the next page:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X GET "$BASE_URL/v3/wallets/$WALLET_ID/withdrawals?limit=25&cursor=$NEXT_CURSOR" \
  -H "Authorization: Bearer $GROUND_API_KEY"
```

When `nextCursor` is `null`, you have reached the end of the result set.

Endpoint-specific filters, sort options, limits, and status semantics vary by endpoint. Treat each API reference page's parameter table as authoritative for that endpoint.

## Idempotency

Create and withdrawal endpoints accept a `requestId` (UUID v4). These endpoints return **`200 OK`** for both the initial request and an idempotent replay with the same `requestId` — the existing resource state is returned on replay.

Persist the `requestId` and payload before submitting each logical wallet creation or withdrawal. Reuse them unchanged after a timeout; reusing the ID with a different payload returns `409 request_id_conflict`.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "$BASE_URL/v3/wallets" \
  -H "Authorization: Bearer $GROUND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "requestId": "f0a3afc3-1e67-4c0c-a8e1-3f5d8fb9a23b",
  "label": "Core Yield Portfolio",
  "strategy": {
    "allocations": {
      "usdc:crosschain": [
        {
          "assetId": "03389041-80ad-4dcf-8fe2-3536bcfe92db",
          "targetWeightPct": 40
        },
        {
          "assetId": "80f900d0-a4b8-4c97-bdc2-8e2ab5228e19",
          "targetWeightPct": 30
        },
        {
          "assetId": "6c6c676a-4111-472b-b29c-3e7e00d1a49c",
          "targetWeightPct": 30
        }
      ],
      "usdt:ethereum": [
        {
          "kind": "cash",
          "targetWeightPct": 100
        }
      ]
    }
  }
}'
```

For example, changing the allocations while reusing the same `requestId` returns:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "error": "requestId has already been used with a different payload",
  "code": "request_id_conflict",
  "details": "The requestId 1f1c3b2a-0000-4000-8000-000000000001 was first used with a different allocation."
}
```

When you receive `409 request_id_conflict`, recover the original wallet through `GET /v3/wallets?requestId=...` or read the original withdrawal by its saved ID. If the withdrawal ID was lost, replay the original persisted payload with its original `requestId`. Correct the local operation mapping before deciding whether to begin a separate request.

## Rate limiting

Each API key can make up to **300 authenticated requests per minute** across the API. Every request counts toward this overall limit. Endpoints with a lower limit must also stay within their listed limit.

Rate limits use two limit types:

* **Per API key** — one allowance is shared by all calls to that endpoint using the API key.
* **Per API key, per wallet** — each wallet gets its own allowance under the API key. For example, you can update Wallet A five times and Wallet B five times in the same minute. Both wallets' calls still count toward the API key's overall 300-request limit.

| Endpoint | Requests allowed | Limit type |
| - | - | - |
| All authenticated `/v3/*` endpoints | 300 per minute | Per API key |
| `GET /v3/activity` | 10 per minute | Per API key |
| `GET /v3/activity?walletId={walletId}` | 10 per minute | Per API key, per wallet |
| `GET /v3/accounting/activity` | 10 per minute | Per API key |
| `GET /v3/accounting/yield/period-summary` | 10 per minute | Per API key |
| `GET /v3/wallets/overview` | 30 per minute | Per API key |
| `GET /v3/wallets/{id}` | 30 per minute | Per API key, per wallet |
| `GET /v3/wallets/{id}/yield` | 30 per minute | Per API key, per wallet |
| `POST /v3/wallets` | 5 per minute | Per API key |
| `PATCH /v3/wallets/{id}/strategy` | 5 per minute | Per API key, per wallet |
| `POST /v3/wallets/{id}/allocate-preview` | 10 per minute | Per API key, per wallet |
| `POST /v3/wallets/{id}/allocate` | 5 per minute | Per API key, per wallet |
| `POST /v3/wallets/{id}/withdrawal-preview` | 10 per minute | Per API key, per wallet |
| `POST /v3/wallets/{id}/withdrawals` | 5 per minute | Per API key, per wallet |
| `POST /v3/webhooks` | 10 per minute | Per API key |
| `DELETE /v3/webhooks/{id}` | 10 per minute | Per API key |
| `POST /v3/address-book/entries` | 30 per minute | Per API key |
| `DELETE /v3/address-book/entries/{id}` | 30 per minute | Per API key |

If you exceed a limit, the API returns `429 Too Many Requests`. The `Retry-After` header tells you how many seconds to wait. Wait at least that long, add a small random delay, and then try again.

## Error handling

Business API errors are returned as JSON with a human-readable `error` string and a machine-readable `code` field.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "error": "Missing required fields: destinationAddress, amountUsd, destinationChain, requestId",
  "code": "validation_error"
}
```

| HTTP status | Meaning | Action |
| - | - | - |
| `400` | Validation error | Fix the request and retry |
| `401` | Authentication failed | Check your Bearer token |
| `404` | Resource not found | Verify the wallet/withdrawal ID |
| `409` | Conflict, such as a changed replay payload (`request_id_conflict`) or unavailable funds | Read the endpoint-specific error code and current resource before retrying |
| `429` | Rate limited | Wait for `Retry-After`, add a small random delay, and try again |
| `500` | Server error | Log the response and retry with backoff |

Business API errors include both `error` and `code` fields. Authentication middleware can return `{ "error": "...", "message": "..." }` before the request reaches a business handler. Use `code` for programmatic branching when it is present, and use the `error` string for logging and debugging.


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