GET /api/users
List all users

GET /api/auth_source_ldaps/:auth_source_ldap_id/users
List all users for LDAP authentication source

GET /api/auth_source_externals/:auth_source_external_id/users
List all users for external authentication source

GET /api/usergroups/:usergroup_id/users
List all users for user group

GET /api/roles/:role_id/users
List all users for role

GET /api/locations/:location_id/users
List all users for location

GET /api/organizations/:organization_id/users
List all users for organization

Examples

GET /api/locations/255093256/organizations/missing/users
404
{
  "message": "Organization with id missing not found"
}

Params

Param name Description
auth_source_ldap_id
optional

ID of LDAP authentication source

Validations:

  • String

usergroup_id
optional

ID of user group

Validations:

  • String

role_id
optional

ID of role

Validations:

  • String

location_id
optional

Scope by locations

Validations:

  • Integer

organization_id
optional

Scope by organizations

Validations:

  • Integer

search
optional

filter results

Validations:

  • String

order
optional

Sort and order by a searchable field, e.g. '<field> DESC'

Validations:

  • String

page
optional

Page number, starting at 1

Validations:

  • Must be a number.

per_page
optional

Number of results per page to return, 'all' to return all results

Validations:

  • Must match regular expression /\A([1-9]\d*|all)\Z$/.

Search fields

Field name Type Possible values
admin true, false
auth_source string
auth_source_type string
description text
disabled true, false
firstname string
id integer
last_login_on datetime
lastname string
location string
location_id integer
login string
mail string
organization string
organization_id integer
role string
role_id integer
usergroup string

GET /api/users/:id
Show a user

Examples

GET /api/users/980190962
200
{
  "firstname": "One",
  "lastname": "User",
  "mail": "userone@someware.com",
  "mail_enabled": false,
  "admin": false,
  "auth_source_id": 980190962,
  "disabled": false,
  "auth_source_name": "ldap-server",
  "timezone": null,
  "locale": null,
  "last_login_on": "2009-10-12 21:50:04 UTC",
  "created_at": "2024-02-22 16:16:06 UTC",
  "updated_at": "2024-02-22 16:16:06 UTC",
  "id": 980190962,
  "login": "one",
  "description": null,
  "ssh_keys": [],
  "default_location": null,
  "locations": [
    {
      "id": 255093256,
      "name": "Location 1",
      "title": "Location 1",
      "description": null
    }
  ],
  "default_organization": null,
  "organizations": [
    {
      "id": 447626438,
      "name": "Organization 1",
      "title": "Organization 1",
      "description": null
    }
  ],
  "effective_admin": false,
  "cached_usergroups": [],
  "auth_source_ldap": {
    "id": 980190962,
    "type": "AuthSourceLdap",
    "name": "ldap-server"
  },
  "mail_notifications": [],
  "roles": [
    {
      "name": "Viewer",
      "id": 5,
      "description": null,
      "origin": "foreman"
    }
  ],
  "usergroups": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Integer

id
required

Validations:

  • String


GET /api/current_user
Show the currently logged-in user

Examples

GET /api/current_user
401
{
  "error": {
    "message": "Unable to authenticate user "
  }
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Integer


POST /api/users
Create a user

Adds role 'Default role' to the user by default

Examples

POST /api/users
{
  "user": {
    "login": "foo",
    "auth_source_id": 200482051,
    "password": "123456",
    "firstname": "sDXDYAhGVMqeQHUxPvnDJJJgajsIDTflDFXFBFiQfFtjLhWnREs"
  }
}
422
{
  "error": {
    "id": null,
    "errors": {
      "firstname": [
        "is too long (maximum is 50 characters)"
      ]
    },
    "full_messages": [
      "First name is too long (maximum is 50 characters)"
    ]
  }
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Integer

user
required

Validations:

  • Hash

user[login]
required

Validations:

  • String

user[firstname]
optional , nil allowed

Validations:

  • String

user[lastname]
optional , nil allowed

Validations:

  • String

user[mail]
required

Validations:

  • String

user[description]
optional , nil allowed

Validations:

  • String

user[disabled]
optional , nil allowed

Validations:

  • Must be one of: true, false, 1, 0.

user[admin]
optional , nil allowed

is an admin account

Validations:

  • Must be one of: true, false, 1, 0.

user[password]
optional , nil allowed

Required unless user is in an external authentication source

Validations:

  • String

user[default_location_id]
optional , nil allowed

Validations:

  • Integer

user[default_organization_id]
optional , nil allowed

Validations:

  • Integer

user[auth_source_id]
required

Validations:

  • Integer

user[timezone]
optional , nil allowed

User's timezone

Validations:

  • Must be one of: International Date Line West, American Samoa, Midway Island, Hawaii, Alaska, Pacific Time (US &amp; Canada), Tijuana, Arizona, Chihuahua, Mazatlan, Mountain Time (US &amp; Canada), Central America, Central Time (US &amp; Canada), Guadalajara, Mexico City, Monterrey, Saskatchewan, Bogota, Eastern Time (US &amp; Canada), Indiana (East), Lima, Quito, Atlantic Time (Canada), Caracas, Georgetown, La Paz, Puerto Rico, Santiago, Newfoundland, Brasilia, Buenos Aires, Greenland, Montevideo, Mid-Atlantic, Azores, Cape Verde Is., Casablanca, Dublin, Edinburgh, Lisbon, London, Monrovia, UTC, Amsterdam, Belgrade, Berlin, Bern, Bratislava, Brussels, Budapest, Copenhagen, Ljubljana, Madrid, Paris, Prague, Rome, Sarajevo, Skopje, Stockholm, Vienna, Warsaw, West Central Africa, Zagreb, Zurich, Athens, Bucharest, Cairo, Harare, Helsinki, Jerusalem, Kaliningrad, Kyiv, Pretoria, Riga, Sofia, Tallinn, Vilnius, Baghdad, Istanbul, Kuwait, Minsk, Moscow, Nairobi, Riyadh, St. Petersburg, Volgograd, Tehran, Abu Dhabi, Baku, Muscat, Samara, Tbilisi, Yerevan, Kabul, Ekaterinburg, Islamabad, Karachi, Tashkent, Chennai, Kolkata, Mumbai, New Delhi, Sri Jayawardenepura, Kathmandu, Almaty, Astana, Dhaka, Urumqi, Rangoon, Bangkok, Hanoi, Jakarta, Krasnoyarsk, Novosibirsk, Beijing, Chongqing, Hong Kong, Irkutsk, Kuala Lumpur, Perth, Singapore, Taipei, Ulaanbaatar, Osaka, Sapporo, Seoul, Tokyo, Yakutsk, Adelaide, Darwin, Brisbane, Canberra, Guam, Hobart, Melbourne, Port Moresby, Sydney, Vladivostok, Magadan, New Caledonia, Solomon Is., Srednekolymsk, Auckland, Fiji, Kamchatka, Marshall Is., Wellington, Chatham Is., Nuku&#39;alofa, Samoa, Tokelau Is..

user[locale]
optional , nil allowed

User's preferred locale

Validations:

  • Must be one of: ca, cs_CZ, de, en, en_GB, es, fr, it, ja, ka, ko, pl, pt_BR, ru, zh_CN, zh_TW.

user[role_ids]
optional , nil allowed

Validations:

  • Must be an array of any type

user[mail_enabled]
optional , nil allowed

Enable user's email

Validations:

  • Must be one of: true, false, 1, 0.

user[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

user[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


PUT /api/users/:id
Update a user

Adds role 'Default role' to the user if it is not already present. Only another admin can change the admin account attribute.

Examples

PUT /api/users/980190962
{
  "user": {
    "mail": "jxIUIyrFCI@example.com"
  }
}
200
{
  "firstname": "One",
  "lastname": "User",
  "mail": "jxIUIyrFCI@example.com",
  "mail_enabled": false,
  "admin": false,
  "auth_source_id": 980190962,
  "disabled": false,
  "auth_source_name": "ldap-server",
  "timezone": null,
  "locale": null,
  "last_login_on": "2009-10-12 21:50:04 UTC",
  "created_at": "2024-02-22 16:16:06 UTC",
  "updated_at": "2024-02-22 16:16:18 UTC",
  "id": 980190962,
  "login": "one",
  "description": null,
  "ssh_keys": [],
  "default_location": null,
  "locations": [
    {
      "id": 255093256,
      "name": "Location 1",
      "title": "Location 1",
      "description": null
    }
  ],
  "default_organization": null,
  "organizations": [
    {
      "id": 447626438,
      "name": "Organization 1",
      "title": "Organization 1",
      "description": null
    }
  ],
  "effective_admin": false,
  "cached_usergroups": [],
  "auth_source_ldap": {
    "id": 980190962,
    "type": "AuthSourceLdap",
    "name": "ldap-server"
  },
  "mail_notifications": [],
  "roles": [
    {
      "name": "Viewer",
      "id": 5,
      "description": null,
      "origin": "foreman"
    }
  ],
  "usergroups": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Integer

id
required

Validations:

  • String

user
required

Validations:

  • Hash

user[login]
optional

Validations:

  • String

user[firstname]
optional , nil allowed

Validations:

  • String

user[lastname]
optional , nil allowed

Validations:

  • String

user[mail]
optional

Validations:

  • String

user[description]
optional , nil allowed

Validations:

  • String

user[disabled]
optional , nil allowed

Validations:

  • Must be one of: true, false, 1, 0.

user[admin]
optional , nil allowed

is an admin account

Validations:

  • Must be one of: true, false, 1, 0.

user[password]
optional , nil allowed

Required unless user is in an external authentication source

Validations:

  • String

user[default_location_id]
optional , nil allowed

Validations:

  • Integer

user[default_organization_id]
optional , nil allowed

Validations:

  • Integer

user[auth_source_id]
optional

Validations:

  • Integer

user[timezone]
optional , nil allowed

User's timezone

Validations:

  • Must be one of: International Date Line West, American Samoa, Midway Island, Hawaii, Alaska, Pacific Time (US &amp; Canada), Tijuana, Arizona, Chihuahua, Mazatlan, Mountain Time (US &amp; Canada), Central America, Central Time (US &amp; Canada), Guadalajara, Mexico City, Monterrey, Saskatchewan, Bogota, Eastern Time (US &amp; Canada), Indiana (East), Lima, Quito, Atlantic Time (Canada), Caracas, Georgetown, La Paz, Puerto Rico, Santiago, Newfoundland, Brasilia, Buenos Aires, Greenland, Montevideo, Mid-Atlantic, Azores, Cape Verde Is., Casablanca, Dublin, Edinburgh, Lisbon, London, Monrovia, UTC, Amsterdam, Belgrade, Berlin, Bern, Bratislava, Brussels, Budapest, Copenhagen, Ljubljana, Madrid, Paris, Prague, Rome, Sarajevo, Skopje, Stockholm, Vienna, Warsaw, West Central Africa, Zagreb, Zurich, Athens, Bucharest, Cairo, Harare, Helsinki, Jerusalem, Kaliningrad, Kyiv, Pretoria, Riga, Sofia, Tallinn, Vilnius, Baghdad, Istanbul, Kuwait, Minsk, Moscow, Nairobi, Riyadh, St. Petersburg, Volgograd, Tehran, Abu Dhabi, Baku, Muscat, Samara, Tbilisi, Yerevan, Kabul, Ekaterinburg, Islamabad, Karachi, Tashkent, Chennai, Kolkata, Mumbai, New Delhi, Sri Jayawardenepura, Kathmandu, Almaty, Astana, Dhaka, Urumqi, Rangoon, Bangkok, Hanoi, Jakarta, Krasnoyarsk, Novosibirsk, Beijing, Chongqing, Hong Kong, Irkutsk, Kuala Lumpur, Perth, Singapore, Taipei, Ulaanbaatar, Osaka, Sapporo, Seoul, Tokyo, Yakutsk, Adelaide, Darwin, Brisbane, Canberra, Guam, Hobart, Melbourne, Port Moresby, Sydney, Vladivostok, Magadan, New Caledonia, Solomon Is., Srednekolymsk, Auckland, Fiji, Kamchatka, Marshall Is., Wellington, Chatham Is., Nuku&#39;alofa, Samoa, Tokelau Is..

user[locale]
optional , nil allowed

User's preferred locale

Validations:

  • Must be one of: ca, cs_CZ, de, en, en_GB, es, fr, it, ja, ka, ko, pl, pt_BR, ru, zh_CN, zh_TW.

user[role_ids]
optional , nil allowed

Validations:

  • Must be an array of any type

user[mail_enabled]
optional , nil allowed

Enable user's email

Validations:

  • Must be one of: true, false, 1, 0.

user[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

user[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type

user[current_password]
optional , nil allowed

Required when user want to change own password

Validations:

  • String


DELETE /api/users/:id
Delete a user

Examples

DELETE /api/users/980190962
{
  "user": {}
}
200
{
  "id": 980190962,
  "login": "one",
  "firstname": "One",
  "lastname": "User",
  "mail": "userone@someware.com",
  "admin": false,
  "last_login_on": "2009-10-12T21:50:04.000Z",
  "auth_source_id": 980190962,
  "created_at": "2024-02-22T16:16:06.259Z",
  "updated_at": "2024-02-22T16:16:06.259Z",
  "password_hash": null,
  "password_salt": null,
  "locale": null,
  "avatar_hash": null,
  "default_organization_id": null,
  "default_location_id": null,
  "lower_login": "one",
  "mail_enabled": false,
  "timezone": null,
  "description": null,
  "disabled": false,
  "password": null,
  "name": "One User"
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Integer

id
required

Validations:

  • String


GET /api/users/extlogin
Use to authenticate against external authentication source

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Integer