Update user

ENDPOINT /api/v0-user/id/[userid] (POST)

When generating URLs, [userid] is the id of a user SecurityPrincipal

The body of the request should be a JSON document containing only the fields that you wish to change for the user. The fields which can be updated by this API are:

  • nameFirst
  • nameLast
  • email
  • ref
  • localeId
  • directGroupMembership

Apart from directGroupMembership, all the fields correspond directly to the equivalent field on the SecurityPrincipal. directGroupMembership is the equivalent of directGroupIds, but returns an array of group API codes instead of group IDs.

Example request body

{
    "nameFirst":"First",
    "nameLast":"Last",
    "email":"first.last@example.com",
    "ref":"890qv",
    "localeId":"en",
    "directGroupMembership":[
        "haplo:group:example"
    ]
}

Returns

This request can respond with following kinds, in addition to the generic kinds (see Introduction):

Kind Meaning
haplo:api-v0:user:update The request was successful and the updated user’s details have been returned
haplo:api-v0:user:update-failed The user could not be created with the provided details. Returns with HTTP status 400
haplo:api-v0:user:no-such-user No user could be found with the requested id. Returns with HTTP status 400

Along with the standard success and kind fields (see Introduction for explanation), the response has the following structure:

  • user
    • id
    • nameFirst
    • nameLast
    • name
    • code
    • email
    • ref
    • isGroup
    • isActive
    • isSuperUser
    • isServiceUser
    • isAnonymous
    • localeId
    • directGroupMembership

Apart from directGroupMembership, all the fields correspond directly to the equivalent field on the SecurityPrincipal. directGroupMembership is the equivalent of directGroupIds, but returns an array of group API codes instead of group IDs.

Example

{
    "success": true,
    "kind": "haplo:api-v0:user:details",
    "user": {
        "id":130,
        "nameFirst":"First",
        "nameLast":"Last",
        "name":"First Last",
        "code":null,
        "email":"first.last@example.com",
        "ref":null,
        "isGroup":false,
        "isActive":true,
        "isSuperUser":false,
        "isServiceUser":false,
        "isAnonymous":false,
        "localeId":"en",
        "directGroupMembership":[
            "haplo:group:example"
        ]
    }
}