Service account users API
DETAILS: Tier: Premium, Ultimate Offering: GitLab Self-Managed, GitLab Dedicated
Use this API to interact with service accounts. For more information, see Service accounts.
List all service account users
DETAILS: Tier: Premium, Ultimate Offering: GitLab Self-Managed, GitLab Dedicated
- List all service account users introduced in GitLab 17.1.
Lists all service account users.
Use the page
and per_page
pagination parameters to filter the results.
Prerequisites:
- You must have administrator access to the instance.
GET /service_accounts
Supported attributes:
Attribute | Type | Required | Description |
---|---|---|---|
order_by |
string | no | Attribute to order results by. Possible values: id or username . Default value: id . |
sort |
string | no | Direction to sort results by. Possible values: desc or asc . Default value: desc . |
Example request:
curl --request GET --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/service_accounts"
Example response:
[
{
"id": 114,
"username": "service_account_33",
"name": "Service account user"
},
{
"id": 137,
"username": "service_account_34",
"name": "john doe"
}
]
Create a service account user
- Create a service account user was introduced in GitLab 16.1
- Username and name attributes introduced in GitLab 16.10.
Creates a service account user.
Prerequisites:
- You must have administrator access to the instance.
POST /service_accounts
Supported attributes:
Attribute | Type | Required | Description |
---|---|---|---|
name |
string | no | Name of the user. If not set, uses Service account user . |
username |
string | no | Username of the user account. If not set, generates a name prepended with service_account_ . |
Example request:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/service_accounts"
Example response:
{
"id": 57,
"username": "service_account_6018816a18e515214e0c34c2b33523fc",
"name": "Service account user"
}