API Components - Documentation.AI

API Components

Reference for Request and Response components that automatically display in the right panel for API documentation.

Overview

The Request and Response components create a two-column layout for API examples:

These components are designed for developers and work like sidebar versions of CodeGroup.

Common use cases:

Using with Web Editor

Request in the editor UI

  1. Place your cursor where you want the sidebar example.
  2. Type / and search for Request.
  3. Select Request to insert a Request block.

Inside the Request block:

Response in the editor UI

  1. Place your cursor under the related Request (or wherever you want the response).
  2. Type / and search for Response.
  3. Select Response to insert a Response block.

Inside the Response block:

Using with Code Editor

Request in MDX

Use Request to display API request examples in the right sidebar. This component works like CodeGroup but displays in the sidebar instead of inline.

<Request tabs="JavaScript,Python">
```javascript
const response = await fetch('/api/docs', {
method: 'POST',
headers: { 'Authorization': 'Bearer TOKEN' },
body: JSON.stringify({ title: 'Getting Started' })
});
```

```python
import requests
response = requests.post('/api/docs',
headers={'Authorization': 'Bearer TOKEN'},
json={'title': 'Getting Started'}
)
```
</Request>

Response in MDX

Use Response to display API response examples in the right sidebar beneath any Request content on the same page.

<Response tabs="200,500">
```json
{
"id": "doc-123",
"status": "success"
}
```

```json
{
"error": "Internal server error",
"code": "INTERNAL_ERROR"
}
```
</Response>

Advanced options

Request attributes

Response attributes

Common patterns

Request and Response automatically participate in the sidebar layout on desktop, so you get a polished API reference without custom layout work.