Skip to main content

Authentication

Every request to the Soku API must be authenticated. The API supports two authentication methods, each used in different contexts. This page covers both methods, when to use each, how to obtain credentials, and how to keep them secure.

Two Authentication Methods

The Soku API uses different authentication depending on the type of endpoint:
These two methods are not interchangeable. Sending an Authorization: Bearer header to a content endpoint (like /v1/posts) will result in a 401 Unauthorized error. Similarly, sending a soku-api-key header to a key management endpoint (like /v1/api-keys) will not work.

Method 1: API Key Authentication

API key authentication is what most developers use. It covers all content endpoints for creating posts, uploading media, rendering templates, and transcribing audio/video.

Obtaining an API Key

API keys are created in the Soku dashboard:
  1. Log in to your account at mysoku.io.
  2. Navigate to Settings > API Keys.
  3. Click Create API Key.
  4. Give the key a descriptive name (for example, “Production Server” or “CI Pipeline”).
  5. Copy the key immediately. For security, the full key is only shown once at creation time.
Copy your API key when it is first displayed. You will not be able to view the full key again after leaving the creation screen. If you lose a key, revoke it and create a new one.

API Key Format

API keys follow the format sk_live_ followed by a random string, totaling approximately 55 characters:

Using Your API Key

Include your API key in the soku-api-key header on every content endpoint request:

Method 2: Firebase ID Token Authentication

The API key management endpoints (/v1/api-keys) and the metrics refresh endpoint (/v1/metrics/refresh) use Firebase ID token authentication. This is because creating and revoking API keys is a privileged operation that requires proof of account ownership.

Obtaining a Firebase ID Token

You can obtain a Firebase ID token by authenticating through the Firebase Authentication SDK in your application. See the Firebase documentation for details.

Using an ID Token

Include the Firebase ID token in the Authorization header as a Bearer token:
Firebase ID tokens expire after 1 hour. Refresh your token before making key management requests if needed.

Quick Reference: Which Auth Method?


Subscription Requirement

API access requires an active Soku subscription. Your account must be in one of the following states: If your subscription is not active, the API returns a 403 Forbidden error:

Authentication Errors

Missing or Invalid API Key (401)

If the soku-api-key header is missing or the key is invalid, the API returns a 401 Unauthorized error:
Common causes:

Missing or Invalid ID Token (401)

If the Authorization header is missing or the Firebase ID token is invalid on a key management endpoint:
Common causes:

API Key Security Best Practices

API keys grant full access to your Soku account through the API. Treat them with the same care as passwords.

Store keys in environment variables

Never hard-code API keys in source code, configuration files checked into version control, or client-side code.

Never expose keys in client-side code

API keys must only be used in server-side code. Never include them in frontend JavaScript, mobile apps, or any code that runs in a browser. If you need to make API calls from a client application, proxy them through your own backend server.
If an API key is exposed publicly (for example, committed to a public repository), revoke it immediately in Settings > API Keys and create a replacement.

Use separate keys for each environment

Create distinct API keys for development, staging, and production. This lets you revoke a compromised key without affecting other environments.

Rotate keys periodically

Revoke and replace API keys on a regular schedule, even if you have no reason to believe they have been compromised. This limits the window of exposure if a key is leaked without your knowledge.

Restrict access

Only share API keys with team members and services that need them. Audit your active keys periodically in Settings > API Keys and revoke any that are no longer in use.

API Key Management Endpoints

You can also create, list, and revoke API keys programmatically using the key management endpoints with Firebase ID token authentication.
For details on the API key management endpoints, see API Keys.

Request Tracking

Every API response includes an X-Request-ID header that uniquely identifies the request. Include this value when contacting support about a specific request.

Next Steps