Share API specification via webhook in SwaggerHub
November 12, 2021
Karnam Dinesh Kumar
In API lifecycle management, synchronizing API specifications with different applications is an inevitable part of the DevOps process or API development workflow. There is a prebuilt integration in SwaggerHub which enables the syncing between the SwaggerHub and third-party applications such as GitLab, Amazon API Gateway, GitHub, etc. As the IT world is changing rapidly with new platforms and applications, prebuilt integrations will not be always available and there is a need for custom integrations. Webhook integration in SwaggerHub is one of the ways to integrate with a third-party system where prebuilt integrations are not available.
What is SwaggerHub webhook integration?
SwaggerHub webhook sends a POST request to a specific URL every time an API is
published in SwaggerHub. You can use webhooks to notify external systems when your API definitions are updated and to trigger your custom actions based on events from SwaggerHub. Webhook comes in handy when the third-party system is having an endpoint to receive the payload (having API spec) and process it further.
How to configure a SwaggerHub webhook:
- Open the API in SwaggerHub.
- If the API has several versions, select the version for which you want to add a webhook.
- Click the API name, switch to the
Integrations tab, and click
Add New Integrations.
- Select the webhook from the list of integrations, and click Add.
- Provide the
Name, Payload URL, select the
Content Type as
To demonstrate the webhook payload, we have created a MuleSoft endpoint [POST] which has been configured as the SwaggerHub webhook as payload URL. In the configuration, it has been mentioned that the webhook will be triggered whenever the spec is saved/published. Name (can be any random name) has been configured to identify the webhook integration in SwaggerHub.
Create and then
- When an API version is saved or published, SwaggerHub sends a POST request with payload data that contains the details shown below to the specified URL.
Note: logs details shown here are from MuleSoft Cloud Platform
Join the conversation
What are your thoughts on this blog? Drop us a line below. We’d love to hear from you.