- Documentation
- API reference
- Endpoint pages and Try it
Endpoint pages and Try it
Choose which operations get pages, add your own text to one, and decide whether readers can send requests.
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.
Pick the operations
Section titled “Pick the operations”A group with openapi and no pages lists the whole spec. To list operations yourself, name each one in pages, as
"<spec> METHOD /path":
{ "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.
Add your own text to one
Section titled “Add your own text to one”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.
---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.
openapistring"[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.
Try it
Section titled “Try it”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://orhttp://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:
{ "api": { "playground": { "display": "simple" } }}api.playground.displaystringinteractiveadds Try it.simpleshows the endpoint page and the examples, with no Try it.nonehides the playground.authis read assimple, because readers aren’t signed in to your API.
playgroundstringIn a page’s frontmatter:
interactive,simpleornone, 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.
Your values
Section titled “Your values”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.