You can use these GitHub Enterprise Cloud endpoints to administer your enterprise account.
端点 URL
REST API 端点 是以下 URL 的前缀:
http(s)://hostname/api/v3/
身份验证
GitHub AE 安装设施的 API 端点接受与 GitHub.com 相同的身份验证方法。 您可以使用 OAuth 令牌或基本身份验证来验证自己。
企业管理 API 端点只有经过身份验证的 GitHub AE 站点管理员可以访问。
版本信息
每个 API 的响应标头中都会返回企业的当前版本:X-GitHub-Enterprise-Version: github-ae@latest.0
您也可以通过调用元端点来读取当前版本。
休息时加密
您可以使用休息时加密 API 来管理用于对 GitHub AE 上的数据进行加密的密钥。 更多信息请参阅“为企业配置数据加密”。
Get an encryption key
Warning: The encryption at rest endpoints are currently in beta and are subject to change.
Gets information about the current key used for encryption at rest.
get /enterprise/encryption
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/encryption
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/encryption')
Default response
Status: 200 OK
{
"updated_at": "2020-09-09T10:04:26.000Z",
"primary_key_version": "9b24a469887e416787173383958c6fb9",
"replica_key_version": "4621542832e447f285ea2dbeaf6f621b",
"backup_key_version": "d067172e711b44a5963fe53b6b976c0f"
}
Update an encryption key
Warning: The encryption at rest endpoints are currently in beta and are subject to change.
Updates the current encryption at rest key with a new private key.
You can add a new encryption key as often as you need. When you add a new key, the old key is discarded.
Your enterprise won't experience downtime when you update the key, because the key vault that GitHub manages uses the "envelope" technique. For more information, see Encryption and decryption via the envelope technique in the Azure documentation.
Your 2048 bit RSA private key should be in PEM format. For more information, see "Configuring data encryption for your enterprise."
patch /enterprise/encryption
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
key |
string | body |
Required. A 2048 bit RSA private key in PEM format. |
代码示例
Shell
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/encryption \
-d '{"key":"key"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /enterprise/encryption', {
key: 'key'
})
Response
Status: 202 Accepted
{
"message": "Started update of private key for encryption at rest.",
"status_url": "https://octocoders.github.io/api/v3/enterprise/encryption/status/6020dd37-ce35-49e8-a15b-0b9df458c049"
}
Disable encryption at rest
Warning: The encryption at rest endpoints are currently in beta and are subject to change.
Disables encryption at rest and deletes the encryption key. To freeze your enterprise, you can disable encryption at rest. For example, you can freeze your enterprise in the case of a breach. It takes approximately ten minutes to disable encryption at rest. To check the status, use the "Get an encryption status" REST API.
To unfreeze your enterprise after you've disabled encryption at rest, you must contact Support. For more information, see "Receiving enterprise support."
delete /enterprise/encryption
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/encryption
JavaScript (@octokit/core.js)
await octokit.request('DELETE /enterprise/encryption')
Response
Status: 202 Accepted
{
"message": "Started disabling encryption at rest.",
"status_url": "https://octocoders.github.io/api/v3/enterprise/encryption/status/db8ef711-ef82-464b-9013-5e0a1bb0031e"
}
Get an encryption status
Warning: The encryption at rest endpoints are currently in beta and are subject to change.
Checks the status of updating an encryption key or disabling encryption at rest.
get /enterprise/encryption/status/{request_id}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
request_id |
string | path | The id provided in the |
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/encryption/status/REQUEST_ID
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/encryption/status/{request_id}', {
request_id: 'request_id'
})
Response
Status: 200 OK
{
"result": "started",
"error": null
}
Response if the url cannot be found
Status: 404 Not Found
管理统计
管理统计 API 提供有关安装设施的各种指标。 它只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 404
响应。
Get statistics
There are a variety of types to choose from:
Type | Description |
---|---|
issues | The number of open and closed issues. |
hooks | The number of active and inactive hooks. |
milestones | The number of open and closed milestones. |
orgs | The number of organizations, teams, team members, and disabled organizations. |
comments | The number of comments on issues, pull requests, commits, and gists. |
pages | The number of GitHub Pages sites. |
users | The number of suspended and admin users. |
gists | The number of private and public gists. |
pulls | The number of merged, mergeable, and unmergeable pull requests. |
repos | The number of organization-owned repositories, root repositories, forks, pushed commits, and wikis. |
all | All of the statistics listed above. |
These statistics are cached and will be updated approximately every 10 minutes.
get /enterprise/stats/{type}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
type |
string | path |
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/stats/TYPE
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/{type}', {
type: 'type'
})
Default response
Status: 200 OK
{
"repos": {
"total_repos": 212,
"root_repos": 194,
"fork_repos": 18,
"org_repos": 51,
"total_pushes": 3082,
"total_wikis": 15
},
"hooks": {
"total_hooks": 27,
"active_hooks": 23,
"inactive_hooks": 4
},
"pages": {
"total_pages": 36
},
"orgs": {
"total_orgs": 33,
"disabled_orgs": 0,
"total_teams": 60,
"total_team_members": 314
},
"users": {
"total_users": 254,
"admin_users": 45,
"suspended_users": 21
},
"pulls": {
"total_pulls": 86,
"merged_pulls": 60,
"mergeable_pulls": 21,
"unmergeable_pulls": 3
},
"issues": {
"total_issues": 179,
"open_issues": 83,
"closed_issues": 96
},
"milestones": {
"total_milestones": 7,
"open_milestones": 6,
"closed_milestones": 1
},
"gists": {
"total_gists": 178,
"private_gists": 151,
"public_gists": 25
},
"comments": {
"total_commit_comments": 6,
"total_gist_comments": 28,
"total_issue_comments": 366,
"total_pull_request_comments": 30
}
}
公告
公告 API 允许您管理企业中的全局公告横幅。 更多信息请参阅“自定义企业的用户消息”。
Get the global announcement banner
Gets the current message and expiration date of the global announcement banner in your enterprise.
get /enterprise/announcement
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/announcement
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/announcement')
Default response
Status: 200 OK
{
"announcement": "Very **important** announcement about _nothing_.",
"expires_at": "2021-01-01T00:00:00.000+00:00"
}
Set the global announcement banner
Sets the message and expiration time for the global announcement banner in your enterprise.
patch /enterprise/announcement
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
announcement |
string | body |
Required. The announcement text in GitHub Flavored Markdown. For more information about GitHub Flavored Markdown, see "Mastering markdown." |
expires_at |
string or null | body |
The time at which the announcement expires. This is a timestamp in ISO 8601 format: |
代码示例
Shell
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/announcement \
-d '{"announcement":"announcement"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /enterprise/announcement', {
announcement: 'announcement'
})
Default response
Status: 200 OK
{
"announcement": "Very **important** announcement about _nothing_.",
"expires_at": "2021-01-01T00:00:00.000+00:00"
}
Remove the global announcement banner
Removes the global announcement banner in your enterprise.
delete /enterprise/announcement
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/announcement
JavaScript (@octokit/core.js)
await octokit.request('DELETE /enterprise/announcement')
Default Response
Status: 204 No Content
全局 web 挂钩
全局 web 挂钩安装在企业上。 您可以使用全局 web 挂钩来自动监视、响应或实施针对企业上的用户、组织、团队和仓库的规则。 全局 web 挂钩可以订阅组织、用户、仓库、团队、成员、成员身份、复刻和 ping 事件类型。
此 API 只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 404
响应。 要了解如何配置全局 web 挂钩,请参阅关于全局 web 挂钩。
get /admin/hooks
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
This API is under preview and subject to change. 查看预览通知 |
accept |
string | header | This API is under preview and subject to change. |
per_page |
integer | query | Results per page (max 100) |
page |
integer | query | Page number of the results to fetch. |
代码示例
Shell
curl \
-H "Accept: application/vnd.github.superpro-preview+json" \
https://api.github.com/admin/hooks
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/hooks', {
mediaType: {
previews: [
'superpro'
]
}
})
Default response
Status: 200 OK
[
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization",
"user"
],
"config": {
"url": "https://example.com",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
]
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
☝️ 此标头必填.
post /admin/hooks
参数
Name | Type | In | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
accept |
string | header |
This API is under preview and subject to change. 查看预览通知 |
||||||||
accept |
string | header | This API is under preview and subject to change. |
||||||||
name |
string | body |
Required. Must be passed as "web". |
||||||||
config |
object | body |
Required. Key/value pairs to provide settings for this webhook. |
||||||||
config object |
url (string) |
Required. The URL to which the payloads will be delivered. |
content_type (string) |
The media type used to serialize the payloads. Supported values include |
secret (string) |
If provided, the |
insecure_ssl (string) |
Determines whether the SSL certificate of the host for |
events
The events that trigger this webhook. A global webhook can be triggered by user
and organization
events. Default: user
and organization
.
active
Determines if notifications are sent when the webhook is triggered. Set to true
to send notifications.
true
代码示例
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.superpro-preview+json" \
https://api.github.com/admin/hooks \
-d '{"name":"name","config":{"url":"url","content_type":"content_type","secret":"secret","insecure_ssl":"insecure_ssl"}}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/hooks', {
name: 'name',
config: {
url: 'url',
content_type: 'content_type',
secret: 'secret',
insecure_ssl: 'insecure_ssl'
},
mediaType: {
previews: [
'superpro'
]
}
})
Default response
Status: 201 Created
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization",
"user"
],
"config": {
"url": "https://example.com",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
☝️ 此标头必填.
get /admin/hooks/{hook_id}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
This API is under preview and subject to change. 查看预览通知 |
accept |
string | header | This API is under preview and subject to change. |
hook_id |
integer | path |
代码示例
Shell
curl \
-H "Accept: application/vnd.github.superpro-preview+json" \
https://api.github.com/admin/hooks/42
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/hooks/{hook_id}', {
hook_id: 42,
mediaType: {
previews: [
'superpro'
]
}
})
Default response
Status: 200 OK
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization",
"user"
],
"config": {
"url": "https://example.com",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
☝️ 此标头必填.
Update a global webhook
Parameters that are not provided will be overwritten with the default value or removed if no default exists.
patch /admin/hooks/{hook_id}
参数
Name | Type | In | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
accept |
string | header |
This API is under preview and subject to change. 查看预览通知 |
||||||||
accept |
string | header | This API is under preview and subject to change. |
||||||||
hook_id |
integer | path | |||||||||
config |
object | body |
Key/value pairs to provide settings for this webhook. |
||||||||
config object |
url (string) |
Required. The URL to which the payloads will be delivered. |
content_type (string) |
The media type used to serialize the payloads. Supported values include |
secret (string) |
If provided, the |
insecure_ssl (string) |
Determines whether the SSL certificate of the host for |
events
The events that trigger this webhook. A global webhook can be triggered by user
and organization
events. Default: user
and organization
.
active
Determines if notifications are sent when the webhook is triggered. Set to true
to send notifications.
true
代码示例
Shell
curl \
-X PATCH \
-H "Accept: application/vnd.github.superpro-preview+json" \
https://api.github.com/admin/hooks/42 \
-d '{"config":{"url":"url","content_type":"content_type","secret":"secret","insecure_ssl":"insecure_ssl"}}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /admin/hooks/{hook_id}', {
hook_id: 42,
config: {
url: 'url',
content_type: 'content_type',
secret: 'secret',
insecure_ssl: 'insecure_ssl'
},
mediaType: {
previews: [
'superpro'
]
}
})
Default response
Status: 200 OK
{
"type": "Global",
"id": 1,
"name": "web",
"active": true,
"events": [
"organization"
],
"config": {
"url": "https://example.com",
"content_type": "form",
"insecure_ssl": "0"
},
"updated_at": "2017-12-07T00:14:59Z",
"created_at": "2017-12-07T00:14:59Z",
"url": "https://api.github.com/admin/hooks/1",
"ping_url": "https://api.github.com/admin/hooks/1/pings"
}
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
☝️ 此标头必填.
delete /admin/hooks/{hook_id}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
This API is under preview and subject to change. 查看预览通知 |
accept |
string | header | This API is under preview and subject to change. |
hook_id |
integer | path |
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.superpro-preview+json" \
https://api.github.com/admin/hooks/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/hooks/{hook_id}', {
hook_id: 42,
mediaType: {
previews: [
'superpro'
]
}
})
Default Response
Status: 204 No Content
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
☝️ 此标头必填.
Ping a global webhook
This will trigger a ping event to be sent to the webhook.
post /admin/hooks/{hook_id}/pings
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
This API is under preview and subject to change. 查看预览通知 |
accept |
string | header | This API is under preview and subject to change. |
hook_id |
integer | path |
代码示例
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.superpro-preview+json" \
https://api.github.com/admin/hooks/42/pings
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/hooks/{hook_id}/pings', {
hook_id: 42,
mediaType: {
previews: [
'superpro'
]
}
})
Default Response
Status: 204 No Content
预览通知
The Global Webhooks API is currently available for developers to preview. To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.superpro-preview+json
☝️ 此标头必填.
许可
许可 API 提供有关企业许可的信息。 它只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 404
响应。
get /enterprise/settings/license
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/enterprise/settings/license
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/settings/license')
Default response
Status: 200 OK
{
"seats": 1400,
"seats_used": 1316,
"seats_available": 84,
"kind": "standard",
"days_until_expiration": 365,
"expire_at": "2016/02/06 12:41:52 -0600"
}
组织
组织管理 API 允许您在企业上创建组织。 它只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 404
响应。
post /admin/organizations
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
login |
string | body |
Required. The organization's username. |
admin |
string | body |
Required. The login of the user who will manage this organization. |
profile_name |
string | body |
The organization's display name. |
代码示例
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/organizations \
-d '{"login":"login","admin":"admin"}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/organizations', {
login: 'login',
admin: 'admin'
})
Default response
Status: 201 Created
{
"login": "github",
"id": 1,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://api.github.com/orgs/github",
"repos_url": "https://api.github.com/orgs/github/repos",
"events_url": "https://api.github.com/orgs/github/events",
"hooks_url": "https://api.github.com/orgs/github/hooks",
"issues_url": "https://api.github.com/orgs/github/issues",
"members_url": "https://api.github.com/orgs/github/members{/member}",
"public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"description": "A great organization"
}
patch /admin/organizations/{org}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
org |
string | path | |
login |
string | body |
Required. The organization's new name. |
代码示例
Shell
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/organizations/ORG \
-d '{"login":"login"}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /admin/organizations/{org}', {
org: 'org',
login: 'login'
})
Response
Status: 202 Accepted
{
"message": "Job queued to rename organization. It may take a few minutes to complete.",
"url": "https://<hostname>/api/v3/organizations/1"
}
用户
用户管理 API 允许您暂停 企业上的用户。 它只适用于经过身份验证的站点管理员。普通用户尝试访问它时会收到 403
响应。
get /admin/keys
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
per_page |
integer | query | Results per page (max 100) |
page |
integer | query | Page number of the results to fetch. |
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/keys
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/keys')
Default response
Status: 200 OK
[
{
"key_id": "012345678912345678",
"key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234",
"user_id": 232,
"repository_id": null
},
{
"key_id": "012345678912345678",
"key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234",
"user_id": null,
"repository_id": 2333,
"id": "2",
"url": "https://api.github.com/repos/octocat/Hello-World/keys/2"
}
]
delete /admin/keys/{key_ids}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
key_ids |
string | path |
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/keys/KEY_IDS
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/keys/{key_ids}', {
key_ids: 'key_ids'
})
Default Response
Status: 204 No Content
List personal access tokens
Lists personal access tokens for all users, including admin users.
get /admin/tokens
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
per_page |
integer | query | Results per page (max 100) |
page |
integer | query | Page number of the results to fetch. |
代码示例
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/tokens
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/tokens')
Default response
Status: 200 OK
[
{
"id": 1,
"url": "https://api.github.com/authorizations/1",
"scopes": [
"public_repo"
],
"token": "",
"token_last_eight": "12345678",
"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2011-09-06T20:39:23Z",
"created_at": "2011-09-06T17:26:27Z",
"fingerprint": "jklmnop12345678"
}
]
Delete a personal access token
Deletes a personal access token. Returns a 403 - Forbidden
status when a personal access token is in use. For example, if you access this endpoint with the same personal access token that you are trying to delete, you will receive this error.
delete /admin/tokens/{token_id}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
token_id |
integer | path |
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/tokens/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/tokens/{token_id}', {
token_id: 42
})
Default Response
Status: 204 No Content
Delete a user
Deleting a user will delete all their repositories, gists, applications, and personal settings. Suspending a user is often a better option.
You can delete any user account except your own.
delete /admin/users/{username}
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
username |
string | path |
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/users/USERNAME
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/users/{username}', {
username: 'username'
})
Default Response
Status: 204 No Content
post /admin/users/{username}/authorizations
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
username |
string | path | |
scopes |
array of strings | body |
A list of scopes. |
代码示例
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/users/USERNAME/authorizations \
-d '{"scopes":["scopes"]}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/users/{username}/authorizations', {
username: 'username',
scopes: [
'scopes'
]
})
Default response
Status: 201 Created
{
"id": 1,
"url": "https://api.github.com/authorizations/1",
"scopes": [
"public_repo"
],
"token": "abcdefgh12345678",
"token_last_eight": "12345678",
"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2011-09-06T20:39:23Z",
"created_at": "2011-09-06T17:26:27Z",
"fingerprint": ""
}
delete /admin/users/{username}/authorizations
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
username |
string | path |
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/admin/users/USERNAME/authorizations
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/users/{username}/authorizations', {
username: 'username'
})
Default Response
Status: 204 No Content
Suspend a user
If your GitHub instance uses LDAP Sync with Active Directory LDAP servers, Active Directory LDAP-authenticated users cannot be suspended through this API. If you attempt to suspend an Active Directory LDAP-authenticated user through this API, it will return a 403
response.
You can suspend any user account except your own.
Note that, if you choose not to pass any parameters, you'll need to set Content-Length
to zero when calling out to this endpoint. For more information, see "HTTP verbs."
put /users/{username}/suspended
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
username |
string | path | |
reason |
string | body |
The reason the user is being suspended. This message will be logged in the audit log. If you don't provide a |
代码示例
Shell
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/suspended \
-d '{"reason":"reason"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /users/{username}/suspended', {
username: 'username',
reason: 'reason'
})
Default Response
Status: 204 No Content
Unsuspend a user
If your GitHub instance uses LDAP Sync with Active Directory LDAP servers, this API is disabled and will return a 403
response. Active Directory LDAP-authenticated users cannot be unsuspended using the API.
delete /users/{username}/suspended
参数
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to |
username |
string | path | |
reason |
string | body |
The reason the user is being unsuspended. This message will be logged in the audit log. If you don't provide a |
代码示例
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/USERNAME/suspended \
-d '{"reason":"reason"}'
JavaScript (@octokit/core.js)
await octokit.request('DELETE /users/{username}/suspended', {
username: 'username',
reason: 'reason'
})
Default Response
Status: 204 No Content