Project Aliases API

  • Tier: Premium, Ultimate
  • Offering: GitLab Self-Managed, GitLab Dedicated

Add, change, or remove project aliases with this API. After you create an alias for a project, users can clone the repository with the alias, which can be helpful when migrating repositories.

All methods require administrator authorization.

List all project aliases

Get a list of all project aliases:

GET /project_aliases

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

AttributeTypeDescription
idintegerID of the project alias.
namestringName of the alias.
project_idintegerID of the associated project.

Example request:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/project_aliases"

Example response:

[
  {
    "id": 1,
    "project_id": 1,
    "name": "gitlab-foss"
  },
  {
    "id": 2,
    "project_id": 2,
    "name": "gitlab"
  }
]

Get project alias details

Get details of a project alias:

GET /project_aliases/:name

Supported attributes:

AttributeTypeRequiredDescription
namestringYesThe name of the alias.

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

AttributeTypeDescription
idintegerID of the project alias.
namestringName of the alias.
project_idintegerID of the associated project.

Example request:

curl --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/project_aliases/gitlab"

Example response:

{
  "id": 1,
  "project_id": 1,
  "name": "gitlab"
}

Create a project alias

Add a new alias for a project:

POST /project_aliases

Supported attributes:

AttributeTypeRequiredDescription
namestringYesName of the alias. Must be unique.
project_idinteger or stringYesID or path of the project.

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

AttributeTypeDescription
idintegerID of the project alias.
namestringName of the alias.
project_idintegerID of the associated project.

Example request:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/project_aliases" \
  --form "project_id=1" \
  --form "name=gitlab"

You can also use the project path:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/project_aliases" \
  --form "project_id=gitlab-org/gitlab" \
  --form "name=gitlab"

Example response:

{
  "id": 1,
  "project_id": 1,
  "name": "gitlab"
}

Delete a project alias

Remove a project alias:

DELETE /project_aliases/:name

Supported attributes:

AttributeTypeRequiredDescription
namestringYesName of the alias.

If successful, returns 204 No Content.

Example request:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/project_aliases/gitlab"