Collaborators
- List collaborators
- Check if a user is a collaborator
- Review a user's permission level
- Add user as a collaborator
- Remove user as a collaborator
List collaborators
Note: The Nested Teams API is currently available for developers to preview. See the blog post for full details. To access the API, you must provide a custom media type in the Accept header:
application/vnd.github.hellcat-preview+json
Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact your GitHub Enterprise site administrator.
For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.
If you pass the hellcat-preview media type, team members will include the members of child teams.
GET /repos/:owner/:repo/collaborators
Parameters
| Name | Type | Description |
|---|---|---|
affiliation |
string |
Filter collaborators returned by their affiliation. Can be one of: * outside: All outside collaborators of an organization-owned repository.* direct: All collaborators with permissions to an organization-owned repository, regardless of organization membership status.* all: All collaborators the authenticated user can see.Default: all |
Response
Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
[
{
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false,
"permissions": {
"pull": true,
"push": true,
"admin": false
}
}
]
Check if a user is a collaborator
Note: The Nested Teams API is currently available for developers to preview. See the blog post for full details. To access the API, you must provide a custom media type in the Accept header:
application/vnd.github.hellcat-preview+json
Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact your GitHub Enterprise site administrator.
For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.
If you pass the hellcat-preview media type, team members will include the members of child teams.
GET /repos/:owner/:repo/collaborators/:username
Response if user is a collaborator
Status: 204 No Content
Response if user is not a collaborator
Status: 404 Not Found
Review a user's permission level
Checks the repository permission of a collaborator. The possible repository permissions are admin, write, read, and none.
GET /repos/:owner/:repo/collaborators/:username/permission
Response if user has admin permissions
Status: 200 OK
{
"permission": "admin",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
}
Add user as a collaborator
This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" for details.
PUT /repos/:owner/:repo/collaborators/:username
Parameters
| Name | Type | Description |
|---|---|---|
permission |
string |
The permission to grant the collaborator. Only valid on organization-owned repositories. Can be one of: * pull - can pull, but not push to or administer this repository.* push - can pull and push, but not administer this repository.* admin - can pull, push and administer this repository.Default: push
|
For more information the permission levels, see "Repository permission levels for an organization" in the GitHub Help documentation.
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."
Response
Status: 204 No Content
Remove user as a collaborator
DELETE /repos/:owner/:repo/collaborators/:username
Response
Status: 204 No Content