Contentstack provides OpenAPI files for its Content Delivery and Content Management APIs in JSON format. These files allow you to automatically generate API documentation, test requests, and streamline your development workflow.
This tutorial walks you through how to use these JSON files with Swagger Editor to interact with Contentstack’s APIs.
To use CDA with Swagger, follow these steps:
- Download the latest CDA JSON file and navigate to Swagger Editor.
- Click File on top-right and select Import File to upload the JSON.
- Open any API request and click the Try it out button to unlock the parameter fields.
- Enter your stack's values or use the default demo stack credentials.
- Click Execute.
The Responses section will display the following:
- The API request in cURL format.
- The response body (JSON).
- The HTTP status code.
Note: To ensure you are testing against the most accurate environment, always download the latest CDA file from the Contentstack documentation site.
To use CDA with Swagger, follow these steps:
- Download the latest CMA JSON file and navigate to Swagger Editor.
- Click File on top-right and select Import File to upload the JSON.
- Before running a request, ensure you have an authentication method ready:
- Management Token: We recommend using a management token for CMA requests. Refer to the Generate Management Token guide for details.
- Authtoken: Run the Log in API request under the User Session section to retrieve an
authtokenin the response. - Open any API request and click the Try it out button to unlock the parameter fields.
- Enter your stack's values or use the default demo stack credentials.
- Click Execute.
The Responses section will display the following:
- The API request in cURL format.
- The response body (JSON).
- The HTTP status code.
Note:
- We recommend using the Management token for executing CMA requests rather than authtoken.
- For any DELETE request that has a request body in it, you won’t be able to run it in Swagger.