The REST documentation on the Magento devdocs website is generated with Swagger UI using a schema derived from the latest build of Magento 2. However, the REST API documentation on devdocs is static in that the Magento Developers website is not running an instance of Magento, and there is no live data.
Magento provides two ways to get detailed information about the structure of the REST endpoints, as described below.
Generate a full REST reference locally
For improved application security, starting from Magento 2.4.4, Swagger UI does not function if the operation mode is set to Production. It only functions in Developer mode. See how to switch operation mode here.
The Swagger UI is installed automatically on your server. As a result, you can generate live REST API documentation that can include Adobe Commerce modules, third-party modules, and extension attributes that have been installed on your system. To view this documentation, go to:
To view the Swagger documentation for a specific store view, use this URL:
The value of
store_code must be one of the following:
- The assigned store code
all. This value only applies to the CMS and Product modules. If this value is specified, the API call affects all the merchant’s stores.
By default, Magento returns documentation for resources available to anonymous users across all stores. If you specify a valid customer or admin token in the
api_key text box in the upper right corner, Swagger returns documentation for all the endpoints the user has access to. To generate an API key, call the
POST /V1/integration/customer/token endpoint or a 2FA endpoint such as
POST /V1/tfa/provider/google/authenticate with the appropriate payload, as directed in Token-based authentication.
The generated Swagger documentation provides the capability to test REST requests. A user can enter a sample request, then press the Try it out! button, and Swagger returns information such as a
curl command, a request URL, a response body, a response code, and the response header. The Try it out! button will not work unless a bearer authorization token has been specified.
REST reference for Asynchronous API
You can also use Swagger to generate live asynchronous API REST documentation. To create this documentation, add the
?type=async parameter to the standard Swagger URL:
Swagger returns information about all resources available for asynchronous REST APIs.
Return the JSON schema for one or more services
You can use a REST client to generate the JSON schema for one or more services. In the client, set the method to
GET and the URL to
To return information about all services:
Return the complete JSON schema
To return the complete JSON schema, specify the
?services=all parameter in the URL. The default
all, but you can also specify
default or a store code defined on the system. For example:
The base URL for returning the asynchronous schema is
By default, the
/swagger endpoint is open on Magento instances. Leaving it open on a public instance could potentially expose system information that should not be readable.
To close off the
/swagger endpoint, disable the following modules:
To ensure proper functionality, always test Magento instances after disabling modules.
You may also use web server rewrite rules to redirect users trying to access the endpoint: