Skip to content
Directory & LifecycleMarkdown

Add users and groups

Create your first users, put them in their groups, and see one of them sign in, in about ten minutes.

API

Your engineering and finance teams are starting to use the realm. You add Maya and Ben, create an engineering and a finance group, put each of them in theirs, and check that Maya can sign in. Everything you give a group from then on reaches its members.

Before you start: you’re a realm administrator holding RealmOwner, with your session in $CVYUH_SESSION (see Call the API).

  1. Create Maya, naming her maya, with a first password:

    Terminal window
    curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user?id=maya" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "uid": "maya", "firstName": "Maya", "lastName": "Chen", "displayName": "Maya Chen",
    "email": "maya@example.com", "passwordHash": "<a first password>" }'

    The realm answers 201 with her record. Her password isn’t in it: the realm stored only a hash of it.

  2. Create Ben the same way, with ?id=ben and his own details.

  3. Create the groups:

    Terminal window
    curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/group?id=engineering" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "displayName": "Engineering", "description": "Everyone who builds the product" }'
    curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/group?id=finance" \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "displayName": "Finance", "description": "Everyone who runs the books" }'
  4. Put each of them in their group:

    Terminal window
    curl https://foobar.cvyuh.com/api/v0/am/objects/v1/group/engineering/relationships/member \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -H "If-Match: *" \
    -d '{ "targetId": "maya" }'

    Then the same on /objects/v1/group/finance/relationships/member with { "targetId": "ben" }. Each answers 201.

Read Maya with her groups:

Terminal window
curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya?expand=memberOf/*" \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

engineering is in her memberOf, and her status is active, filled in by the realm. Then have Maya sign in to the realm with maya and her password. She’s in.

Remove a member with DELETE on /objects/v1/group/engineering/relationships/member/maya. Delete a user or a group with DELETE on /objects/v1/user/{id} or /objects/v1/group/{id}, each with If-Match: * or the revision you read.