Service account users API
- 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
- Tier: Premium, Ultimate
- Offering: GitLab Self-Managed, GitLab Dedicated
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
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_ . |
email | string | no | Email of the user account. If not set, generates a no-reply email address. |
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",
"email": "service_account_6018816a18e515214e0c34c2b33523fc@noreply.gitlab.example.com"
}
Specify a custom email address
You can specify a custom email address at service account creation to receive notifications on this service account’s actions.
Example request:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --data "email=custom_email@gitlab.example.com" "https://gitlab.example.com/api/v4/service_accounts"
Example response:
{
"id": 57,
"username": "service_account_6018816a18e515214e0c34c2b33523fc",
"name": "Service account user",
"email": "custom_email@gitlab.example.com"
}
This fails if the email address has already been taken by another user:
{
"message": "400 Bad request - Email has already been taken"
}
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support