Skip to main content

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.

Base URLs

The SubPirate Pro API is available at different endpoints depending on your environment:
Local Development
string
http://localhost:8787
When running npm run dev:all, the API server runs on port 8787. The Vite dev server on port 5173 automatically proxies /api/* requests to this server.
Production
string
https://your-production-domain.com
In production, the API is served from the same origin as the frontend application.

Response Format

All API responses use JSON format with consistent patterns:

Success Response

{
  "ok": true,
  "data": {
    // Response data here
  }
}
or for list endpoints:
{
  "items": [
    // Array of items
  ],
  "next_cursor": "optional_pagination_token"
}

Error Response

{
  "error": "Error message describing what went wrong",
  "details": "Optional additional context"
}
error
string
required
Human-readable error message
details
string
Additional error context when available

Common Error Codes

The API uses standard HTTP status codes:
200
OK
Request succeeded
400
Bad Request
Invalid request parameters or malformed JSON
{
  "error": "tier+interval or priceId is required"
}
401
Unauthorized
Missing or invalid authentication token
{
  "error": "Missing Authorization bearer token"
}
or
{
  "error": "Invalid or expired token"
}
403
Forbidden
Valid authentication but insufficient permissions, or origin not allowed
{
  "error": "Origin not allowed"
}
or
{
  "error": "Admin access required"
}
404
Not Found
Requested resource does not exist
409
Conflict
Resource conflict (e.g., subscription already exists)
{
  "error": "subscription_already_exists",
  "action": "open_billing_portal"
}
500
Internal Server Error
Server-side error occurred
{
  "error": "Supabase server auth is not configured. Set SUPABASE_URL and SUPABASE_ANON_KEY."
}
502
Bad Gateway
Upstream service (Reddit, OpenRouter) returned an error
{
  "error": "Failed to contact Reddit"
}

Rate Limiting

All /api/* endpoints are rate-limited to prevent abuse:
Window
string
15 minutes
Max Requests
number
300 requests per window
Rate limit information is included in response headers:
RateLimit-Limit: 300
RateLimit-Remaining: 299
RateLimit-Reset: 1234567890
When you exceed the rate limit, you’ll receive a 429 Too Many Requests response.

CORS

The API implements CORS (Cross-Origin Resource Sharing) to allow browser-based clients:
  • Allowed Origins: Configurable via CORS_ORIGINS environment variable (comma-separated)
  • Default (Development): http://localhost:5173,http://127.0.0.1:5173
  • Allowed Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
  • Allowed Headers: Content-Type, Authorization
In development mode without explicit CORS_ORIGINS, any local network origin is automatically allowed (localhost, 127.0.0.1, private IP ranges).

Health Check

Check API availability with the health endpoint:
curl http://localhost:8787/health
Response:
{
  "status": "ok",
  "timestamp": "2026-03-02T10:30:00.000Z"
}
status
string
Always returns "ok" if the server is running
timestamp
string
ISO 8601 timestamp of the response

Example Request

Here’s a complete example of making an authenticated API request:
curl -X GET \
  http://localhost:8787/api/subscription \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json"
Response:
{
  "tier": "pro",
  "status": "active",
  "isActive": true,
  "plan": {
    "name": "Pro Plan",
    "limits": {
      "analyses_per_month": 100,
      "reddit_accounts": 5,
      "campaigns": 10,
      "projects": 20
    }
  }
}

Build docs developers (and LLMs) love