Authentication

Authentication Scheme

Trading API uses Ed25519 signature authentication (signatureAuth).

To authenticate with the Trading API, you'll need an Ed25519 keypair (private and public keys). See the Generating Ed25519 Keypairs section below for instructions on how to generate them.

Each authenticated request must include three headers:

Header
Description

x-thegrid-signature

Base64-encoded Ed25519 signature

x-thegrid-timestamp

Unix timestamp (seconds since epoch)

x-thegrid-fingerprint

SHA256 hash of your public key (Base64-encoded)

Signature Generation Process

  1. Construct the message: timestamp + HTTP_METHOD + request_path + body

  2. Sign the message with your Ed25519 private key

  3. Base64 encode the signature

  4. Include headers in your request

circle-info

Important: The request_path is the endpoint path without query parameters. Query parameters are sent with the HTTP request but are excluded from signature computation.

Signature Examples:

For a simple POST request to /api/v1/trading/orders:

Message to sign: {timestamp}POST/api/v1/trading/orders{"market_id":"market_b310e860-97cd-45eb-bdc3-5be0b79295d0","side":"buy",...}

For a GET request with query parameters like /api/v1/trading/orders?limit=10&next=eyJpZCI6Im9yZGVyX1pWRk9BR0c0SldSTlhNQ0sifQ:

Common mistake (will cause "Signature verification failed"):

Correct:

Generating Ed25519 Keypairs

To authenticate with the Trading API, you'll need an Ed25519 keypair (private and public keys). Here's how to generate them in different languages:

Generate a private key (32-byte seed)

Extract the public key for adding in The Grid UI

Convert private key to Base64 format for use with the API

Convert public key to Base64 format for use with the API

Important Security Notes:

  • Never share your private key - keep it secure and never commit it to version control

  • Store keys securely - use environment variables or secure key management systems

  • Use different keypairs for different environments (development, staging, production)

  • The private key format includes both the seed and public key (64 bytes total)

  • The public key is 32 bytes and is used to generate the fingerprint for the x-thegrid-fingerprint header

Last updated

Was this helpful?