---
title: "Add a repository collaborator"
method: PUT
path: "/repos/{owner}/{repo}/collaborators/{username}"
tags: ["repos"]
---

# Add a repository collaborator

`PUT /repos/{owner}/{repo}/collaborators/{username}`

This endpoint triggers [notifications](https://docs.github.com/enterprise-server@3.5/github/managing-subscriptions-and-notifications-on-github/about-notifications). Creating content too quickly using this endpoint may result in secondary rate limiting. See "[Secondary rate limits](https://docs.github.com/enterprise-server@3.5/rest/overview/resources-in-the-rest-api#secondary-rate-limits)" and "[Dealing with secondary rate limits](https://docs.github.com/enterprise-server@3.5/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details.

For more information on permission levels, see "[Repository permission levels for an organization](https://docs.github.com/enterprise-server@3.5/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#permission-levels-for-repositories-owned-by-an-organization)". There are restrictions on which permissions can be granted to organization members when an organization base role is in place. In this case, the permission being given must be equal to or higher than the org base permission. Otherwise, the request will fail with:

```
Cannot assign {member} permission of {role name}
```

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](https://docs.github.com/enterprise-server@3.5/rest/overview/resources-in-the-rest-api#http-verbs)."

The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the [repository invitations API endpoints](https://docs.github.com/enterprise-server@3.5/rest/reference/repos#invitations).

**Updating an existing collaborator's permission level**

The endpoint can also be used to change the permissions of an existing collaborator without first removing and re-adding the collaborator. To change the permissions, use the same endpoint and pass a different `permission` parameter. The response will be a `204`, with no other indication that the permission level changed.

**Rate limits**

You are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository.

## Path parameters

- `owner` string, required
- `repo` string, required
- `username` string, required

## Request body

- object
  - `permission` string — The permission to grant the collaborator. **Only valid on organization-owned repositories.**

## Response `201`

Response when a new invitation is created

- RepositoryInvitation — Repository invitations let you manage who you collaborate with.
  - `id` integer, required — Unique identifier of the repository invitation.
  - `repository` MinimalRepository, required — Minimal Repository
    - `id` integer, required
    - `node_id` string, required
    - `name` string, required
    - `full_name` string, required
    - `owner` SimpleUser, required — A GitHub user.
      - `name` string, nullable
      - `email` string, nullable
      - `login` string, required
      - `id` integer, required
      - `node_id` string, required
      - `avatar_url` string, uri, required
      - `gravatar_id` string, nullable, required
      - `url` string, uri, required
      - `html_url` string, uri, required
      - `followers_url` string, uri, required
      - `following_url` string, required
      - `gists_url` string, required
      - `starred_url` string, required
      - `subscriptions_url` string, uri, required
      - `organizations_url` string, uri, required
      - `repos_url` string, uri, required
      - `events_url` string, required
      - `received_events_url` string, uri, required
      - `type` string, required
      - `site_admin` boolean, required
      - `starred_at` string
    - `private` boolean, required
    - `html_url` string, uri, required
    - `description` string, nullable, required
    - `fork` boolean, required
    - `url` string, uri, required
    - `archive_url` string, required
    - `assignees_url` string, required
    - `blobs_url` string, required
    - `branches_url` string, required
    - `collaborators_url` string, required
    - `comments_url` string, required
    - `commits_url` string, required
    - `compare_url` string, required
    - `contents_url` string, required
    - `contributors_url` string, uri, required
    - `deployments_url` string, uri, required
    - `downloads_url` string, uri, required
    - `events_url` string, uri, required
    - `forks_url` string, uri, required
    - `git_commits_url` string, required
    - `git_refs_url` string, required
    - `git_tags_url` string, required
    - `git_url` string
    - `issue_comment_url` string, required
    - `issue_events_url` string, required
    - `issues_url` string, required
    - `keys_url` string, required
    - `labels_url` string, required
    - `languages_url` string, uri, required
    - `merges_url` string, uri, required
    - `milestones_url` string, required
    - `notifications_url` string, required
    - `pulls_url` string, required
    - `releases_url` string, required
    - `ssh_url` string
    - `stargazers_url` string, uri, required
    - `statuses_url` string, required
    - `subscribers_url` string, uri, required
    - `subscription_url` string, uri, required
    - `tags_url` string, uri, required
    - `teams_url` string, uri, required
    - `trees_url` string, required
    - `clone_url` string
    - `mirror_url` string, nullable
    - `hooks_url` string, uri, required
    - `svn_url` string
    - `homepage` string, nullable
    - `language` string, nullable
    - `forks_count` integer
    - `stargazers_count` integer
    - `watchers_count` integer
    - `size` integer — The size of the repository. Size is calculated hourly. When a repository is initially created, the size is 0.
    - `default_branch` string
    - `open_issues_count` integer
    - `is_template` boolean
    - `topics` string[]
    - `has_issues` boolean
    - `has_projects` boolean
    - `has_wiki` boolean
    - `has_pages` boolean
    - `has_downloads` boolean
    - `archived` boolean
    - `disabled` boolean
    - `visibility` string
    - `pushed_at` string, date-time, nullable
    - `created_at` string, date-time, nullable
    - `updated_at` string, date-time, nullable
    - `permissions` object
      - `admin` boolean
      - `maintain` boolean
      - `push` boolean
      - `triage` boolean
      - `pull` boolean
    - `role_name` string
    - `temp_clone_token` string
    - `delete_branch_on_merge` boolean
    - `subscribers_count` integer
    - `network_count` integer
    - `code_of_conduct` CodeOfConduct — Code Of Conduct
      - `key` string, required
      - `name` string, required
      - `url` string, uri, required
      - `body` string
      - `html_url` string, uri, nullable, required
    - `license` object, nullable
      - `key` string
      - `name` string
      - `spdx_id` string
      - `url` string
      - `node_id` string
    - `forks` integer
    - `open_issues` integer
    - `watchers` integer
    - `allow_forking` boolean
  - `invitee` NullableSimpleUser, nullable, required — A GitHub user.
    - `name` string, nullable
    - `email` string, nullable
    - `login` string, required
    - `id` integer, required
    - `node_id` string, required
    - `avatar_url` string, uri, required
    - `gravatar_id` string, nullable, required
    - `url` string, uri, required
    - `html_url` string, uri, required
    - `followers_url` string, uri, required
    - `following_url` string, required
    - `gists_url` string, required
    - `starred_url` string, required
    - `subscriptions_url` string, uri, required
    - `organizations_url` string, uri, required
    - `repos_url` string, uri, required
    - `events_url` string, required
    - `received_events_url` string, uri, required
    - `type` string, required
    - `site_admin` boolean, required
    - `starred_at` string
  - `inviter` NullableSimpleUser, nullable, required — A GitHub user.
    - `name` string, nullable
    - `email` string, nullable
    - `login` string, required
    - `id` integer, required
    - `node_id` string, required
    - `avatar_url` string, uri, required
    - `gravatar_id` string, nullable, required
    - `url` string, uri, required
    - `html_url` string, uri, required
    - `followers_url` string, uri, required
    - `following_url` string, required
    - `gists_url` string, required
    - `starred_url` string, required
    - `subscriptions_url` string, uri, required
    - `organizations_url` string, uri, required
    - `repos_url` string, uri, required
    - `events_url` string, required
    - `received_events_url` string, uri, required
    - `type` string, required
    - `site_admin` boolean, required
    - `starred_at` string
  - `permissions` 'read' | 'write' | 'admin' | 'triage' | 'maintain', required — The permission associated with the invitation.
  - `created_at` string, date-time, required
  - `expired` boolean — Whether or not the invitation has expired
  - `url` string, required — URL for the repository invitation
  - `html_url` string, required
  - `node_id` string, required

## Other responses

- `204` — Response when: - an existing collaborator is added as a collaborator - an organization member is added as an individual collaborator - an existing team member (whose team is also a repository collaborator) is added as an individual collaborator
- `403` — Forbidden
- `422` — Validation failed, or the endpoint has been spammed.

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-4.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-4/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-4/versions/ee6c7a46328e/schema)
