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:
MethodHeaderEndpointsPurpose
API Keysoku-api-key: sk_live_xxxxx/v1/posts, /v1/media, /v1/templates, /v1/ai/transcribe, /v1/media/render-ogAll content and automation endpoints
Firebase ID TokenAuthorization: Bearer {id_token}/v1/api-keys, /v1/metrics/refreshAccount management and key administration
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:
sk_live_f7e8d9c0b3c4d5e6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2

Using Your API Key

Include your API key in the soku-api-key header on every content endpoint request:
curl -X POST https://api.mysoku.io/v1/posts \
  -H "Content-Type: application/json" \
  -H "soku-api-key: sk_live_your_api_key_here" \
  -d '{
    "post": {
      "content": {
        "text": "Hello from the API",
        "mediaType": "text",
        "platform": ["threads"]
      }
    }
  }'
HeaderRequiredDescription
soku-api-keyYesYour Soku API key, starting with sk_live_
Content-TypeYesMust be application/json for all requests with a body

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:
curl -X POST https://api.mysoku.io/v1/api-keys \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIs..." \
  -d '{"name": "Production Server"}'
HeaderRequiredDescription
AuthorizationYesBearer {firebase_id_token}
Content-TypeYesMust be application/json for requests with a body
Firebase ID tokens expire after 1 hour. Refresh your token before making key management requests if needed.

Quick Reference: Which Auth Method?

I want to…EndpointAuth MethodHeader
Create a postPOST /v1/postsAPI Keysoku-api-key: sk_live_...
Upload mediaPOST /v1/mediaAPI Keysoku-api-key: sk_live_...
Render a templatePOST /v1/templatesAPI Keysoku-api-key: sk_live_...
Render an OG imagePOST /v1/media/render-ogAPI Keysoku-api-key: sk_live_...
Transcribe mediaPOST /v1/ai/transcribeAPI Keysoku-api-key: sk_live_...
Create an API keyPOST /v1/api-keysID TokenAuthorization: Bearer ...
List API keysGET /v1/api-keysID TokenAuthorization: Bearer ...
Revoke an API keyDELETE /v1/api-keys/{id}ID TokenAuthorization: Bearer ...
Refresh metricsPOST /v1/metrics/refreshID TokenAuthorization: Bearer ...

Subscription Requirement

API access requires an active Soku subscription. Your account must be in one of the following states:
Subscription StatusAPI Access
Trialing (free trial active)Allowed
Active (paid subscription)Allowed
CanceledDenied (403)
ExpiredDenied (403)
Past dueDenied (403)
If your subscription is not active, the API returns a 403 Forbidden error:
{
  "error": {
    "type": "authentication_error",
    "code": "forbidden",
    "message": "An active subscription is required to access the API.",
    "timestamp": "2026-02-28T12:00:00.000Z",
    "requestId": "req_abc123def456",
    "details": null
  }
}

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:
{
  "error": {
    "type": "authentication_error",
    "code": "unauthorized",
    "message": "Invalid or missing API key.",
    "timestamp": "2026-02-28T12:00:00.000Z",
    "requestId": "req_abc123def456",
    "details": null
  }
}
Common causes:
ProblemSolution
Header is missing entirelyAdd the soku-api-key header to your request
Key is misspelled or truncatedVerify you copied the full key, including the sk_live_ prefix
Key has been revokedCreate a new key in Settings > API Keys
Wrong header nameUse soku-api-key, not Authorization or x-api-key
Using Authorization: Bearer on a content endpointSwitch to soku-api-key header

Missing or Invalid ID Token (401)

If the Authorization header is missing or the Firebase ID token is invalid on a key management endpoint:
{
  "error": {
    "type": "authentication_error",
    "code": "unauthorized",
    "message": "Invalid or expired Firebase ID token.",
    "timestamp": "2026-02-28T12:00:00.000Z",
    "requestId": "req_abc123def456",
    "details": null
  }
}
Common causes:
ProblemSolution
Token has expiredRefresh your Firebase ID token (they expire after 1 hour)
Token is malformedVerify you are passing a valid JWT from Firebase Auth
Using soku-api-key on a key management endpointSwitch to Authorization: Bearer {id_token}

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.
# Set as an environment variable
export SOKU_API_KEY="sk_live_your_api_key_here"
// Read from environment
const apiKey = process.env.SOKU_API_KEY;

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.
EnvironmentKey Name Example
DevelopmentDev Server - Local
StagingStaging Server
ProductionProduction Backend
CI/CDGitHub Actions Pipeline

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.
X-Request-ID: req_abc123def456

Next Steps

TopicDescription
Posts APIStart creating and publishing posts
API KeysManage API keys programmatically
Rate LimitsUnderstand request limits for your tier