Authentication

GETTING STARTED

Authentication

Learn how Sobtra authenticates users and API requests, and how to protect your credentials.

Authentication methods

Sobtra supports different authentication flows depending on the endpoint. Choose the method required by the resource you are accessing.

User authentication

Supabase Auth manages user sign-in and access tokens for authenticated application operations.

API-key authentication

API keys authenticate supported server-to-server requests and are associated with a merchant and an environment.

API-key authentication

For an endpoint protected by API-key authentication, provide your key as a Bearer token in the Authorization header.

Authorization header

httpExample
Authorization: Bearer YOUR_API_KEY

Example request

bashExample
curl "$SOBTRA_API_URL/users/me/merchants" \
  -H "Authorization: Bearer $SOBTRA_API_KEY" \
  -H "Accept: application/json"

Creating and managing API keys

API keys are managed in the context of a merchant. Create separate keys for testing and live integrations, and give each key an identifiable name.

  • Use test credentials during development.
  • Store secret keys in server-side environment variables or a secret manager.
  • Restrict access to production credentials.
  • Revoke a key immediately if it is exposed or no longer needed.
  • Do not commit API keys to Git or include them in browser bundles.

Server-side configuration

dotenvExample
SOBTRA_API_URL=https://api.sobtra.com
SOBTRA_API_KEY=your_secret_test_key

User authentication

Dashboard endpoints protected by user authentication require a valid Supabase access token. Your application should obtain the session through Supabase Auth and send the access token to the backend when required.

Authenticated user request

bashExample
curl "$SOBTRA_API_URL/users/me" \
  -H "Authorization: Bearer SUPABASE_ACCESS_TOKEN" \
  -H "Accept: application/json"

Public and webhook endpoints

Some endpoints are intentionally public, while incoming payment-provider webhooks use provider-specific authentication and signature verification. Do not assume that all endpoints use the same authorization mechanism.

Related documentation