# Access Keys

Arkiv’s public RPC is heavily rate limited to prevent abuse, so get a free access key from the [Arkiv Hub](https://hub.arkiv.network/access-keys). The key raises the rate limits on your calls.

- You get one key per wallet on each network.
- A key works on one network only. You choose the network when you create the key.
- Each key has a monthly quota, measured in cost units.

The SDK asks for a key when you connect to Rabdi. To try Arkiv without one, pass `accessKey: ""`: the SDK uses the public RPC and logs a warning.

<RpcTerms />

## Get a key

1. Open [hub.arkiv.network/access-keys](https://hub.arkiv.network/access-keys).

2. Connect your wallet and sign the sign-in message. The signature proves that you own the wallet. It does not send a transaction.

3. Complete your registration if the Hub asks for it.

4. Select the network. For the current public testnet, select **Rabdi**.

5. Give your project a name, solve the captcha, and select **Generate**.

The Hub shows your key on the page. Copy it with the copy button.

## Send the key with your requests

The RPC accepts the key in three forms. Use the one that fits your client.

| Form | How |
| ---- | --- |
| In the path | Append the key to the RPC URL: `https://rpc.rabdi.db-chain.testnet.arkiv.network/<key>` |
| `X-API-KEY` header | `X-API-KEY: <key>` |
| Bearer token | `Authorization: Bearer <key>` |

### HTTP

```bash
curl --json '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' \
  -H "X-API-KEY: <key>" \
  https://rpc.rabdi.db-chain.testnet.arkiv.network
```

### WebSocket

The WebSocket endpoint accepts the key in the path or in the `X-API-KEY` header.

```bash
wscat -c wss://rpc.rabdi.db-chain.testnet.arkiv.network/<key> \
  -x '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' \
  -w 1
```

## Use a key with the SDK

Pass the key to `rabdi`. Read it from an environment variable rather than writing it in code:

```ts
import { createPublicClient } from "@arkiv-network/sdk"
import { rabdi } from "@arkiv-network/sdk/chains"
import { http } from "viem"

const publicClient = createPublicClient({
  chain: rabdi({ accessKey: process.env.ARKIV_ACCESS_KEY ?? "" }),
  transport: http(),
})
```

`rabdi` puts the key at the end of both RPC URLs. So `http()` and `webSocket()` with no URL send it. Don’t add a chain with your key to a user’s wallet: the wallet keeps the URL and uses it for every app. [Add the chain without a key](https://stage.docs.arkiv.network/start-here/clients/#write-from-a-browser-wallet) instead.

Leaving out `accessKey` is a type error, and throws `MissingAccessKeyError` if it runs anyway. A key the RPC doesn’t know fails every call with HTTP status 401.
**Handle the key with care:** A key isn’t a password, but anyone who has it can spend your quota. In a web app, anyone can read it from the network requests, so add your site to the key’s **Origins**. On a server, add your server’s IP to the **IP allowlist**. See [lock the key down](#lock-the-key-down).

## Watch your quota

The **Usage** tab on the Hub shows the cost units you used this month, the RPC calls and requests made, and the date the quota resets. The counts can lag a few minutes behind live traffic.

When you reach the quota, the RPC can reject calls on that key. The Hub shows a warning when this happens.

If you need more, select **Request more quota** on the Usage tab and give a short reason. For very large quotas, use **Request even higher quota** to contact the team.

## Lock the key down

The Hub has two allowlists. Both are empty by default, which allows requests from anywhere.

- **Origins.** List the websites that can use the key from a browser. Non-browser clients can forge the `Origin` header, so treat this as attribution, not access control.
- **IP allowlist.** List the exact server IPs that can use the key. No CIDR ranges. Requests from other IPs are rejected, so this is real access control.

## Regenerate or delete a key

Both actions are on the key header in the Hub.

- **Regenerate** gives you a new key. The old key stops working at once. Update your integrations before you regenerate.
- **Delete** removes the key. This is permanent, but you can generate a new key afterwards.

## Get help

If your calls are rejected and you are not over quota, ask in [Discord](https://discord.gg/arkiv).