Create user

ENDPOINT /api/v0-user/create/ (POST only)

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

The body of the request should be a JSON document containing the fields below:

Field Explanation
nameFirst Required. The user’s first name
nameLast Required. The user’s last name
email Required. The email address for the user. Must be unique.
localeId Optional. If unspecified, will use the application’s default locale.
directGroupMembership Optional. Array of group API codes specifying the direct group membership of this user.

An optional parameter of welcomeLink can be included. Passing a value of 1 will include a welcome link for the newly created user to set their password and log in to the system.

Membership of std:group:everyone is implied, and should not be specified in directGroupMembership.

Example request body

{
    "nameFirst":"First",
    "nameLast":"Last",
    "email":"first.last@example.com",
    "localeId":"en",
    "directGroupMembership":[
        "std:group:administrators"
        "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:create The request was successful and the new user’s details have been returned
haplo:api-v0:user:creation-failed A user could not be created the provided details. Returns with HTTP status 400

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

  • welcomeLink (optional, see above)
  • 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 response

{
    "success": true,
    "kind": "haplo:api-v0:user:create",
    "welcomeLink": "https://app.example.org/do/authentication/welcome/130-abcdef1234567890",
    "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":[
            "std:group:administrators"
            "haplo:group:example"
        ]
    }
}