Browse documentation

Agents & API

Getting an API key

How keys work

An API key starts with oxk_ followed by 32 random bytes, base64url encoded. oxley stores only its SHA-256 hash, so a key is shown once, when it is issued. Copy it then.

Every call except issuing a key sends the key as Authorization: Bearer <key>.

  • Live keys An address can have at most 3 live keys.
  • Signatures Only signatures from externally owned accounts (EOAs) work for now.
  • Issuing Issuing is rate-limited per IP.

The message to sign

Sign this message with the wallet that will own the key, using EIP-191 personal_sign. Replace <address> with the signing address in its checksummed (EIP-55) form, and <ISO time> with the current time as JavaScript’s toISOString writes it, for example 2026-11-13T09:30:00.000Z.

The message is three lines separated by newlines. Send the same time as issuedAt in the request. It must be within 10 minutes of the server’s clock.

Message
Oxley API key
Address: <address>
Issued at: <ISO time>

POST /v1/keys

Send the address, the time and the signature as JSON. This is the one call that needs no key. The answer has the new key in key, the owner address and the tier it starts on.

Errors use the standard shape described under Endpoints: 400 for a malformed body, a time outside the window or a malformed signature; 401 when the signature is not the address’s signature of the message; 409 when the address already holds 3 live keys (revoke one first); and 429 when one IP issues too often.

  • address The address that signed.
  • issuedAt The time used in the message, in the toISOString format.
  • signature The EIP-191 personal_sign signature of the message by address, as a 65-byte hex string.

Sign and request a key with viem

This script signs the message locally and asks for a key. Only the signature leaves your machine, never the private key. Run it as an ES module, for example with tsx.

Request a key (viem)
import { privateKeyToAccount } from 'viem/accounts';

const API = 'https://oxley-agents.web3bandit.workers.dev';
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`);

// Three lines, exactly as shown above. account.address is the checksummed form; the same time goes in the request.
const issuedAt = new Date().toISOString();
const message = ['Oxley API key', `Address: ${account.address}`, `Issued at: ${issuedAt}`].join('\n');

// signMessage signs with EIP-191 personal_sign.
const signature = await account.signMessage({ message });

const response = await fetch(`${API}/v1/keys`, {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ address: account.address, issuedAt, signature }),
});
const body = await response.json();
if (!response.ok) throw new Error(`${response.status} ${body.error}: ${body.reason}`);

// The key is shown once. Store it in your secret manager now.
console.log(body.key);

Use your key

Send the key as a bearer token. GET /v1/me is a quick check that it works: it returns your tier and limits.

Check the key
curl https://oxley-agents.web3bandit.workers.dev/v1/me \
  -H "Authorization: Bearer $OXLEY_API_KEY"

Revoke a key

DELETE /v1/keys/self revokes the key you send and answers { "revoked": true }. The key stops working. If a key may have leaked, revoke it and request a new one.

Revoke the key in use
curl -X DELETE https://oxley-agents.web3bandit.workers.dev/v1/keys/self \
  -H "Authorization: Bearer $OXLEY_API_KEY"