Skip to content
Kora supports two optional authentication methods for securing your RPC endpoint: API Key and HMAC authentication. This guide covers setup, implementation, and security best practices. Authentication is optional but strongly recommended for production deployments. Without authentication, anyone who discovers your Kora endpoint can submit transactions and consume your SOL balance.
MethodSecurity LevelUse CaseComplexity
None⚠️ NoneDevelopment, testing, high-margin pricingNone
API KeyBasicInternal apps, trusted clientsLow
HMACHighPublic APIs, untrusted networksMedium
BothMaximumHigh-security environmentsMedium
Kora Authentication is configured in the kora.toml file in the [kora.auth] section. In this document:

​API Key Authentication

Simple shared secret authentication using HTTP headers. You can generate a new API key using the openssl command (or a similar command) in your terminal:

​Server Configuration

  • Add a KORA_API_KEY to your .env (environment variables) (has priority) or
  • Add an api_key to your kora.toml:
This key will be globally required for all requests to the Kora RPC endpoint.

​Client Implementation

Include the API key in the x-api-key header with every request: cURL Example:
The JavaScript examples on this page are ES modules that use top-level await. Save them as .mjs files, or set "type": "module" in your package.json. JavaScript Example using Kora SDK:
JavaScript Example using fetch:

​HMAC Authentication

Instead of sending an API key with every request, HMAC creates a unique cryptographic signature that proves you know a secret without revealing it. Each signature includes a timestamp and expires after 5 minutes, so intercepted requests can’t be replayed. Attackers can’t create new requests because they don’t have your secret key.

​Server Configuration

  • Add KORA_HMAC_SECRET to your .env (environment variables) (has priority) or
  • Add a global hmac_secret to your kora.toml (minimum 32 characters—you can generate one with openssl rand -hex 32 or similar):

​How HMAC Works

  1. Client creates a message by concatenating: {timestamp}{request_body}
  2. Client signs the message using HMAC-SHA256 with the shared secret
  3. Client sends the request with timestamp and signature headers
  4. Server validates the signature and timestamp (must be within 5 minutes)

​Client Implementation

To use HMAC client-side, you can use the Kora SDK or the crypto library in JavaScript:
  1. Create a timestamp
  2. Create the request body
  3. Create a message by concatenating the timestamp and body (e.g., message = timestamp + body)
  4. Create a signature by signing the message with the HMAC secret (using the crypto.createHmac method)
  5. Send the request with the timestamp (x-timestamp) and signature (x-hmac-signature) headers
JavaScript Example using Kora SDK: The Kora SDK abstracts away the HMAC authentication process, so you can simply call the method you want to call and the SDK will handle the authentication for you.
JavaScript Example using crypto library:

​Combined Authentication

You can enable both authentication methods simultaneously for maximum security:
When both are configured, clients must send the x-api-key, x-timestamp, and x-hmac-signature headers.

​Security Best Practices

  • Use strong, random keys: Minimum 32 characters with high entropy
  • Rotate regularly: Change keys periodically (monthly/quarterly)
  • Secure storage: Use environment variables or secrets management (Railway secrets, AWS Secrets Manager, etc.)
  • Never hardcode: Keep keys out of source code and logs
  • Use HTTPS: Always use TLS in production to protect keys in transit
  • Monitor access: Watch for unusual authentication patterns or repeated failures

​Exempt Endpoints

Health checks are exempt from authentication. Kora exposes liveness as a JSON-RPC method, and also serves it as a plain HTTP GET /liveness path that the server converts into a liveness JSON-RPC call. The API key and HMAC checks skip any request whose JSON-RPC method is liveness, so both forms work without auth headers:
A successful check returns HTTP 200. The liveness method must stay enabled in [kora.enabled_methods] (it is enabled by default). If you disable it, both forms are rejected. Rate limiting still applies to health checks.

​Troubleshooting

A 401 response has an empty body, so response.json() and the Kora SDK fail with SyntaxError: Unexpected end of JSON input. Check response.status before parsing when you call Kora with fetch. 401 Unauthorized with API Key:
  • Verify the API key is correct and matches server configuration
  • Check that the x-api-key header is being sent
  • Ensure no extra whitespace in the key
401 Unauthorized with HMAC:
  • Verify timestamp is current (within 5 minutes)
  • Check that message construction matches: {timestamp}{body}
  • Ensure HMAC secret matches server configuration
  • Verify signature is lowercase hex