Skip to Content
Apso is in public beta. Get started
GuidesAuthAPI keys

API key authentication

An Apso service API key identifies a trusted caller to a deployed backend. It works well for a Next.js backend-for-frontend, a worker, a scheduled job, or another server.

Service keys and user Auth solve different problems

CredentialIdentifiesAppropriate location
Apso service API keyA trusted application or processServer environment or secret manager
User session or tokenAn individual userSecure cookie or client credential flow

A shared service key does not tell your backend which end user initiated a request. For a browser product, authenticate the user in your BFF, apply the user’s authorization rules, then call Apso with the server-side service key.

Send a service key

curl https://your-service.example.com/Projects \ -H "X-API-Key: $APSO_API_KEY"

With the TypeScript SDK:

src/lib/apso.ts
import 'server-only'; import { ApsoClientFactory } from '@apso/sdk'; export const apso = ApsoClientFactory.getClient({ baseURL: process.env.APSO_API_URL!, apiKey: process.env.APSO_API_KEY!, });

Create, rotate, and revoke hosted service keys from the service’s API Keys view. See Manage API Keys for the operational workflow.

Give each consumer its own key

Create separate credentials for:

  • Development, staging, and production
  • A web BFF and background workers
  • Independent third-party server integrations
  • Jobs with different owners or rotation schedules

Descriptive names such as production-nextjs-bff make incident response and rotation easier.

Add product-level machine credentials

Some products issue credentials to their own customers. Model that as application data and validate it in custom code. Store a one-way hash of each secret, show the plaintext once, and associate the record with its owner and status.

Useful fields include:

  • Key ID or prefix for lookup
  • Hashed secret
  • Workspace or organization ID
  • Display name
  • Created, last-used, and expiration timestamps
  • Revocation status

Use a constant-time comparison for hashes and apply rate limiting at the deployment edge or application layer. Never store customer key plaintext after creation.

Rotation sequence

  1. Create a replacement key.
  2. Update the consuming server’s secret.
  3. Deploy or restart the consumer.
  4. Verify one read and one write.
  5. Revoke the old key.
Last updated on