User Administration

August 21, 2019 ยท View on GitHub

Create a new user

POST /admin/users

Parameters

NameTypeDescription
source_idintAuthentication source ID. Remain default means a local user
login_namestringAuthentication source login name, required for non-local user
usernamestringRequired Unique user name
emailstringRequired Unique email address of user
passwordstringDefault password for user, required for local user
send_notifyboolSend a notification email for this creation, require mailer service enabled

Example

{
    "source_id": 1,
    "login_name": "apiuser",
    "username": "apiuser",
    "email": "apiuser@user.com"
}

Response

Status: 201 Created
{
  "id": 9,
  "username": "apiuser",
  "full_name": "",
  "email": "apiuser@user.com",
  "avatar_url": "//1.gravatar.com/avatar/0550f43afcac6f78c3af2dd3a6f1c176"
}

Edit an existing user

PATCH /admin/users/:username

Parameters

NameTypeDescription
source_idintAuthentication source ID. Remain default means a local user
login_namestringAuthentication source login name, required for non-local user
full_namestringFull name of user
emailstringRequired Unique email address of user
passwordstringNew password for user. Ignore this field to leave it unchanged
websitestringPersonal website of user
locationstringLocation of user
activeboolActive or deactive the user. Ignore this field to leave it unchanged
adminboolPromote or depromote the user to be site admin. Ignore this field to leave it unchanged
allow_git_hookboolAllow or disallow the user for using Git hooks. Ignore this field to leave it unchanged
allow_import_localboolAllow or disallow the user for importing local repositories. Ignore this field to leave it unchanged

Example

{
    "source_id":1,
    "login_name":"apiuser",
    "full_name": "API User",
    "email":"apiuser@user.com"
}

Response

Status: 200 OK
{
  "id": 9,
  "username": "apiuser",
  "full_name": "API User",
  "email": "apiuser@user.com",
  "avatar_url": "//1.gravatar.com/avatar/b7193b9f212a6fe7a20db58d556fcc41"
}

Delete a user

DELETE /admin/users/:username

Response

Status: 204 No Content

Create a public key for user

POST /admin/users/:username/keys

Parameters

NameTypeDescription
titlestringRequired The name of the key
keystringRequired The content of the key