platform_connections Directus collection. All credentials are encrypted with AES-256-GCM before being written to the database.
Encryption
Credentials are encrypted usingserver/utils/credentialsCrypto.js:
- Algorithm: AES-256-GCM
- Key source:
CREDENTIALS_ENC_KEY_B64environment variable (base64-encoded 256-bit key) - Functions:
encryptJSON(data)→ encrypted blob,decryptJSON(blob)→ original object - Format: The encrypted blob includes the IV and auth tag, stored as a single field (
encrypted_credentials) in theplatform_connectionsrecord
credentials.js is one of two endpoints permitted to use adminFetch for Directus reads (the other is register.js). All other endpoints use the MCP_SERVICE_TOKEN service client. This exception exists because credential access requires admin-level Directus reads that bypass per-user RLS.Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/credentials/store | Encrypt credentials and write to Directus |
POST | /api/credentials/reveal | Decrypt credentials from Directus and return them |
POST /api/credentials/store
Encrypts a credentials object and saves it to theplatform_connections Directus record for the given creator profile.
Body
The UUID of the
platform_connections record in Directus. This is the target record that will be updated with the encrypted credentials.The credentials object to encrypt. Shape varies by platform. See platform-specific shapes below.
Response
true when credentials were encrypted and written to Directus.The
platform_connections record ID (echoed from request).The Directus record ID that was updated.
PATCH to /items/platform_connections/{creatorProfileId} and writes three fields:
| Field | Value |
|---|---|
encrypted_credentials | AES-256-GCM encrypted blob |
credentials_version | "v1" |
credentials_updated_at | Current UTC timestamp |
POST /api/credentials/reveal
Fetches the encrypted credentials from Directus and decrypts them, returning the original credentials object.Body
The UUID of the
platform_connections record whose credentials should be decrypted.Response
true when credentials were found and successfully decrypted.The decrypted credentials object. Shape matches what was passed to
/store.Per-user isolation
Credentials are stored inplatform_connections records that are associated with a specific creator_profile_id. Row-level security in PostgreSQL ensures that each user can only access their own records. The reveal endpoint additionally validates that the requesting identity is authorized to access the given creatorProfileId before decrypting.
Platform credential shapes
Thecredentials object is platform-specific. Common shapes:
OnlyFans
OnlyFans
Fansly
Fansly
Instagram
Error responses
| Status | Body | Cause |
|---|---|---|
400 | { "success": false, "error": "creatorProfileId required" } | Missing required field |
400 | { "success": false, "error": "credentials object required" } | Missing or invalid credentials payload |
401 | { "success": false, "error": "Unauthorized" } | Missing or incorrect X-RBAC-SYNC-SECRET |
500 | { "success": false, "error": "RBAC_SYNC_WEBHOOK_SECRET not set" } | Server misconfiguration — missing env var |