Skip to content

Endpoint pages and Try it

Choose which operations get pages, add your own text to one, and decide whether readers can send requests.

2 min read

Updated

Each operation in your spec becomes an endpoint page: a bar with the method and path, then the description, the authorization, the parameters, the request body and the responses. Beside them, request examples in cURL, JavaScript, Python and Go, and then each response.

A group with openapi and no pages lists the whole spec. To list operations yourself, name each one in pages, as "<spec> METHOD /path":

docs.json
{
"group": "Deploys",
"pages": [
"openapi.yaml POST /api/sites/{id}/deploy",
"openapi.yaml GET /api/sites/{id}/analytics"
]
}

When the group names its spec with openapi, or api.openapi sets one, leave the spec out: "POST /api/sites/{id}/deploy". The sidebar shows each operation’s method as a badge.

Give a page its own file, and point it at an operation with openapi in its frontmatter. What you write shows after the bar and before the parameters.

guides/start-a-deploy.mdx
---
title: "Start a deploy"
openapi: "POST /api/sites/{id}/deploy"
---
Call this from CI after your docs merge.

List the page in docs.json like any other page. If the operation isn’t in a spec, the page shows a notice with your own content, and the build warns.

openapistringpath

"[spec] METHOD /path". Leave out the spec when the site has one. To write the page without a spec, see Hand-written endpoint pages.

To show your own request and response examples, put RequestExample and ResponseExample in the page. They replace the generated ones. See API fields and examples.

On an interactive page, Try it opens a dialog with a field for each parameter and for the authorization, and sends the request to the API. The reader’s browser sends it, straight to the spec’s first server. Specly doesn’t see it.

That has two limits:

  • The server must be an https:// or http:// address. Without one, Try it says there’s no server to send to.
  • The API must answer requests from your docs site (CORS). If it doesn’t, the browser blocks the call.

Choose how much readers get for the whole site in docs.json:

docs.json
{
"api": { "playground": { "display": "simple" } }
}
api.playground.displaystringpathdefault: interactive

interactive adds Try it. simple shows the endpoint page and the examples, with no Try it. none hides the playground. auth is read as simple, because readers aren’t signed in to your API.

playgroundstringpath

In a page’s frontmatter: interactive, simple or none, for that page only. Anything else is ignored with a warning, and the site’s setting applies.

A request that starts something real, like a deploy, is a good reason to choose simple. Specly’s own API reference does: a call from a browser would also fail the CORS check.

If a request example holds a placeholder such as {{ORG_ID}} and you’ve listed it in specly.placeholders, readers fill it in once with Your values, and Try it uses it. See Runnable code.

Was this page helpful?

Report a problem

What’s the problem?

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