---
title: "API fields and examples"
description: "Document an endpoint's fields, and show its request and response beside the text."
---

`ParamField` and `ResponseField` describe a field: its name, type, whether it's required, its default, and what it is.
`Expandable` folds a field's children away.

- `url` (string, required): Where Specly sends the event.

- `limit` (integer, default: `10`): How many results to return.

- `X-Legacy-Key` (string, deprecated): Use an API key instead.

- `retry` (object): How failed deliveries are retried.

  - `max_age` (integer, default: `259200`): Seconds to keep trying.

  - `ordered` (boolean): Keep events in order.

```mdx
<ParamField body="url" type="string" required>
  Where Specly sends the event.
</ParamField>

<ParamField query="limit" type="integer" default="10">
  How many results to return.
</ParamField>

<ResponseField name="retry" type="object">
  How failed deliveries are retried.

  <Expandable title="child fields">
    <ResponseField name="max_age" type="integer" default="259200">Seconds to keep trying.</ResponseField>
  </Expandable>
</ResponseField>
```

## Field props

`ParamField` and `ResponseField` are the same component. Name the field with `name`, or with the place it goes: `path`,
`query`, `body` or `header`, which also shows that place beside it.

- `type` (string): The field's type, shown as given.

- `required` (boolean, default: `false`): Shows "required".

- `deprecated` (boolean, default: `false`): Shows "deprecated" and dims the field.

- `default` (string): The default value.

- `pre` (string[]): Tags shown before the name.

- `post` (string[]): Tags shown after the details.

## Expandable props

- `title` (string, default: `child attributes`): The summary reads "Show" or "Hide", then this text.

- `defaultOpen` (boolean, default: `false`): Starts it open.

## Request and response examples

`RequestExample` and `ResponseExample` hold code blocks. Specly gathers them into a panel in the right-hand column,
beside the text, and each block becomes a tab named by its title or language. The page then drops its table of
contents. The panel is on this page, to the right. On a phone it sits below the text.

```bash cURL
curl https://api.yourcompany.dev/events -d '{"url":"https://hooks.yourcompany.dev"}'
```

```js Node
await fetch('https://api.yourcompany.dev/events', { method: 'POST' });
```

```json 201
{ "id": "evt_1", "status": "pending" }
```

````mdx
<RequestExample>

```bash cURL
curl https://api.yourcompany.dev/events -d '{"url":"https://hooks.yourcompany.dev"}'
```

```js Node
await fetch('https://api.yourcompany.dev/events', { method: 'POST' });
```

</RequestExample>

<ResponseExample>

```json 201
{ "id": "evt_1", "status": "pending" }
```

</ResponseExample>
````

A request's tabs follow the reader's language, as a [code group](/components/code-groups) does. A response's tabs, such
as status codes, stay its own.

## Panel

`Panel` puts any content you choose in the same right-hand column. Use it for something other than code. Place it at
the top level of the page, not inside another component.

```mdx
<Panel>
  Anything that belongs beside the text.
</Panel>
```
