Skip to main content
ClearDocs

API Reference

This page demonstrates the ApiBlock component — the primary tool for documenting REST API endpoints in ClearDocs. Each block renders a complete, interactive endpoint reference with the HTTP method, endpoint URL, headers, request body, response body, authentication requirements, rate limiting metadata, and auto-generated cURL examples. Use this page as both a working reference for the built-in authentication API and a template for documenting your own APIs.

Authentication

ClearDocs includes two built-in authentication endpoints for managing user sessions in private mode. These endpoints handle password verification, JWT session creation, and session cleanup.

Verify Password

The verify endpoint authenticates a visitor by checking the provided password against the server-side hash. On success, it sets a JWT session cookie that grants access to all documentation pages for 14 days. The endpoint is rate limited to prevent brute-force attacks.

POST/api/auth/verifyNo auth required

Authenticate with the documentation site password. Returns a JWT session cookie on success. Rate limited to 5 attempts per IP with a 15-minute lockout.

Rate limit: 5 requests / 15 minutes (Per IP address)
Headers
Content-Typeapplication/json
Request Body
{ "password": "your-access-password" }
Request Example
curl -X POST "/api/auth/verify" \ -H "Content-Type: application/json" \ -d '{"password":"your-access-password"}'
Response
{ "success": true }

Logout

The logout endpoint ends the current session by clearing the authentication cookie. It validates the request origin to prevent CSRF attacks and verifies that the session is authenticated before clearing.

POST/api/auth/logoutBearer Token

End the current session and clear the authentication cookie.

Request Example
curl -X POST "/api/auth/logout"
Response200
{ "success": true }

Example: REST API Documentation

The following examples show how to document a typical REST API using ClearDocs components. Each endpoint demonstrates a different HTTP method with structured parameter and response field documentation alongside it. Use this section as a template when building your own API reference pages.

List Resources

Retrieve a paginated collection of resources. This example demonstrates the GET method with query parameters for filtering, sorting, and pagination — the most common pattern in REST API documentation.

GEThttps://api.devops.bd/api/v1/documentsBearer Token

Retrieve a paginated list of documents. Supports filtering by status and sorting by creation date.

Headers
AuthorizationBearer <token>
Acceptapplication/json
Request Example
curl -X GET "https://api.devops.bd/api/v1/documents" \ -H "Authorization: Bearer <token>" \ -H "Accept: application/json"
Response200
{ "data": [ { "id": "doc_01", "title": "Getting Started Guide", "status": "published", "createdAt": "2026-03-24T12:00:00Z" }, { "id": "doc_02", "title": "API Integration", "status": "draft", "createdAt": "2026-03-23T09:30:00Z" } ], "meta": { "total": 42, "page": 1, "perPage": 20 } }

Query Parameters

pageintegerqueryDefault: 1

Page number for paginated results. The first page is 1.

perPageintegerqueryDefault: 20

Number of items returned per page. Maximum allowed value is 100.

statusstringquery

Filter results by document status. Allowed values: draft, published, archived. When omitted, documents of all statuses are returned.

sortstringqueryDefault: createdAt

Field to sort results by. Allowed values: createdAt, updatedAt, title. Results are sorted in descending order by default.

Response Fields

dataarrayrequired

Array of document objects matching the query. Each object contains the document ID, title, status, and creation timestamp.

meta.totalintegerrequired

Total number of documents matching the query across all pages.

meta.pageintegerrequired

Current page number in the paginated result set.

meta.perPageintegerrequired

Number of items included per page in the response.

Create Resource

Create a new resource in the collection. This example demonstrates the POST method with a JSON request body, required and optional fields, and a 201 status code response.

POSThttps://api.devops.bd/api/v1/documentsBearer Token

Create a new document. The title field is required. Status defaults to draft if not specified.

Headers
AuthorizationBearer <token>
Content-Typeapplication/json
Request Body
{ "title": "New Document", "content": "Document body in Markdown format.", "status": "draft", "tags": [ "guide", "onboarding" ] }
Request Example
curl -X POST "https://api.devops.bd/api/v1/documents" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{"title":"New Document","content":"Document body in Markdown format.","status":"draft","tags":["guide","onboarding"]}'
Response200
{ "id": "doc_03", "title": "New Document", "status": "draft", "createdAt": "2026-03-24T14:30:00Z" }

Request Body Parameters

titlestringbodyrequired

The document title. Must be between 1 and 200 characters. Displayed in navigation, search results, and browser tabs.

contentstringbody

Document body in Markdown format. Supports the full range of Markdown syntax including headings, lists, code blocks, and links.

statusstringbodyDefault: draft

Initial document status. Allowed values: draft (visible only to editors) or published (visible to all authenticated users).

tagsstring[]body

Array of tag strings for categorization. Tags are used for filtering and grouping documents in the sidebar and search results.

Update Resource

Replace an entire resource. This example demonstrates the PUT method, which requires all fields to be included in the request body — omitted fields are reset to their defaults.

PUThttps://api.devops.bd/api/v1/documents/:idBearer Token

Replace a document entirely. All fields are required in the request body.

Headers
AuthorizationBearer <token>
Content-Typeapplication/json
Request Body
{ "title": "Updated Document Title", "content": "Updated content.", "status": "published", "tags": [ "guide", "updated" ] }
Request Example
curl -X PUT "https://api.devops.bd/api/v1/documents/:id" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{"title":"Updated Document Title","content":"Updated content.","status":"published","tags":["guide","updated"]}'
Response200
{ "id": "doc_03", "title": "Updated Document Title", "status": "published", "updatedAt": "2026-03-24T15:00:00Z" }
idstringpathrequired

The unique document identifier. Found in the id field of any document response object.

Partial Update

Update specific fields without replacing the entire resource. This example demonstrates the PATCH method, which accepts a partial request body — only the included fields are modified.

PATCHhttps://api.devops.bd/api/v1/documents/:idBearer Token

Update specific fields of a document without replacing the entire resource.

Headers
AuthorizationBearer <token>
Content-Typeapplication/json
Request Body
{ "status": "published" }
Request Example
curl -X PATCH "https://api.devops.bd/api/v1/documents/:id" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{"status":"published"}'
Response200
{ "id": "doc_03", "title": "Updated Document Title", "status": "published", "updatedAt": "2026-03-24T15:30:00Z" }

Delete Resource

Permanently remove a resource. This example demonstrates the DELETE method with a confirmation response.

DELETEhttps://api.devops.bd/api/v1/documents/:idBearer Token

Permanently delete a document. This action cannot be undone. All associated metadata and search index entries are removed.

Headers
AuthorizationBearer <token>
Request Example
curl -X DELETE "https://api.devops.bd/api/v1/documents/:id" \ -H "Authorization: Bearer <token>"
Response200
{ "success": true, "message": "Document deleted successfully." }

Deprecated Endpoint

ClearDocs supports marking endpoints as deprecated with optional migration guidance. Deprecated endpoints render with reduced opacity and a warning notice directing users to the replacement.

DeprecatedGET/api/v1/docsBearer Token
This endpoint is deprecated. Use GET /api/v1/documents instead.

Retrieve documents using the legacy endpoint.

Headers
AuthorizationBearer <token>
Request Example
curl -X GET "/api/v1/docs" \ -H "Authorization: Bearer <token>"
Response200
{ "items": [] }

Usage

To use the ApiBlock component in your MDX files, pass all data props as JSON strings. The component parses, formats, and renders them automatically with syntax highlighting and interactive tabs.

Supported Props

The ApiBlock component accepts the following props for configuring endpoint documentation:

  • methodGET | POST | PUT | PATCH | DELETE (required)
    • The HTTP method for the endpoint, rendered as a color-coded badge
  • endpointstring (required)
    • The API endpoint URL path, displayed prominently in the header
  • descriptionstring
    • Endpoint description text shown below the header
  • headers — JSON string
    • Request headers as a JSON object string, rendered with syntax highlighting
  • body — JSON string
    • JSON request body, auto-formatted with 2-space indentation
  • response — JSON string
    • JSON response body for a single response
  • statusCodenumber
    • Response HTTP status code (default: 200)
  • responses — JSON string (array)
    • Multiple responses displayed in a tabbed interface, each with statusCode, label, and body
  • authstring
    • Authentication type indicator: bearer, apiKey, basic, oauth2, or none
  • authLabelstring
    • Custom auth label text that overrides the default label for the auth type
  • deprecatedboolean
    • Mark the endpoint as deprecated, reducing opacity and showing a warning
  • deprecationNotestring
    • Migration guidance text shown in a warning box when deprecated is true
  • rateLimitstring or JSON
    • Rate limiting metadata, displayed as plain text or parsed from JSON with requests, window, and optional note fields
  • baseUrlstring
    • Base URL prefix shown above the endpoint path in muted text
  • codeExamples — JSON string (array)
    • Additional code examples beyond the auto-generated cURL, each with language, label, and code

Each method type renders with a distinct color: GET (blue), POST (green), PUT (amber), PATCH (purple), DELETE (red).

Companion Components

Use ParamField and ResponseField alongside ApiBlock to provide structured documentation for request parameters and response fields:

  • namestring (required)
    • The parameter or field name, displayed in monospace font
  • typestring
    • Data type label (string, integer, boolean, array, object, and more)
  • locationstring
    • Where the parameter is sent: path, query, body, or header
  • requiredboolean
    • Shows a red "required" label indicating the field must be provided
  • defaultValuestring
    • Default value displayed as inline code when the field is omitted
  • deprecatedboolean
    • Shows a red "deprecated" label indicating the field will be removed
  • childrennode
    • Description text that supports inline Markdown formatting