Automatically sync Swagger APIs with Postman when Bitbucket files are changed

Hi @danny-dainton,

Hi, our APIs are defined in OpenAPI and the specification is stored in Bitbucket. We use Postman collections for API testing.
Currently, when APIs are added or deprecated in Swagger, the Postman collection has to be updated manually.
Is there a way to automatically sync the Postman collection whenever the Swagger file changes in Bitbucket? Is there any CI/CD pipeline solution available???

1 Like

Hi,

Yes — what you’re describing is a common scenario, and there are ways to automate syncing Postman collections from your OpenAPI/Swagger files stored in Bitbucket. Here are some approaches:

1. Use Postman’s CLI (newman) with OpenAPI importer

  • Postman has a CLI tool called Newman and also supports importing OpenAPI/Swagger specs directly.

  • You can write a script in your CI/CD pipeline to:

    1. Pull the latest Swagger/OpenAPI spec from Bitbucket

    2. Import it into Postman using the CLI or Postman API

    3. Automatically update the collection

2. Postman API for automated collection updates

  • Postman provides a Collections API where you can programmatically create or update collections.

  • Combine this with a CI/CD pipeline (GitHub Actions, GitLab CI, Bitbucket Pipelines, Jenkins, etc.) to trigger whenever your Swagger file changes.

3. CI/CD pipeline example

  • In Bitbucket Pipelines (or another CI tool), add a step that:

    # Example pseudo-steps
    git pull origin main
    # Convert Swagger to Postman collection (via Postman API or openapi-to-postman tool)
    openapi2postmanv2 -s api-spec.yaml -o collection.json -p
    # Use Postman API to update the collection
    curl -X PUT "https://api.getpostman.com/collections/<COLLECTION_UID>" \
         -H "X-Api-Key: <YOUR_API_KEY>" \
         -H "Content-Type: application/json" \
         -d @collection.json
    

4. Tools to help

  • openapi-to-postman – Converts OpenAPI specs to Postman collections automatically.

  • Postman API + Newman – For testing and collection management in CI/CD.

With this setup, every time a Swagger file is updated in Bitbucket, your pipeline can automatically regenerate and update the Postman collection without manual intervention.

If you want, I can draft a ready-to-use Bitbucket Pipeline example that fully automates this.