Skip to main content

API Reference

The thig.ai API provides programmatic access to projects, PRDs, templates, AI tools, exports, and more.

Base URL

https://app.thig.ai/api

Authentication

All API requests require authentication via session cookies or API keys. See Authentication for details.

Response Format

Success Response

{
  "success": true,
  "data": { ... }
}
Some endpoints return the data directly without a wrapper:
{
  "projects": [...],
  "total": 42
}

Error Response

{
  "error": "Error message describing what went wrong",
  "code": "ERROR_CODE"
}

Common HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad Request — invalid input
401Unauthorized — not authenticated
403Forbidden — insufficient permissions or feature disabled
404Not Found
429Rate Limited — too many requests
500Internal Server Error

Rate Limiting

API requests are rate-limited based on:
  • Subscription tier — Higher plans get higher limits
  • Endpoint type — AI endpoints have stricter limits than CRUD endpoints
When rate limited, you’ll receive a 429 response. Wait and retry after the indicated period.

Streaming Endpoints

AI-powered endpoints use Server-Sent Events (SSE) for streaming responses. Event types:
Event TypeDescription
progressPhase update with percentage (e.g., “Analyzing requirements… 25%“)
contentText content chunk
doneFinal complete result
errorError with message and optional code

Handling SSE Streams

const response = await fetch('/api/generate-prd/stream', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ projectId: 'xxx' })
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;

  const text = decoder.decode(value);
  const lines = text.split('\n');

  for (const line of lines) {
    if (line.startsWith('data: ')) {
      const event = JSON.parse(line.slice(6));
      // Handle event based on event.type
    }
  }
}

Feature Flags

Some endpoints are gated by feature flags and may return 403 if the feature is disabled for your organization. Feature-gated endpoints are noted in their documentation.

API Sections