API Reference
ApiBlock renders one REST endpoint as a card from a single typed operation
prop: a color-coded method badge, the path, an auth indicator, request
parameters and body, a cURL command built from those values, and one or more
response tabs. Put ParamField and ResponseField under it when a parameter or
a response key needs its own row with a type, a default, and a description. The
three examples below build up from the smallest usable card to the full set of
props.
Quick Start
One typed operation object with a method, a path, and a response is enough to
render a card.
/api/healthReport whether the docs site is up.
<ApiBlock
operation={{
method: 'GET',
path: '/api/health',
summary: 'Report whether the docs site is up.',
responses: [{ statusCode: '200', exampleBody: '{"status":"ok"}' }],
}}
/>Adding Options
Add a query parameter, a request body, a 201 status, and a base URL, then
describe each input and output field with ParamField and ResponseField.
https://api.example.com/api/v1/documentsBearer TokenCreate a document. Only title is required; status falls back to draft.
notifybooleanqueryDefault: falsetitlestringbodyrequiredDocument title, 1 to 200 characters. Shows up in navigation, search, and the browser tab.
statusstringbodyDefault: draftEither draft or published.
idstringrequiredServer-assigned identifier. Pass it back in the path for update and delete calls.
<ApiBlock
operation={{
method: 'POST',
path: '/api/v1/documents',
summary:
'Create a document. Only title is required; status falls back to draft.',
parameters: [
{
name: 'notify',
type: 'boolean',
location: 'query',
required: false,
defaultValue: 'false',
description: 'Send a notification when the document is created.',
},
],
requestBody: {
fields: [
{ name: 'title', type: 'string', location: 'body', required: true },
{
name: 'status',
type: 'string',
location: 'body',
required: false,
defaultValue: 'draft',
},
],
},
responses: [
{
statusCode: '201',
exampleBody:
'{"id":"doc_03","title":"Release checklist","status":"draft","createdAt":"2026-03-24T14:30:00Z"}',
},
],
auth: { scheme: 'bearer' },
}}
baseUrl="https://api.example.com"
/>
<ParamField name="title" type="string" location="body" required>
Document title, 1 to 200 characters. Shows up in navigation, search, and the
browser tab.
</ParamField>
<ParamField name="status" type="string" location="body" defaultValue="draft">
Either `draft` or `published`.
</ParamField>
<ResponseField name="id" type="string" required>
Server-assigned identifier. Pass it back in the path for update and delete
calls.
</ResponseField>Advanced
Two or more entries in operation.responses swap the single response for
clickable status tabs, rateLimit takes a real object, operation.auth.label
overrides the padlock text, and codeExamples adds tabs after the generated
cURL.
/api/auth/verifyPassword in bodyCheck the site password and set a session cookie.
<ApiBlock
operation={{
method: 'POST',
path: '/api/auth/verify',
summary: 'Check the site password and set a session cookie.',
requestBody: {
fields: [
{ name: 'password', type: 'string', location: 'body', required: true },
],
},
responses: [
{ statusCode: '200', exampleBody: '{"success":true}' },
{
statusCode: '401',
label: 'Unauthorized',
exampleBody: '{"success":false,"error":"Incorrect password."}',
},
{
statusCode: '429',
label: 'Rate Limited',
exampleBody: '{"success":false,"error":"Too many failed attempts."}',
},
],
auth: { scheme: 'none', label: 'Password in body' },
}}
rateLimit={{ requests: 5, window: '15 minutes', note: 'per IP address' }}
codeExamples={[
{
language: 'python',
label: 'Python',
code: 'import requests\n\nr = requests.post(url, json=payload)\nprint(r.status_code)',
},
]}
/>Options
ApiBlock
operationobjectrequiredThe endpoint's data as one real object — a subset of the EndpointOperation
type from lib/openapi-import/types.ts, so anything the OpenAPI importer
produces can be passed straight through. Invalid shapes fail the build with a
message naming the exact field, instead of silently rendering nothing.
operation.methodstringrequiredGET, POST, PUT, PATCH, or DELETE. Picks the badge color and the left
border color: blue, green, amber, purple, red.
operation.pathstringrequiredThe path shown beside the badge and used as the cURL URL.
operation.summarystringSentence shown under the header, above the parameters block. Falls back to
operation.description when omitted.
operation.parametersarrayArray of { name, type, location, required, defaultValue, description }.
Entries with location: "query" or location: "header" render as
ParamField rows in a built-in Parameters section, and feed the generated
cURL command's query string and -H flags.
operation.requestBodyobject{ mediaType, example, fields }. fields pretty-prints as the Request Body
panel; example (or a skeleton built from fields) becomes the cURL -d
payload.
operation.responsesarrayArray of { statusCode, label, exampleBody }. Two or more render as
clickable tabs; label is optional and appears next to the status code.
operation.authobject{ scheme, label }. scheme is bearer, apiKey, basic, oauth2, or
none, mapped to "Bearer Token", "API Key", "Basic Auth", "OAuth 2.0", and
"No auth required". label overrides the mapped text while keeping the
padlock icon. none gets an open padlock; the rest get a closed one.
operation.deprecatedbooleanDefault: falseAdds a red "Deprecated" chip to the header and fades the whole card.
operation.deprecationNotestringMigration text shown in a red warning box above the summary.
baseUrlstringMuted prefix before the path, also prepended to the cURL URL.
rateLimitobject{ requests, window, note }. The object above renders as "5 requests / 15
minutes (per IP address)".
codeExamplesarrayArray of { language, label, code } items appended after the generated cURL
tab. Only bash and python get real syntax highlighting; anything else
falls back to the JSON grammar.
showParametersbooleanDefault: trueSet false when the page already renders operation.parameters itself (see
components/OpenApiEmbed.tsx), to avoid showing the same parameters twice.
ParamField
namestringrequiredParameter name, rendered in monospace.
typestringType chip, such as string, integer, or string[]. Free text, so write
whatever the API actually returns.
locationstringpath, query, body, or header. Each gets its own chip color: sky,
purple, teal, amber.
requiredbooleanDefault: falseAdds a red "required" label after the badges.
defaultValuestringRendered as Default: <value> in muted text.
deprecatedbooleanDefault: falseStrikes through the name, fades the row, and adds an amber "deprecated" label.
ResponseField
namestringrequiredField name. Use dot paths like meta.total for nested keys.
typestringType chip shown next to the name.
requiredbooleanMarks the field as always present in the response.
deprecatedbooleanSame treatment as ParamField: struck-through name, faded row, amber label.
There is no location prop here, since a response field has nowhere else to
live.