API Reference

Last updated: 02/22/2026

The TechWrit AI REST API lets you integrate documentation analysis into CI/CD pipelines, scripts, and custom tooling.

Base URL: https://techwrit.ai/api

Authentication

All API requests require an API key sent as a Bearer token in the X-Authorization header.

X-Authorization: Bearer twai_your_api_key_here
Note

Use X-Authorization (not Authorization). The hosting platform reserves the standard Authorization header for its own authentication layer.

Creating an API key

  1. Sign in to TechWrit AI (Pro or Team subscription required).
  2. Open the user menu (bottom of the sidebar) and select API Keys.
  3. Enter an optional label and click Create.
  4. Copy the key immediately — it is shown only once.

You can create up to 5 API keys. Revoke unused keys from the same dialog.

Rate limits

API requests share the same monthly quota as web UI requests. Every response includes rate limit headers:

HeaderDescription
X-RateLimit-LimitMonthly request limit (omitted for unlimited tiers)
X-RateLimit-RemainingRequests remaining this month
X-RateLimit-ResetISO 8601 timestamp when the limit resets (1st of next month)

POST /api/v1/analyze

Analyze or generate technical documentation.

Request body

{
  "mode": "review",
  "input": "Click the button to login to the system.",
  "docType": "API reference",
  "audience": "developers",
  "rules": [
    { "label": "Active voice", "description": "Prefer active voice over passive." }
  ],
  "termSubs": [
    { "preferred": "select", "avoid": ["click"] }
  ],
  "glossary": [
    { "term": "API", "definition": "Application Programming Interface.", "synonyms": ["interface"] }
  ],
  "customInstructions": "Focus on security terminology."
}
FieldTypeRequiredDescription
modestringYesOne of: generate, rewrite, review, style-check, simplify, keywords, glossary-gen, code-to-docs, user-guide, explain, summarize, expand, translate, outline
inputstringYesThe text to analyze or the prompt for generation
docTypestringNoDocument type context (e.g., "API reference", "User guide")
audiencestringNoOne of: consumer, engineers, developers, devops
rulesarrayNoStyle rules to apply. Each: { label, description }. If omitted, uses your saved rules.
termSubsarrayNoTerminology substitutions. Each: { preferred, avoid[] }. If omitted, uses your saved config.
glossaryarrayNoGlossary entries. Each: { term, definition, synonyms[] }. If omitted, uses your saved config.
customInstructionsstringNoAdditional freeform instructions appended to the prompt

When rules, termSubs, or glossary are omitted, the API falls back to your saved configuration from the web UI.

Success response (200)

{
  "content": "The analysis output text...",
  "mode": "review",
  "usage": {
    "inputTokens": 1234,
    "outputTokens": 567
  },
  "quota": {
    "limit": null,
    "used": 5,
    "remaining": null
  }
}
FieldDescription
contentThe generated or analyzed text
modeThe mode that was used
usage.inputTokensInput tokens consumed
usage.outputTokensOutput tokens consumed
quota.limitMonthly limit (null for unlimited tiers)
quota.usedRequests used this month
quota.remainingRequests remaining (null for unlimited)

Error responses

StatusCodeDescription
400INVALID_MODEMissing or invalid mode parameter
400INVALID_INPUTMissing or empty input parameter
401UNAUTHORIZEDMissing or invalid API key
403API_KEY_REQUIREDFree tier — API requires Pro or Team
429RATE_LIMIT_EXCEEDEDMonthly request limit exceeded
502UPSTREAM_ERRORUpstream AI service error

Error response body:

{
  "error": {
    "message": "Human-readable error description.",
    "code": "ERROR_CODE"
  }
}

Examples

cURL

curl -X POST https://techwrit.ai/api/v1/analyze \
  -H "X-Authorization: Bearer twai_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "review",
    "input": "Click the button to login to the system."
  }'

Node.js

const response = await fetch("https://techwrit.ai/api/v1/analyze", {
  method: "POST",
  headers: {
    "X-Authorization": "Bearer twai_your_key_here",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    mode: "review",
    input: "Click the button to login to the system.",
    audience: "developers",
  }),
});

const data = await response.json();
console.log(data.content);

Python

import requests

response = requests.post(
    "https://techwrit.ai/api/v1/analyze",
    headers={
        "X-Authorization": "Bearer twai_your_key_here",
        "Content-Type": "application/json",
    },
    json={
        "mode": "review",
        "input": "Click the button to login to the system.",
    },
)

data = response.json()
print(data["content"])

Limitations

  • Stateless — Each request is independent. There is no session history or multi-turn context.
  • Text only — File attachments are not supported via the API. Include code as text in the input field.
  • Max input — Input text is limited by the upstream model's context window (approximately 200,000 characters).
  • Shared quota — API requests and web UI requests share the same monthly counter.