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
Copy file name to clipboardExpand all lines: content/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens.md
+164Lines changed: 164 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,170 @@ For more information about best practices, see [AUTOTITLE](/rest/overview/keepin
117
117
118
118
If you selected an organization as the resource owner and the organization requires approval for {% data variables.product.pat_v2 %}s, then your token will be marked as `pending` until it is reviewed by an organization administrator. Your token will only be able to read public resources until it is approved. If you are an owner of the organization, your request is automatically approved. For more information, see [AUTOTITLE](/organizations/managing-programmatic-access-to-your-organization/reviewing-and-revoking-personal-access-tokens-in-your-organization).
119
119
120
+
{% ifversion fpt or ghec %}
121
+
122
+
## Pre-filling {% data variables.product.pat_v2 %} details using URL parameters
123
+
124
+
You can share templates for a {% data variables.product.pat_v2 %} via links. By directing users to token creation with relevant fields already completed, you make it easier to automate workflows and improve their developer experience.
125
+
126
+
Each supported field can be set using a specific query parameter. All parameters are optional and validated by the token generation form to ensure that the combinations of permissions and resource owner make sense.
127
+
128
+
Here is an example URL template, with line breaks for legibility:
Try the URL to create a token with `contents:read` and `metadata:read`, with the given name and description and an expiration date 45 days in the future. You'll see an error message indicating `Cannot find the specified resource owner: octodemo` because you're not a member of the `octodemo` organization.
140
+
141
+
Below are some example URLs that generate the tokens we see most often:
*[Push access to repositories](https://github.com/settings/personal-access-tokens/new?name=Repo-writing+token&description=Just+contents:write&contents=write)
145
+
*[{% data variables.product.prodname_github_models %} access](https://github.com/settings/personal-access-tokens/new?name=GitHub+Models+token&description=Used%20to%20call%20GitHub%20Models%20APIs%20to%20easily%20run%20LLMs%3A%20https%3A%2F%2Fdocs.github.com%2Fgithub-models%2Fquickstart%23step-2-make-an-api-call&user_models=read)<!-- markdownlint-disable-line search-replace Custom rule -->
146
+
*[Update code and open a pull request](https://github.com/settings/personal-access-tokens/new?name=Core-loop+token&description=Write%20code%20and%20push%20it%20to%20main%21%20Includes%20permission%20to%20edit%20workflow%20files%20for%20Actions%20-%20remove%20%60workflows%3Awrite%60%20if%20you%20don%27t%20need%20to%20do%20that&contents=write&pull_requests=write&workflows=write)
147
+
*[Manage {% data variables.product.prodname_copilot_short %} licenses in an organization](https://github.com/settings/personal-access-tokens/new?name=Core-loop+token&description=Enable%20or%20disable%20copilot%20access%20for%20users%20with%20the%20Seat%20Management%20APIs%3A%20https%3A%2F%2Fdocs.github.com%2Frest%2Fcopilot%2Fcopilot-user-management%0ABe%20sure%20to%20select%20an%20organization%20for%20your%20resource%20owner%20below%21&organization_copilot_seat_management=write)<!-- markdownlint-disable-line search-replace Custom rule -->
|`description`| string |`Used+for+deployments`| ≤ 1024 chars, URL-encoded | Pre-fills the description for the token. |
158
+
|`target_name`| string |`octodemo`| User or organization slug | Sets the token's resource target. This is the owner of the repositories that the token will be able to access. If not provided, defaults to the current user's account. |
159
+
|`expires_in`| integer |`30` or `none`| Integer between 1 and 366, or `none`| Days until expiration or `none` for non-expiring. If not provided, the default is 30 days, or less if the target has a token lifetime policy set. |
160
+
|`<permission>`| string |`contents=read`| A series of permission and access levels. | The permissions the token should have. Permissions can be set to `read`, `write`, or `admin`, but not every permission supports each of those levels. |
161
+
162
+
### Permissions
163
+
164
+
To set a permission, use its name as a query parameter, with the value specifying the desired access level. Valid access levels are `read`, `write`, and `admin`, but not every permission supports every level — some are `read`-only, some are `write`-only, and only a few accept `admin`.
165
+
166
+
Combine multiple permissions in the form `&contents=read&pull_requests=write&...`, using as many as needed.
167
+
168
+
> [!TIP]
169
+
> You do not need to include both `read` and `write` for a permission in your URL — `write` always includes `read`, and `admin` always includes `write`.
170
+
171
+
#### Account permissions
172
+
173
+
> [!IMPORTANT]
174
+
> Account permissions can only be used when the current user is the resource owner.
175
+
176
+
| Parameter name | Display name | Access levels |
177
+
| --- | --- | --- |
178
+
|`blocking`| Block another user |`read`, `write`|
179
+
|`codespaces_user_secrets`| {% data variables.product.prodname_codespaces %} user secrets |`read`, `write`|
180
+
|`copilot_messages`| {% data variables.copilot.copilot_chat_short %} |`read`|
181
+
|`copilot_editor_context`| {% data variables.product.prodname_copilot_short %} Editor Context |`read`|
182
+
|`copilot_requests`| {% data variables.product.prodname_copilot_short %} requests |`write`|
> The `copilot_requests` permission enables making {% data variables.product.prodname_copilot_short %} requests for the given user. These requests count towards the user's premium request allowance. Additional requests beyond the allowance incur overage billing. For more information about {% data variables.product.prodname_copilot_short %} requests and billing, see [AUTOTITLE](/copilot/concepts/billing/copilot-requests).
203
+
204
+
{% endif %}
205
+
206
+
#### Repository permissions
207
+
208
+
Repository permissions work for both user and organization resource owners.
0 commit comments