Overview

public. Add or modify a user

Uri Parameters

None

Query Parameters
NameTypeDescription
accountpasswordstring?Account password to set (default: do not set/change password)
authpasswordstring?Password to use for verification with external authentication service
authusernamestring?Username to use for verification with external authentication service
noncestring?The unique key that may have been emailed out during user creation. Requires accountpassword.
Return Codes
NameValueDescription
BadRequest400Invalid input parameter or request body
Conflict409Username conflicts with an existing username
Forbidden403Administrator access or account owner is required
NotFound404Requested user could not be found
Ok200The request completed successfully

Message Format

Input: 

<user id="{int}">
    <username>{text}</username> 
    <email>{text}</email> 
    <fullname>{text}</fullname> 
    <status>{active|inactive}</status> 
    <service.authentication id="{int}" /> 
    <permissions.user> 
        <role>{text}</role> 
    </permissions.user> 
</user>

Output: 

<user id="{int}" href="{uri}">
    <nick>{text}</nick> 
    <username>{text}</username> 
    <email>{text}</email> 
    <page.home id="{int}" href="{int}">
        <title>{text}</title> 
        <path>{text}</path> 
    </page.home>
    <fullname>{text}</fullname> 
    <status>{active|inactive}</status> 
    <date.lastlogin>{date}</date.lastlogin> 
    <service.authentication id="{int}" href="{uri]" /> 
    <permissions.user>
        <operations mask="{int}">{text}</operations> 
        <role id="{int}" href="{uri}">{text}</role> 
    </permissions.user>
    <permissions.effective>
        <operations mask="{int}">{text}</operations> 
    </permissions.effective>
    <groups count="{int}" href="{uri}">  
        <group id="{int}" href="{uri}">  
            <name>{text}</name>   
            <service.authentication id="{int}" href="{uri}" />   
            <users count="{int}" href="{uri}" />   
            <permissions.group>  
                <operations mask="{int}">{text}</operations>   
                <role id="{int}" href="{uri}">{text}</role>   
            </permissions.group>  
        </group>  
    ...
    </groups> 
</user>

Implementation Notes

If no user ID is specified, a new user is created.  Otherwise, the existing user is updated. 

Note that it is not possible to modify an existing user's username or authentication service.  It is also not possible to create two users having the same username.

Code Samples

The following code example creates "newuser1".  This user has the Contributor role, uses the local authentication service, and has account password "mypassword":

Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
XDoc usersDoc = new XDoc("user")
    .Elem("username", "newuser1")
    .Elem("email", "newuser1@mindtouch.com")
    .Elem("fullname", "newuser1's full name")
    .Start("permissions.user")
        .Elem("role", "Contributor")
    .End();
p.At("users").With("accountpassword", "mypassword").Post(usersDoc);

Sample response indicating that the new user was successfully created:

<user id="3" href="http://deki-hayes/@api/deki/users/3">
    <nick>newuser1</nick> 
    <username>newuser1</username> 
    <email>newuser1@mindtouch.com</email> 
    <fullname>newuser1's full name</fullname> 
    <status>active</status> 
    <date.lastlogin>2007-09-06T00:56:51Z</date.lastlogin> 
    <service.authentication id="1" href="http://deki-hayes/@api/deki/site/services/1" /> 
    <permissions.user>
        <operations mask="1343">LOGIN,BROWSE,READ,SUBSCRIBE,UPDATE,CREATE,DELETE,CHANGEPERMISSIONS</operations> 
        <role id="4" href="http://deki-hayes/@api/deki/site/roles/4">Contributor</role> 
    </permissions.user>
    <permissions.effective>
        <operations mask="1343">LOGIN,BROWSE,READ,SUBSCRIBE,UPDATE,CREATE,DELETE,CHANGEPERMISSIONS</operations> 
    </permissions.effective>
    <groups /> 
</user>
Tag page
You must login to post a comment.