カスタム属性API

カスタム属性への API 呼び出しはすべて、管理者として認証される必要があります。

カスタム属性は現在、ユーザー、グループ、プロジェクトで利用可能で、このドキュメントでは「リソース」と呼ばれます。

カスタム属性のリスト

リソースのすべてのカスタム属性を取得します。

GET /users/:id/custom_attributes
GET /groups/:id/custom_attributes
GET /projects/:id/custom_attributes
属性 タイプ 必須 説明
id 整数 はい リソースのID
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/42/custom_attributes"

回答例

[
   {
      "key": "location",
      "value": "Antarctica"
   },
   {
      "key": "role",
      "value": "Developer"
   }
]

単一のカスタム属性

リソースのカスタム属性を取得します。

GET /users/:id/custom_attributes/:key
GET /groups/:id/custom_attributes/:key
GET /projects/:id/custom_attributes/:key
属性 タイプ 必須 説明
id 整数 はい リソースのID
key はい カスタム属性のキー
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"

回答例

{
   "key": "location",
   "value": "Antarctica"
}

カスタム属性の設定

リソースにカスタム属性を設定します。 属性が既に存在する場合は更新され、そうでない場合は新しく作成されます。

PUT /users/:id/custom_attributes/:key
PUT /groups/:id/custom_attributes/:key
PUT /projects/:id/custom_attributes/:key
属性 タイプ 必須 説明
id 整数 はい リソースのID
key はい カスタム属性のキー
value はい カスタム属性の値
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --data "value=Greenland" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"

回答例

{
   "key": "location",
   "value": "Greenland"
}

カスタム属性の削除

リソースのカスタム属性を削除します。

DELETE /users/:id/custom_attributes/:key
DELETE /groups/:id/custom_attributes/:key
DELETE /projects/:id/custom_attributes/:key
属性 タイプ 必須 説明
id 整数 はい リソースのID
key はい カスタム属性のキー
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"