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

# API key actions

> Request parameters and responses for api key actions.

All paths are relative to the [base URL](/api-reference/trading/overview). See [authentication](/api-reference/trading/authentication) and [errors and idempotency](/api-reference/trading/errors).

## Register a wallet-signed API grant

`POST /v1/api-keys`

Requires the main account owner’s EIP-712 signature. Copy-wallet key creation is rejected with `main_account_required`; non-mainnet grants are rejected with `mainnet_required`.

### Request body

| Field                   | Type    | Required | Details                     |
| ----------------------- | ------- | -------- | --------------------------- |
| `consent`               | object  | Yes      |                             |
| `consent.account`       | string  | Yes      | Format: `uuid`              |
| `consent.network`       | string  | Yes      | `hyperliquid_mainnet`       |
| `consent.key_hash`      | string  | Yes      |                             |
| `consent.policy`        | object  | Yes      |                             |
| `consent.policy.scopes` | array   | Yes      |                             |
| `consent.issued_at`     | integer | Yes      | Maximum: `8640000000000000` |
| `consent.expires_at`    | null    | No       | Default: `null`             |
| `signature`             | string  | Yes      |                             |

### Example request

```bash theme={null}
curl -X POST "$LEGEND_API_BASE/v1/api-keys" \
  -H "Content-Type: application/json" \
  --data @signed-request.json
```

### Response

| Field        | Type           | Required | Details   |
| ------------ | -------------- | -------- | --------- |
| `object`     | string         | Yes      | `api_key` |
| `account`    | string         | Yes      |           |
| `network`    | string         | Yes      |           |
| `key_hash`   | string         | Yes      |           |
| `scopes`     | array          | Yes      |           |
| `expires_at` | string or null | Yes      |           |

See the [OpenAPI schema](/api-reference/trading/openapi.json) for nested response objects and validation patterns.

Illustrative successful response:

```json theme={null}
{
  "object": "api_key",
  "account": "00000000-0000-4000-8000-000000000001",
  "network": "hyperliquid_mainnet",
  "key_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "scopes": [
    "trading:read",
    "trading:write"
  ],
  "expires_at": null
}
```

## Revoke a key with the account owner signature, including before registration

`POST /v1/api-keys/revoke`

Requires the account owner’s EIP-712 signature.

### Request body

| Field       | Type   | Required | Details        |
| ----------- | ------ | -------- | -------------- |
| `account`   | string | Yes      | Format: `uuid` |
| `key_hash`  | string | Yes      |                |
| `signature` | string | Yes      |                |

### Example request

```bash theme={null}
curl -X POST "$LEGEND_API_BASE/v1/api-keys/revoke" \
  -H "Content-Type: application/json" \
  --data @signed-request.json
```

### Response

| Field      | Type    | Required | Details   |
| ---------- | ------- | -------- | --------- |
| `object`   | string  | Yes      | `api_key` |
| `key_hash` | string  | Yes      |           |
| `revoked`  | boolean | Yes      | `True`    |

See the [OpenAPI schema](/api-reference/trading/openapi.json) for nested response objects and validation patterns.

Illustrative successful response:

```json theme={null}
{
  "object": "api_key",
  "key_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "revoked": true
}
```
