curl --request POST \
--url https://api.example.com/api/reddit/oauth/exchange \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"reconnect_account_id": "<string>"
}
'{
"ok": true,
"account": {
"account.id": "<string>",
"account.username": "<string>"
},
"error": "<string>",
"details": "<string>"
}Exchange Reddit OAuth authorization code for encrypted access and refresh tokens
curl --request POST \
--url https://api.example.com/api/reddit/oauth/exchange \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"reconnect_account_id": "<string>"
}
'{
"ok": true,
"account": {
"account.id": "<string>",
"account.username": "<string>"
},
"error": "<string>",
"details": "<string>"
}Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MatthewSabia1/SubPirate-Pro/llms.txt
Use this file to discover all available pages before exploring further.
Authorization: Bearer <supabase_access_token>
TOKEN_ENCRYPTION_KEY environment variable (base64-encoded 32-byte key)v1:<iv_base64>:<tag_base64>:<ciphertext_base64>reddit_account_tokens table:
access_token_enc - Encrypted Reddit access tokenrefresh_token_enc - Encrypted Reddit refresh tokenencryptString() function in server.js:297-311.
plan_definitions.max_reddit_accounts403 with subscription_required if user has no active subscription403 with quota_exceeded if account limit reached| Status | Error | Description |
|---|---|---|
| 400 | Missing OAuth code | No code provided in request body |
| 400 | Invalid reconnect account id | reconnect_account_id is not a valid UUID |
| 400 | Reconnect account not found for this user | Specified account doesn’t exist or doesn’t belong to user |
| 403 | subscription_required | User has no active subscription |
| 403 | quota_exceeded | User has reached their Reddit account limit |
| 409 | Reconnect requires the same Reddit account | OAuth username doesn’t match the account being reconnected |
| 500 | Reddit OAuth is not configured | REDDIT_CLIENT_ID or REDDIT_CLIENT_SECRET not set |
| 500 | Failed to encrypt Reddit tokens | TOKEN_ENCRYPTION_KEY missing or invalid |
| 502 | Invalid token response from Reddit | Reddit token exchange failed |
| 502 | Invalid user response from Reddit | Reddit /api/v1/me request failed |
curl -X POST https://api.subpirateapp.com/api/reddit/oauth/exchange \
-H "Authorization: Bearer eyJhbGc..." \
-H "Content-Type: application/json" \
-d '{
"code": "abc123xyz"
}'
{
"ok": true,
"account": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "example_user"
}
}
{
"error": "quota_exceeded",
"feature": "reddit_accounts",
"limit": 3,
"upgrade_required": true,
"message": "You've reached your limit of 3 Reddit accounts. Upgrade for more."
}
https://www.reddit.com/api/v1/access_token with Basic auth (client_id:client_secret)https://oauth.reddit.com/api/v1/me with access tokenupsert_reddit_account_with_limit stored procedure to enforce quotareddit_account_tokens with 3 retry attempts23503, 40001, 40P01 or RLS policy violationsreconnect_account_id is provided:
reddit_user_idexecuteRedditOAuthExchangeFlow() in api/_lib/redditOAuthExchangeFlow.js:64-227 for full implementation.