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.
/api/auth/verifyNo auth requiredAuthenticate with the documentation site password. Returns a JWT session cookie on success. Rate limited to 5 attempts per IP with a 15-minute lockout.
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.
/api/auth/logoutBearer TokenEnd the current session and clear the authentication cookie.
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.
https://api.devops.bd/api/v1/documentsBearer TokenRetrieve a paginated list of documents. Supports filtering by status and sorting by creation date.
Query Parameters
pageintegerqueryDefault: 1Page number for paginated results. The first page is 1.
perPageintegerqueryDefault: 20Number of items returned per page. Maximum allowed value is 100.
statusstringqueryFilter results by document status. Allowed values: draft, published,
archived. When omitted, documents of all statuses are returned.
sortstringqueryDefault: createdAtField to sort results by. Allowed values: createdAt, updatedAt, title.
Results are sorted in descending order by default.
Response Fields
dataarrayrequiredArray of document objects matching the query. Each object contains the document ID, title, status, and creation timestamp.
meta.totalintegerrequiredTotal number of documents matching the query across all pages.
meta.pageintegerrequiredCurrent page number in the paginated result set.
meta.perPageintegerrequiredNumber 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.
https://api.devops.bd/api/v1/documentsBearer TokenCreate a new document. The title field is required. Status defaults to draft if not specified.
Request Body Parameters
titlestringbodyrequiredThe document title. Must be between 1 and 200 characters. Displayed in navigation, search results, and browser tabs.
contentstringbodyDocument body in Markdown format. Supports the full range of Markdown syntax including headings, lists, code blocks, and links.
statusstringbodyDefault: draftInitial document status. Allowed values: draft (visible only to editors) or
published (visible to all authenticated users).
tagsstring[]bodyArray 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.
https://api.devops.bd/api/v1/documents/:idBearer TokenReplace a document entirely. All fields are required in the request body.
idstringpathrequiredThe 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.
https://api.devops.bd/api/v1/documents/:idBearer TokenUpdate specific fields of a document without replacing the entire resource.
Delete Resource
Permanently remove a resource. This example demonstrates the DELETE method with a confirmation response.
https://api.devops.bd/api/v1/documents/:idBearer TokenPermanently delete a document. This action cannot be undone. All associated metadata and search index entries are removed.
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.
/api/v1/docsBearer TokenRetrieve documents using the legacy endpoint.
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:
method—GET|POST|PUT|PATCH|DELETE(required)- The HTTP method for the endpoint, rendered as a color-coded badge
endpoint—string(required)- The API endpoint URL path, displayed prominently in the header
description—string- 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
statusCode—number- Response HTTP status code (default: 200)
responses— JSON string (array)- Multiple responses displayed in a tabbed interface, each with
statusCode,label, andbody
- Multiple responses displayed in a tabbed interface, each with
auth—string- Authentication type indicator:
bearer,apiKey,basic,oauth2, ornone
- Authentication type indicator:
authLabel—string- Custom auth label text that overrides the default label for the auth type
deprecated—boolean- Mark the endpoint as deprecated, reducing opacity and showing a warning
deprecationNote—string- Migration guidance text shown in a warning box when deprecated is true
rateLimit—stringor JSON- Rate limiting metadata, displayed as plain text or parsed from JSON with
requests,window, and optionalnotefields
- Rate limiting metadata, displayed as plain text or parsed from JSON with
baseUrl—string- 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, andcode
- Additional code examples beyond the auto-generated cURL, each with
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:
name—string(required)- The parameter or field name, displayed in monospace font
type—string- Data type label (string, integer, boolean, array, object, and more)
location—string- Where the parameter is sent:
path,query,body, orheader
- Where the parameter is sent:
required—boolean- Shows a red "required" label indicating the field must be provided
defaultValue—string- Default value displayed as inline code when the field is omitted
deprecated—boolean- Shows a red "deprecated" label indicating the field will be removed
children—node- Description text that supports inline Markdown formatting