You can manually define API endpoints in individual MDX pages. This approach is useful for small APIs or prototyping.
Setup
Configure your API settings
In your docs.json file, define your base URL and authentication method.
If you want to hide the API playground, set the display field to none. You don't need to include an authentication method if you hide the playground.
Find a full list of API configurations in Settings.
Create your endpoint pages
Create an MDX file for each endpoint. Define the title and api in the frontmatter:
The api frontmatter field accepts either a full URL or a relative path:
- Full URL like
POST https://api.acme.com/v1/users. Theserverfield indocs.jsonis ignored for that endpoint. - Relative path like
POST /v1/users. Requires aserverfield indocs.json. The server URL is prepended to the path.
Specify path parameters by wrapping them in {}:
To override the global playground display mode for a specific page, add playground to the frontmatter:
Options:
playground: 'interactive'- Display the interactive playground (default)playground: 'simple'- Display a copyable endpoint with no playgroundplayground: 'none'- Hide the playground entirely
Add parameters and responses
Use parameter and response fields to document your endpoint's parameters and return values.
Add your endpoints to your docs
Add your endpoint pages to the navigation by updating the pages field in your docs.json:
Each page path corresponds to an MDX file in your docs repository. For example, api-reference/users/create-user.mdx. Learn more about structuring your docs in Navigation.
Using OpenAPI endpoints in navigation
If you have an OpenAPI specification, you can reference endpoints directly in your navigation without creating individual MDX files. Reference specific endpoints by including the OpenAPI file path and the endpoint:
You can also set a default OpenAPI spec for a navigation group and reference endpoints by method and path:
For more details on OpenAPI integration, see OpenAPI setup.
Enable authentication
You can set authentication globally in docs.json or override it on individual pages using the authMethod field in frontmatter. A page-specific method overrides the global setting.
Bearer token
Basic authentication
API key
None
To disable authentication on a specific page, set authMethod to none: