Skip to content

API fields and examples

Document an endpoint's fields, and show its request and response beside the text.

2 min read

Updated

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.

urlstringbodyrequired

Where Specly sends the event.

limitintegerquerydefault: 10

How many results to return.

X-Legacy-Keystringheaderdeprecated

Use an API key instead.

retryobject

How failed deliveries are retried.

ShowHide child fields
max_ageintegerdefault: 259200
Seconds to keep trying.
orderedboolean
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>

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.

typestring
The field’s type, shown as given.
requiredbooleandefault: false
Shows “required”.
deprecatedbooleandefault: false
Shows “deprecated” and dims the field.
defaultstring
The default value.
prestring[]
Tags shown before the name.
poststring[]
Tags shown after the details.
titlestringdefault: child attributes

The summary reads “Show” or “Hide”, then this text.

defaultOpenbooleandefault: false
Starts it open.

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.

cURL
curl https://api.yourcompany.dev/events -d '{"url":"https://hooks.yourcompany.dev"}'
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 does. A response’s tabs, such as status codes, stay its own.

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>
Was this page helpful?

Report a problem

What’s the problem?

The docs team sees this. Other readers don’t.