1 ---
2 title: npm-trust
3 section: 1
4 description: Manage trusted publishing relationships between packages and CI/CD providers
5 github_repo: npm/cli
6 github_branch: latest
7 github_path: docs/lib/content/commands/npm-trust.md
8 redirect_from:
9 - /cli-commands/npm-trust
10 - /cli-commands/trust
11 - /cli-documentation/cli-commands/npm-trust
12 - /cli-documentation/cli-commands/trust
13 - /cli-documentation/commands/npm-trust
14 - /cli-documentation/commands/trust
15 - /cli-documentation/npm-trust
16 - /cli-documentation/trust
17 - /cli-documentation/v11/cli-commands/npm-trust
18 - /cli-documentation/v11/cli-commands/trust
19 - /cli-documentation/v11/commands/npm-trust
20 - /cli-documentation/v11/commands/trust
21 - /cli-documentation/v11/npm-trust
22 - /cli-documentation/v11/trust
23 - /cli/cli-commands/npm-trust
24 - /cli/cli-commands/trust
25 - /cli/commands/npm-trust
26 - /cli/commands/trust
27 - /cli/npm-trust
28 - /cli/trust
29 - /cli/v11/cli-commands/npm-trust
30 - /cli/v11/cli-commands/trust
31 - /cli/v11/commands/trust
32 - /cli/v11/npm-trust
33 - /cli/v11/trust
34 - /commands/npm-trust
35 - /commands/trust
36 ---
37
38 ### Synopsis
39
40 ```bash
41 npm trust
42 ```
43
44 Note: This command is unaware of workspaces.
45
46 ### Prerequisites
47
48 Before using npm trust commands, ensure the following requirements are met:
49
50 - **npm version**: `npm@11.10.0` or above is required. Use `npm install -g npm@^11.10.0` to update if needed.
51 - **Write permissions on the package**: You must have write access to the package you're configuring.
52 - **2FA enabled on account**: Two-factor authentication must be enabled at the account level. Even if it's not currently enabled, you must enable it to use trust commands.
53 - **Supported authentication methods**: Granular Access Tokens (GAT) with the bypass 2FA option are not supported. Legacy basic auth (username and password) credentials will not work for trust commands or endpoints.
54 - **Package must exist**: The package you're configuring must already exist on the npm registry.
55
56 ### Description
57
58 Configure trust relationships between npm packages and CI/CD providers using OpenID Connect (OIDC). This is the command-line equivalent of managing trusted publisher configurations on the npm website.
59
60 For a comprehensive overview of trusted publishing, see the [npm trusted publishers documentation](https://docs.npmjs.com/trusted-publishers).
61
62 The `[package]` argument specifies the package name. If omitted, npm will use the name from the `package.json` in the current directory.
63
64 Each trust relationship has its own set of configuration options and flags based on the OIDC claims provided by that provider. OIDC claims come from the CI/CD provider and include information such as repository name, workflow file, or environment. Since each provider's claims differ, the available flags and configuration keys are not universal—npm matches the claims supported by each provider's OIDC configuration. For specific details on which claims and flags are supported for a given provider, use `npm trust <provider> --help`.
65
66 The required options depend on the CI/CD provider you're configuring. Detailed information about each option is available in the [managing trusted publisher configurations](https://docs.npmjs.com/trusted-publishers#managing-trusted-publisher-configurations) section of the npm documentation. If a provider is repository-based and the option is not provided, npm will use the `repository.url` field from your `package.json`, if available.
67
68 Currently, the registry only supports one configuration per package. If you attempt to create a new trust relationship when one already exists, it will result in an error. To replace an existing configuration:
69
70 1. Use `npm trust list [package]` to view the ID of the existing trusted publisher
71 2. Use `npm trust revoke --id <id> [package]` to remove the existing configuration
72 3. Then create your new trust relationship
73
74 ### Bulk Usage
75
76 For maintainers managing a large number of packages, you can configure trusted publishing in bulk using bash scripting. Create a loop that iterates through package names and their corresponding configuration details, executing the `npm trust <provider>` command with the `--yes` flag for each package.
77
78 The first request will require two-factor authentication. During two-factor authentication, you'll see an option on the npm website to skip two-factor authentication for the next 5 minutes. Enabling this option will allow subsequent `npm trust <provider>` commands to proceed without two-factor authentication, streamlining the bulk configuration process.
79
80 We recommend adding a 2-second sleep between each call to avoid rate limiting. With this approach, you can configure approximately 80 packages within the 5-minute two-factor authentication skip window.
81
82 ### Configuration
83
84 ### `npm trust github`
85
86 Create a trusted relationship between a package and GitHub Actions
87
88 #### Synopsis
89
90 ```bash
91 npm trust github [package] --file [--repo|--repository] [--env|--environment] [-y|--yes]
92 ```
93
94 #### Flags
95
96 | Flag | Default | Type | Description |
97 | --- | --- | --- | --- |
98 | `--file` | null | String (required) | Name of workflow file within a repositories .GitHub folder (must end in yaml, yml) |
99 | `--repository`, `--repo` | null | String | Name of the repository in the format owner/repo |
100 | `--environment`, `--env` | null | String | CI environment name |
101 | `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
102 | `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. \* In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
103 | `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
104 | `--yes`, `-y` | null | null or Boolean | Automatically answer "yes" to any prompts that npm might print on the command line. |
105
106 ### `npm trust gitlab`
107
108 Create a trusted relationship between a package and GitLab CI/CD
109
110 #### Synopsis
111
112 ```bash
113 npm trust gitlab [package] --file [--project|--repo|--repository] [--env|--environment] [-y|--yes]
114 ```
115
116 #### Flags
117
118 | Flag | Default | Type | Description |
119 | --- | --- | --- | --- |
120 | `--file` | null | String (required) | Name of pipeline file (e.g., .gitlab-ci.yml) |
121 | `--project` | null | String | Name of the project in the format group/project or group/subgroup/project |
122 | `--environment`, `--env` | null | String | CI environment name |
123 | `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
124 | `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. \* In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
125 | `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
126 | `--yes`, `-y` | null | null or Boolean | Automatically answer "yes" to any prompts that npm might print on the command line. |
127
128 ### `npm trust circleci`
129
130 Create a trusted relationship between a package and CircleCI
131
132 #### Synopsis
133
134 ```bash
135 npm trust circleci [package] --org-id <uuid> --project-id <uuid> --pipeline-definition-id <uuid> --vcs-origin <origin> [--context-id <uuid>...] [-y|--yes]
136 ```
137
138 #### Flags
139
140 | Flag | Default | Type | Description |
141 | --- | --- | --- | --- |
142 | `--org-id` | null | String (required) | CircleCI organization UUID |
143 | `--project-id` | null | String (required) | CircleCI project UUID |
144 | `--pipeline-definition-id` | null | String (required) | CircleCI pipeline definition UUID |
145 | `--vcs-origin` | null | String (required) | CircleCI repository origin in format 'provider/owner/repo' |
146 | `--context-id` | null | null or String (can be set multiple times) | CircleCI context UUID to match |
147 | `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
148 | `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. \* In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
149 | `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
150 | `--yes`, `-y` | null | null or Boolean | Automatically answer "yes" to any prompts that npm might print on the command line. |
151
152 ### `npm trust list`
153
154 List trusted relationships for a package
155
156 #### Synopsis
157
158 ```bash
159 npm trust list [package]
160 ```
161
162 #### Flags
163
164 | Flag | Default | Type | Description |
165 | --- | --- | --- | --- |
166 | `--json` | false | Boolean | Whether or not to output JSON data, rather than the normal output. \* In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`. Not supported by all npm commands. |
167 | `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
168
169 ### `npm trust revoke`
170
171 Revoke a trusted relationship for a package
172
173 #### Synopsis
174
175 ```bash
176 npm trust revoke [package] --id=<trust-id>
177 ```
178
179 #### Flags
180
181 | Flag | Default | Type | Description |
182 | --- | --- | --- | --- |
183 | `--id` | null | String (required) | ID of the trusted relationship to revoke |
184 | `--dry-run` | false | Boolean | Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, `install`, `update`, `dedupe`, `uninstall`, as well as `pack` and `publish`. Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc. |
185 | `--registry` | "https://registry.npmjs.org/" | URL | The base URL of the npm registry. |
186
187 ### See Also
188
189 - [npm publish](/cli/v11/commands/npm-publish)
190 - [npm token](/cli/v11/commands/npm-token)
191 - [npm access](/cli/v11/commands/npm-access)
192 - [npm config](/cli/v11/commands/npm-config)
193 - [npm registry](/cli/v11/using-npm/registry)