You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5,42 +5,328 @@ description: Publish a Postman collection full of example requests and responses
5
5
6
6
Publish your Postman collection directly to Postman workspaces, making it easy for your team and API consumers to discover and test your endpoints.
7
7
8
-
## Publish directly to Postman
8
+
<Frame>
9
+
<imgsrc="assets/collection-success.png"alt="Collection published on Postman" />
10
+
</Frame>
9
11
10
-
To publish your collection directly to Postman, configure the output and specify the name of your collection:
12
+
<Info>
13
+
This page assumes that you have:
11
14
12
-
```yaml title="generators.yml" {6-9}
15
+
* An initialized `fern` folder. See [Set up the `fern`
16
+
folder](/sdks/overview/quickstart).
17
+
* A GitHub repository for your Postman collection. See [Project structure](/sdks/overview/project-structure).
18
+
* A Postman generator group in `generators.yml`. See [Postman
19
+
Quickstart](quickstart#add-the-sdk-generator).
20
+
21
+
</Info>
22
+
23
+
## Generate an API key
24
+
25
+
<Steps>
26
+
27
+
<Steptitle="Log into Postman">
28
+
29
+
Log into [Postman](https://www.postman.com/) or create a new account.
30
+
31
+
</Step>
32
+
33
+
<Steptitle="Navigate to API Keys">
34
+
35
+
1. Click on your profile picture.
36
+
1. Select **Settings**.
37
+
1. Select **API Keys**.
38
+
39
+
<Frame>
40
+
<imgsrc="assets/api-key.png"alt="Collection published on Postman" />
41
+
</Frame>
42
+
43
+
</Step>
44
+
45
+
<Steptitle="Generate key">
46
+
Click on **Generate API Key**. Name your key, then click **Generate**.
47
+
48
+
<Warning>Save your new token – it won't be displayed after you leave the page.</Warning>
49
+
50
+
</Step>
51
+
52
+
</Steps>
53
+
54
+
## Configure Postman publication
55
+
56
+
You'll need to update your `generators.yml` file to configure the output location, repository, publishing mode, and authentication credentials for Postman publishing. Your `generators.yml`[should live in your source repository](/sdks/overview/project-structure) (or on your local machine), not the repository that contains your Postman collection file.
57
+
<Steps>
58
+
<Steptitle="Configure `output` location">
59
+
60
+
In the `group` for your Postman collection, change the output location from `local-file-system` (the default) to `postman` to indicate that Fern should publish your collection directly to Postman:
Optionally set the mode to control how Fern handles Postman publishing:
93
+
94
+
- `mode: release` (default): Fern generates code, commits to main, and tags a release automatically
95
+
- `mode: pull-request`: Fern generates code and creates a PR for you to review before release
96
+
- `mode: push`: Fern generates code and pushes to a branch you specify for you to review before release
97
+
98
+
You can also configure other settings, like the reviewers or license. Refer to the [full `github` (`generators.yml`) reference](/sdks/reference/generators-yml#github) for more information.
Fern's Postman publishing uses a simple versioning approach based on whether you specify a `collection-id`:
136
+
137
+
- **Update existing collection:** Specify `collection-id`. Fern updates the same collection each time. Use this option to keep your workspace clean with one collection that is always current.
138
+
- **Create new collections:** Omit `collection-id`. Fern creates a new collection with each publish. Use this option to maintain historical versions or separate environment collections.
To publish to a particular collection, configure the output and specify the name of your collection and collection ID:
177
+
</Step>
29
178
30
-
```yaml title="generators.yml" {10}
179
+
<Step title="Specify the collection name and ID">
180
+
181
+
You can get your collection name and ID by navigating to your workspace and either:
182
+
- Copying the ID from the URL: `https://user-name.postman.co/workspace/workspace-name~workspace-id/collection/COLLECTION-ID`
183
+
- Making a GET request to `https://api.getpostman.com/collections`. You must also enter your API key in the **Auth** tab. Send the request. This request returns configuration, including IDs and names, for all of your collections.
collection-name: Your collection name # Name of the existing collection
198
+
github:
199
+
repository: your-org/company-postman
43
200
```
201
+
</Step>
202
+
</Steps>
203
+
</Accordion>
204
+
</AccordionGroup>
205
+
206
+
## Publish your collection
207
+
208
+
Decide how you want to publish your collection to Postman. You can use GitHub workflows for automated releases or publish directly via the CLI.
209
+
210
+
<AccordionGroup>
211
+
212
+
<Accordion title="Release via a GitHub workflow">
213
+
214
+
Set up a release workflow via [GitHub Actions](https://docs.github.com/en/actions/get-started/quickstart) so you can trigger new Postman collection releases directly from your source repository.
215
+
216
+
<Steps>
217
+
<Step title="Set up authentication">
218
+
219
+
Open your source repository in GitHub. Click on the **Settings** tab. Then, under the **Security** section, open **Secrets and variables** > **Actions**.
220
+
221
+
You can also use the url `https://github.com/<your-repo>/settings/secrets/actions`.
222
+
223
+
</Step>
224
+
<Step title="Add secret for your API key">
225
+
226
+
1. Select **New repository secret**.
227
+
1. Name your secret `POSTMAN_API_KEY`.
228
+
1. Add the corresponding API key you generated above.
229
+
1. Click **Add secret**.
230
+
231
+
</Step>
232
+
<Step title="Add secret for your Fern Token">
233
+
234
+
1. Select **New repository secret**.
235
+
1. Name your secret `FERN_TOKEN`.
236
+
1. Add your Fern token. If you don't already have one, generate one by
237
+
running `fern token`. By default, the `fern_token` is generated for the
238
+
organization listed in `fern.config.json`.
239
+
1. Click **Add secret**.
240
+
241
+
</Step>
242
+
<Step title="Set up a new workflow">
243
+
244
+
Set up a CI workflow that you can manually trigger from the GitHub UI. In your repository, navigate to **Actions**. Select **New workflow**, then **Set up workflow yourself**. Add a workflow that's similar to this:
You can alternatively configure your workflow to execute `on: [push]`. See Vapi's [npm publishing GitHub Action](https://github.com/VapiAI/server-sdk-typescript/blob/main/.github/workflows/ci.yml) for an example.
276
+
</Note>
277
+
</Step>
278
+
279
+
<Step title="Regenerate and release your collection">
280
+
281
+
Navigate to the **Actions** tab, select the workflow you just created, specify a version number, and click **Run workflow**. This regenerates your collection.
282
+
283
+
<Note>
284
+
Specifying the version number will update the release number in your GitHub repository, but won't version your collection.
<Step title="Regenerate and release your collection">
308
+
309
+
Regenerate your collection.
310
+
311
+
<Note>
312
+
The `--version` parameter in `fern generate --version X.X.X` creates a GitHub release tag but doesn't affect Postman collection naming or versioning. Collection versioning is controlled by the `collection-id` configuration.
The rest of the release process depends on your chosen mode:
2
+
3
+
-**Release mode (default):** If you didn't specify a `mode` or set `mode: release`, no further action is required. Fern initiates the publishing workflow in your collection repository.
4
+
5
+
-**Pull request or push mode:** If you set `mode: pull-request` or `mode: push`, Fern creates a pull request or pushes to a branch respectively. Review and merge the PR (`pull-request`) or branch (`push`), then [tag a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) to initiate the publishing
6
+
7
+
Once the workflow completes, you can view your new or updated collection by logging into Postman and navigating to your workspace.
8
+
9
+
<Frame>
10
+
<imgsrc="assets/collection-success.png"alt="Collection published on Postman" />
You can get your workspace ID by navigating to your workspace and either:
2
+
3
+
- Copying the ID from the URL: `https://user-name.postman.co/workspace/workspace-name~WORKSPACE-ID/request/create`
4
+
- Making a GET request to `https://api.getpostman.com/workspaces`. You must also enter your API key in the **Auth** tab. This request returns configuration, including IDs, for all of your workspaces.
5
+
6
+
<Frame>
7
+
<imgsrc="assets/get-workspace-id.png"alt="Collection published on Postman" />
0 commit comments