---
title: Request & Response Example
description: Show separate request and response code cards with language selection and response status tabs.
url: https://pr-79-a9c4e9fe1b6c.thally.app/components/request-response-example
---

# Request & Response Example

Show separate request and response code cards with language selection and response status tabs.

Use `<RequestExample>` and `<ResponseExample>` to present HTTP examples as
separate labeled cards. Put each fenced sample directly inside its wrapper.
Request variants appear in a language menu; response variants appear as status tabs.

## Request languages and response statuses

```bash cURL
curl -X POST https://api.example.com/pets \
  -H "Content-Type: application/json" \
  -d '{"name": "Buddy", "species": "dog"}'
```

```python Python
import requests

response = requests.post(
    "https://api.example.com/pets",
    json={"name": "Buddy", "species": "dog"},
)
```

```json 201 Created
{ "id": "pet_123", "name": "Buddy", "species": "dog" }
```

```json 400 Bad Request
{ "error": "A pet name is required." }
```

````mdx
<RequestExample>
```bash cURL
curl -X POST https://api.example.com/pets \
  -H "Content-Type: application/json" \
  -d '{"name": "Buddy", "species": "dog"}'
```

```python Python
import requests

response = requests.post(
    "https://api.example.com/pets",
    json={"name": "Buddy", "species": "dog"},
)
```
</RequestExample>

<ResponseExample>
```json 201 Created
{ "id": "pet_123", "name": "Buddy", "species": "dog" }
```

```json 400 Bad Request
{ "error": "A pet name is required." }
```
</ResponseExample>
````

Label each request fence with its language, such as `cURL` or `Python`. The
selected language is shared with compatible code groups, generated API request
cards, and the Try it modal. If a group does not offer that language, it keeps a compatible earlier choice
or shows its first sample. The preference survives a reload when browser storage is available.

Label response fences with the status code and optional description, such as
`201 Created` or `400 Bad Request`. Readers can select a status tab or move
between tabs with the arrow keys. Changing the status does not change the
request language. On small screens, tabs keep the status code visible and hide
the longer description.

These authored responses are examples from your documentation. To display an
actual API response, use [Try it](/guides/api-playground).

## Link fields to examples

On an API endpoint page, hovering or focusing a parameter row or a linked code
line highlights matching field names across the documentation and samples.
Use the same names in your `ParamField` and `ResponseField` entries and in the
example keys. Links are inferred from recognized field-name positions, such
as JSON keys, rather than arbitrary matching text.

## Next steps

- [Code blocks and language groups](/components/code-blocks)
- [Document request parameters](/components/param-field)
- [Document response fields](/components/response-field)
- [Generate an API reference](/guides/api-reference-setup)