You can connect more than one API in Postman to the same Git repository. For each API you want to connect, repeat the process to set up the Git integration. For complete steps, see Using a cloud-hosted Git repository or Using an on-premises Git repository.
It's important to make sure your APIs remain separated in the repository to avoid changes from one API getting applied to another API. You can separate your APIs in the repository using either files or branches.
You can keep your APIs separate by adding different definition files to each API. Definition files can exist at the root level of the repository or in any subdirectory. Also, when setting up the Git integrations, make sure to select a different collections folder for each API. This will keep your collection files separated.
For example, if you have an emails
API and an sms
API, you could have the following file structure for the main
branch in your repository:
emails-api.yaml
- Root definition file for the emails
APIemails/postman/collections
- Collections directory for the emails
APIsms-api.yaml
- Root definition file for the sms
APIsms/postman/collections
- Collections directory for the sms
APIIf you're working on a multi-file API definition, you can choose which files to add to each API. Make sure to select the correct definition files when adding files to an API.
For OpenAPI 2.0 and 3.0 APIs, when you add definition files to your API, Postman scans for any referenced files in the same repository and automatically adds them to your API. If two APIs are in the same repository, and each API's root definition files reference the same file, that file will be added to both APIs. In this case, changes made in one API may affect the other API.
If there are common components referenced by multiple APIs, you can keep them in separate directories (such as schemas
or responses
). You can then add the common component files to each API as needed. This enables you to reuse the same component file in more than one API definition. Keep in mind that if you push changes to a component file from one API, other APIs that use the same component will also be affected.
You can keep your APIs separate by using a different branch for each API in the repository. For example, if you have a notifications-v1
API and a notifications-v2
API, you could have the following branch and directory structure in your repository:
notifications-v1
branch
notifications.yaml
- Root definition file for the notifications-v1
APIpostman/collections
- Collections directory for the notifications-v1
APInotifications-v2
branch
notifications.yaml
- Root definition file for the notifications-v2
APIpostman/collections
- Collections directory for the notifications-v2
APIAs you work on your APIs, you can switch branches and push or pull changes for any branch. To keep your APIs separate, always make sure you are on the correct branch before pushing or pulling changes.
Last modified: 2023/09/15
Additional resources
Videos
Blog posts