Skip to main content

Overview

The Credentials API provides secure, server-side encryption for sensitive creator credentials (API keys, passwords, session cookies). All encryption uses AES-256-GCM with keys that never leave the server. Key Features:
  • Server-side encryption (clients never handle encryption keys)
  • Multiple credential types: platform connections, download credentials, session cookies
  • Directus JWT authentication for user-facing endpoints
  • Shared secret authentication for server-to-server operations

Endpoint Categories

1. Platform Connections

User-facing endpoints for managing creator platform credentials (Instagram, TikTok, etc.)

2. Download Credentials

YouTube-DL/yt-dlp compatible credentials (passwords, Netscape cookies)

3. Platform Sessions

Browser extension cookie capture for HITL (Human-in-the-Loop) authentication

Platform Connections

POST /api/credentials/create-profile

Create or update a creator profile with encrypted credentials. Authentication: Directus JWT (Bearer token)
string
required
Platform identifier (e.g., instagram, tiktok, youtube)
string
Creator’s username on the platform (optional)
object
required
Platform-specific credentials object (will be encrypted server-side)Example for Instagram:
Response:
boolean
Operation success status
string
UUID of the created/updated platform_connections record
boolean
true if existing connection was updated, false if new record created
Example Request:
Response:

POST /api/credentials/update-profile-creds

Update encrypted credentials on an existing creator profile the user owns. Authentication: Directus JWT (Bearer token)
string
required
UUID of the platform_connections record to update
object
required
New credentials object (replaces existing encrypted data)
string
Update the platform username (optional)
Example Request:
Response:

Server-to-Server Endpoints

These endpoints require the X-RBAC-SYNC-SECRET header. Never call from client code.

POST /api/credentials/store

Encrypt and save credentials to Directus platform_connections table. Authentication: X-RBAC-SYNC-SECRET header
string
required
UUID of the platform_connections record
object
required
Credentials object to encrypt and store
Example Request:
Response:

POST /api/credentials/reveal

Decrypt and return credentials for a creator profile. Authentication: X-RBAC-SYNC-SECRET header
string
required
UUID of the platform_connections record
boolean
Operation success status
string
UUID of the profile
object
Decrypted credentials object
Example Request:
Response:

Download Credentials (yt-dlp)

POST /api/credentials/create-download-cred

Create credentials for yt-dlp/youtube-dl authentication (password or cookies). Authentication: Directus JWT (Bearer token)
string
required
Platform identifier (e.g., youtube, instagram)
string
required
UUID of the associated platform_connections record
string
required
Either password or cookies
string
Platform username (optional for cookies auth)
object
required
For password auth:
For cookies auth:
string
Human-readable name for this credential set (optional)
Example Request (Password Auth):
Response:

POST /api/credentials/reveal-download-cred

Decrypt download credentials (server-to-server only). Authentication: X-RBAC-SYNC-SECRET header
string
required
UUID of the download_credentials record
Example Request:
Response:

POST /api/credentials/store-platform-session

Store browser cookies captured via extension (HITL authentication). Authentication: Directus JWT (Bearer token)
string
required
UUID of the platform_connections record
string
required
Platform identifier (e.g., instagram, tiktok)
array
required
Array of browser cookie objects:
string
Browser user agent string (optional)
string
ISO 8601 expiry timestamp (optional)
Example Request:
Response:

POST /api/credentials/get-platform-session

Retrieve decrypted session cookies (server-to-server only). Authentication: X-RBAC-SYNC-SECRET header
string
required
UUID of the platform_connections record
string
required
Platform identifier
Example Request:
Response:

POST /api/credentials/revoke-platform-session

Mark a platform session as revoked (disables cookie usage). Authentication: Directus JWT (Bearer token)
string
required
UUID of the platform_sessions record
Example Request:
Response:

Encryption Details

All credential encryption uses the encryptJSON() and decryptJSON() utilities (server/utils/credentialsCrypto.js):
  • Algorithm: AES-256-GCM
  • Key derivation: Server-side environment variable (never exposed)
  • IV: Randomly generated per encryption operation
  • Output format: Base64-encoded iv:authTag:ciphertext
Security guarantees:
  • Encryption keys never leave the server
  • Clients never handle plaintext encryption keys
  • Each credential has unique IV (no key reuse)
  • Authentication tags prevent tampering

Error Handling

Common error responses: Missing credentials:
Unauthorized (invalid secret):
Forbidden (not profile owner):
Directus error (upstream):