GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Go to GitLab Docs homepage
  • What's new?
  • Get free trial
  • Use GitLab
  • GitLab Duo
  • GitLab Orbit
  • Extend
  • Install
  • Administer
  • Subscribe
  • Contribute
  • Solutions
  • Getting started
  • Tutorials

This view

  • Original page
  • New address

GeezerVison is showing docs.gitlab.com — Organizations API | GitLab Docs

 / 

Organizations API

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed
  • Status: Experiment

Use this API to interact with GitLab organizations. For more information, see organization.

Create an organization

  • Introduced in GitLab 17.5 with a flag named allow_organization_creation. Disabled by default. This feature is an experiment.
  • Changed in GitLab 18.4. Feature flag allow_organization_creation consolidated and renamed to organization_switching.
  • Feature flag changed to org_stage_experimental in GitLab 19.4. Disabled by default. Feature flag organization_switching removed.

The availability of this feature is controlled by a feature flag. For more information, see the history.

Creates an organization.

This endpoint is an experiment and might be changed or removed without notice.

POST /organizations

Parameters:

AttributeTypeRequiredDescription
namestringyesThe name of the organization
pathstringyesThe path of the organization
descriptionstringnoThe description of the organization
avatarfilenoThe avatar image for the organization

Example request:

shell
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --form "name=New Organization" \
  --form "path=new-org" \
  --form "description=A new organization" \
  --form "avatar=@/path/to/avatar.png" \
  --url "https://gitlab.example.com/api/v4/organizations"

Example response:

json
{
  "id": 42,
  "uuid": "0192f8c2-1a2b-7cde-89ab-0123456789ab",
  "name": "New Organization",
  "path": "new-org",
  "description": "A new organization",
  "created_at": "2024-09-18T02:35:15.371Z",
  "updated_at": "2024-09-18T02:35:15.371Z",
  "web_url": "https://gitlab.example.com/o/new-org/-/overview",
  "avatar_url": "https://gitlab.example.com/uploads/-/system/organizations/organization_detail/avatar/42/avatar.png"
}

Restore an organization

  • Introduced as an experiment in GitLab 19.6.

Restores a soft-deleted organization.

Prerequisites:

  • You must be an administrator.
POST /organizations/:id/restore

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesThe ID of the organization.

If successful, returns 201 Created and the following response attributes:

AttributeTypeDescription
avatar_urlstringURL of the organization avatar.
created_atdatetimeTimestamp when the organization was created.
descriptionstringDescription of the organization.
idintegerID of the organization.
namestringName of the organization.
pathstringPath of the organization.
updated_atdatetimeTimestamp when the organization was last updated.
uuidstringUUID of the organization.
visibilitystringVisibility level of the organization.
web_urlstringURL of the organization.

If the organization is not soft-deleted, returns 400 Bad Request.

Example request:

shell
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/organizations/42/restore"

Example response:

json
{
  "id": 42,
  "uuid": "0192f8c2-1a2b-7cde-89ab-0123456789ab",
  "name": "New Organization",
  "path": "new-org",
  "description": "A new organization",
  "visibility": "private",
  "created_at": "2024-09-18T02:35:15.371Z",
  "updated_at": "2024-09-20T10:12:45.118Z",
  "web_url": "https://gitlab.example.com/o/new-org/-/overview",
  "avatar_url": null
}

Transfer users to an organization

  • Introduced in GitLab 19.6.

Transfers ownership of users to an organization, including their personal namespaces and projects. This is a change of ownership, not organization membership. The transfer runs in the background.

Prerequisites:

  • You must be an administrator.
  • All users must belong to the same organization.
  • No user can be an internal user, such as the ghost user or a bot like support_bot or admin_bot. Service accounts and project access token bots can be transferred.
POST /organizations/:id/transfer_users

Parameters:

AttributeTypeRequiredDescription
idintegeryesThe ID of the organization to transfer the users to.
user_idsarray of integersyesThe IDs of the users to transfer. Maximum 50.

If successful, returns 202 Accepted and the IDs of the users being transferred.

Example request:

shell
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "user_ids[]=5" \
  --data "user_ids[]=6" \
  --url "https://gitlab.example.com/api/v4/organizations/42/transfer_users"

Example response:

json
{
  "organization_id": 42,
  "user_ids": [5, 6]
}

List organization users

  • Introduced as an experiment in GitLab 19.6.
  • In GitLab 19.7, the id response attribute was renamed to user_id, and the order_by value id was renamed to user_id.

Lists the users of an organization.

Prerequisites:

  • Instance or organization administrator access.
GET /organizations/:id/users

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesThe ID of the organization.
cursorstringNoCursor for the next page of results.
order_bystringNoField to sort by. Only user_id is supported. Default is user_id.
per_pageintegerNoNumber of items per page, from 1 to 100. Default is 20.
sortstringNoSort order, either asc or desc. Default is asc.

This endpoint supports only keyset pagination. Keyset pagination is used by default, and the page parameter is not supported.

If successful, returns 200 OK and the following response attributes:

AttributeTypeDescription
access_levelstringAccess level of the user in the organization, either default or owner. Users with the owner access level are organization administrators.
botbooleanIf true, the user is a bot.
user_idintegerID of the user.
usernamestringUsername of the user.

Example request:

shell
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/organizations/42/users"

Example response:

json
[
  {
    "user_id": 1001,
    "username": "jsmith",
    "bot": false,
    "access_level": "default"
  }
]

Add a user to an organization

  • Introduced as an experiment in GitLab 19.6.
  • In GitLab 19.7, the id response attribute was renamed to user_id, and the user_id request attribute was added.

Adds a user to an organization.

Prerequisites:

  • Instance or organization administrator access.
POST /organizations/:id/users

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesThe ID of the organization.
access_levelstringNoThe access level of the user, either default or owner. Users with the owner access level are organization administrators. Default is default.
user_idintegerConditionalThe ID of the user to add. Required if username is not provided. Cannot be used with username.
usernamestringConditionalThe username of the user to add. Required if user_id is not provided. Cannot be used with user_id.

If successful, returns 201 Created and the attributes listed in List organization users.

If the user does not exist or is already a member, returns 400 Bad Request. To change the access level of an existing member, use Update an organization user.

Example request:

shell
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "user_id=1001" \
  --data "access_level=owner" \
  --url "https://gitlab.example.com/api/v4/organizations/42/users"

Example response:

json
{
  "user_id": 1001,
  "username": "jsmith",
  "bot": false,
  "access_level": "owner"
}

Retrieve an organization user

  • Introduced as an experiment in GitLab 19.7.

Retrieves a user of an organization.

Prerequisites:

  • Instance or organization administrator access.
GET /organizations/:id/users/:user_id

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesThe ID of the organization.
user_idinteger or stringYesThe ID or username of the user.

If successful, returns 200 OK and the attributes listed in List organization users.

Returns 404 Not Found if the user does not exist or is not a member of the organization.

Example request:

shell
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/organizations/42/users/1001"

Example response:

json
{
  "user_id": 1001,
  "username": "jsmith",
  "bot": false,
  "access_level": "default"
}

Update an organization user

  • Introduced as an experiment in GitLab 19.6.
  • In GitLab 19.7, the id response attribute was renamed to user_id, and the user_id path attribute was changed to also accept a username.

Changes the access level of a user in an organization. For example, you can make a member an organization administrator.

Prerequisites:

  • Instance or organization administrator access.
PUT /organizations/:id/users/:user_id

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesThe ID of the organization.
user_idinteger or stringYesThe ID or username of the user.
access_levelstringYesThe access level of the user, either default or owner. Users with the owner access level are organization administrators.

If successful, returns 200 OK and the attributes listed in List organization users.

Returns 400 Bad Request if the change would leave the organization without an active organization administrator.

Returns 404 Not Found if the user does not exist or is not a member of the organization.

Example request:

shell
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "access_level=owner" \
  --url "https://gitlab.example.com/api/v4/organizations/42/users/1001"

Example response:

json
{
  "user_id": 1001,
  "username": "jsmith",
  "bot": false,
  "access_level": "owner"
}

Remove a user from an organization

  • Introduced as an experiment in GitLab 19.6.
  • In GitLab 19.7, the user_id path attribute was changed to also accept a username.

Removes a user from an organization. Removal from an organization also removes the user as a member from any groups or projects managed by the organization.

Prerequisites:

  • Instance or organization administrator access, unless you are removing yourself.
DELETE /organizations/:id/users/:user_id

Supported attributes:

AttributeTypeRequiredDescription
idintegerYesThe ID of the organization.
user_idinteger or stringYesThe ID or username of the user.

If successful, returns 204 No Content.

Returns 400 Bad Request if:

  • The user is the last active organization administrator.
  • The organization is the user’s home organization, which is the organization that the user belongs to by default.
  • The user would no longer belong to any organization.

Returns 403 Forbidden if you do not have permission to remove the user.

Example request:

shell
curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/organizations/42/users/5"
Was this page helpful?
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.