Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais recentes, acesse a documentação em inglês. Se houver problemas com a tradução desta página, entre em contato conosco.
O GitHub AE está atualmente sob versão limitada. Entre em contato com nossa Equipe de Vendas para saber mais.

Administração do GitHub Enterprise

Neste artigo

You can use these GitHub Enterprise Cloud endpoints to administer your enterprise account.

URLs do ponto de extremidade

REST API endpoints are prefixed with the following URL:

http(s)://hostname/api/v3/

Autenticação

Os endpoints de API da sua instalação do GitHub AE aceitam os mesmos métodos de autenticação da API do GitHub.com. You can authenticate yourself with OAuth tokens or basic authentication.

Enterprise administration API endpoints are only accessible to authenticated GitHub AE site administrators.

Informações da versão

The current version of your enterprise is returned in the response header of every API: X-GitHub-Enterprise-Version: github-ae@latest.0 You can also read the current version by calling the meta endpoint.

Encryption at rest

You can use the encryption at rest API to manage the key that encrypts your data on GitHub AE. For more information, see "Configuring data encryption for your enterprise."

Estatísticas de admin

A API de Estatísticas Administrativas fornece uma variedade de métricas sobre sua instalação. Só está disponível para administradores do site autenticados. Usuários normais receberão uma mensagem 404 se tentarem acessá-la.

Get statistics

There are a variety of types to choose from:

TypeDescription
issuesThe number of open and closed issues.
hooksThe number of active and inactive hooks.
milestonesThe number of open and closed milestones.
orgsThe number of organizations, teams, team members, and disabled organizations.
commentsThe number of comments on issues, pull requests, commits, and gists.
pagesThe number of GitHub Pages sites.
usersThe number of suspended and admin users.
gistsThe number of private and public gists.
pullsThe number of merged, mergeable, and unmergeable pull requests.
reposThe number of organization-owned repositories, root repositories, forks, pushed commits, and wikis.
allAll of the statistics listed above.

These statistics are cached and will be updated approximately every 10 minutes.

get /enterprise/stats/{type}

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

type string path

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/enterprise/stats/TYPE
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/stats/{type}', {
  type: 'type'
})

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
  }
}

Announcements

The Announcements API allows you to manage the global announcement banner in your enterprise. For more information, see "Customizing user messages for your enterprise."

Get the global announcement banner

Gets the current message and expiration date of the global announcement banner in your enterprise.

get /enterprise/announcement

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/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

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

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 nullable body

The time at which the announcement expires. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. To set an announcement that never expires, omit this parameter, set it to null, or set it to an empty string.

Amostras de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/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

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/enterprise/announcement
JavaScript (@octokit/core.js)
await octokit.request('DELETE /enterprise/announcement')

Response

Status: 204 No Content

Webhooks globais

Global webhooks are installed on your enterprise. You can use global webhooks to automatically monitor, respond to, or enforce rules for users, organizations, teams, and repositories on your enterprise. Webhooks globais podem se inscrever para os tipos de eventos organização, usuário, repositório, equipe, integrante, filiação, bifurcaçãoe ping.

Esta API está disponível somente para administradores do site autenticados. Usuários normais receberão uma mensagem 404 se tentarem acessá-la. Para aprender como configurar webhooks globais, consulte Sobre webhooks globais.

get /admin/hooks

Parâmetros

Name Type In Description
accept string header

This API is under preview and subject to change. Ver aviso de pré-visualização

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.

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  http(s)://api.{hostname}/admin/hooks
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/hooks', {
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

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"
  }
]

Aviso de pré-visualização

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
☝️ Este cabeçalho é obrigatório.

post /admin/hooks

Parâmetros

Name Type In Description
accept string header

This API is under preview and subject to change. Ver aviso de pré-visualização

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.

Properties of the 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 json and form. The default is form.

secret (string)

If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.

insecure_ssl (string)

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

events array of strings body

The events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.

active boolean body

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

Default: true

Amostras de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  http(s)://api.{hostname}/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'
    ]
  }
})

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"
}

Aviso de pré-visualização

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
☝️ Este cabeçalho é obrigatório.

get /admin/hooks/{hook_id}

Parâmetros

Name Type In Description
accept string header

This API is under preview and subject to change. Ver aviso de pré-visualização

accept string header

This API is under preview and subject to change.

hook_id integer path

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  http(s)://api.{hostname}/admin/hooks/42
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/hooks/{hook_id}', {
  hook_id: 42,
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

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"
}

Aviso de pré-visualização

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
☝️ Este cabeçalho é obrigatório.

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}

Parâmetros

Name Type In Description
accept string header

This API is under preview and subject to change. Ver aviso de pré-visualização

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.

Properties of the 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 json and form. The default is form.

secret (string)

If provided, the secret will be used as the key to generate the HMAC hex digest value in the X-Hub-Signature header.

insecure_ssl (string)

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

events array of strings body

The events that trigger this webhook. A global webhook can be triggered by user and organization events. Default: user and organization.

active boolean body

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

Default: true

Amostras de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  http(s)://api.{hostname}/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'
    ]
  }
})

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"
}

Aviso de pré-visualização

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
☝️ Este cabeçalho é obrigatório.

delete /admin/hooks/{hook_id}

Parâmetros

Name Type In Description
accept string header

This API is under preview and subject to change. Ver aviso de pré-visualização

accept string header

This API is under preview and subject to change.

hook_id integer path

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  http(s)://api.{hostname}/admin/hooks/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/hooks/{hook_id}', {
  hook_id: 42,
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 204 No Content

Aviso de pré-visualização

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
☝️ Este cabeçalho é obrigatório.

Ping a global webhook

This will trigger a ping event to be sent to the webhook.

post /admin/hooks/{hook_id}/pings

Parâmetros

Name Type In Description
accept string header

This API is under preview and subject to change. Ver aviso de pré-visualização

accept string header

This API is under preview and subject to change.

hook_id integer path

Amostras de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.superpro-preview+json" \
  http(s)://api.{hostname}/admin/hooks/42/pings
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/hooks/{hook_id}/pings', {
  hook_id: 42,
  mediaType: {
    previews: [
      'superpro'
    ]
  }
})

Response

Status: 204 No Content

Aviso de pré-visualização

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
☝️ Este cabeçalho é obrigatório.

Licença

A API de Licença fornece informações sobre sua licença empresarial. Só está disponível para administradores do site autenticados. Usuários normais receberão uma mensagem 404 se tentarem acessá-la.

get /enterprise/settings/license

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/enterprise/settings/license
JavaScript (@octokit/core.js)
await octokit.request('GET /enterprise/settings/license')

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"
}

Organizações

The Organization Administration API allows you to create organizations on your enterprise. Só está disponível para administradores do site autenticados. Usuários normais receberão uma mensagem 404 se tentarem acessá-la.

post /admin/organizations

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

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.

Amostras de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/organizations \
  -d '{"login":"login","admin":"admin"}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/organizations', {
  login: 'login',
  admin: 'admin'
})

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}

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

org string path
login string body

Required. The organization's new name.

Amostras de código

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/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"
}

Usuários

The User Administration API allows you to suspend and unsuspend users on your enterprise. Só está disponível para administradores do site autenticados. Usuários normais receberão uma mensagem 403 se tentarem acessá-la.

get /admin/keys

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

direction string query

One of asc (ascending) or desc (descending).

sort string query
since string query

Only show public keys accessed after the given time.

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/keys
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/keys')

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}

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

key_ids string path

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/keys/KEY_IDS
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/keys/{key_ids}', {
  key_ids: 'key_ids'
})

Response

Status: 204 No Content

List personal access tokens

Lists personal access tokens for all users, including admin users.

get /admin/tokens

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

per_page integer query

Results per page (max 100)

page integer query

Page number of the results to fetch.

Amostras de código

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/tokens
JavaScript (@octokit/core.js)
await octokit.request('GET /admin/tokens')

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}

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

token_id integer path

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/tokens/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/tokens/{token_id}', {
  token_id: 42
})

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}

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

username string path

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/users/USERNAME
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/users/{username}', {
  username: 'username'
})

Response

Status: 204 No Content

post /admin/users/{username}/authorizations

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

username string path
scopes array of strings body

A list of scopes.

Amostras de código

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/users/USERNAME/authorizations \
  -d '{"scopes":["scopes"]}'
JavaScript (@octokit/core.js)
await octokit.request('POST /admin/users/{username}/authorizations', {
  username: 'username',
  scopes: [
    'scopes'
  ]
})

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

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

username string path

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/admin/users/USERNAME/authorizations
JavaScript (@octokit/core.js)
await octokit.request('DELETE /admin/users/{username}/authorizations', {
  username: 'username'
})

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

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

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 reason, it will default to "Suspended via API by SITE_ADMINISTRATOR", where SITE_ADMINISTRATOR is the person who performed the action.

Amostras de código

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/users/USERNAME/suspended \
  -d '{"reason":"reason"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /users/{username}/suspended', {
  username: 'username',
  reason: 'reason'
})

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

Parâmetros

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended.

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 reason, it will default to "Unsuspended via API by SITE_ADMINISTRATOR", where SITE_ADMINISTRATOR is the person who performed the action.

Amostras de código

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  http(s)://api.{hostname}/users/USERNAME/suspended \
  -d '{"reason":"reason"}'
JavaScript (@octokit/core.js)
await octokit.request('DELETE /users/{username}/suspended', {
  username: 'username',
  reason: 'reason'
})

Response

Status: 204 No Content

Esse documento ajudou você?

Privacy policy

Ajude-nos a tornar esses documentos ótimos!

Todos os documentos do GitHub são de código aberto. Você percebeu que algo que está errado ou não está claro? Envie um pull request.

Faça uma contribuição

Ou, aprenda como contribuir.