Get started with Directory & Lifecycle
Add your first user and your first group, put the user in the group, and read it back, in four calls.
API
In this page you add Maya to your realm, create an engineering group, and make her a member of it. From then on,
everything you give the group, such as an entitlement, a policy or a shared vault, reaches her, and leaves her the
moment she leaves the group.
Before you begin
Section titled “Before you begin”- A realm administrator’s account. You need an account in a group that holds the realm’s
RealmOwnerprivilege. See Delegated administration. - A session for the API. Sign in as that administrator and keep the session in
$CVYUH_SESSION, as Call the API describes. Every call below sends it as a cookie. curl, or any HTTP client. The calls use your realm’s own host; replacefoobarwith your realm’s.
Add a user to a group
Section titled “Add a user to a group”-
Check your session. Ask the realm who you are:
Terminal window curl -X POST https://foobar.cvyuh.com/api/v0/am/whoami/v1 \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION"The answer names you, your
rolesin the realm and how long the session has left (session.expiresInSecs). A401means the session has ended: sign in again. -
Add Maya. Create a user, naming it
mayawith?id=, with her sign-in name inuidand 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
201with her record:{"id": "<internal id>","objectId": "maya","typeName": "user","rev": <rev>,"attributes": { "uid": "maya", "displayName": "Maya Chen", "email": "maya@example.com","firstName": "Maya", "lastName": "Chen", "status": "active" },"createTime": "<RFC 3339 time>","updateTime": "<RFC 3339 time>"}The realm filled
statuswithactive, and stored only a hash of her password, which no read returns. -
Create the group.
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" }'The realm answers
201with the group. -
Put Maya in the group. Link her to the group’s
memberlist, naming her by her id: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" }'The realm answers
201with the link and the group’s new revision:{ "_id": "engineering", "property": "member", "targetId": "maya", "rev": <rev> }
Check it worked
Section titled “Check it worked”Read Maya with her groups expanded:
curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya?expand=memberOf/*" \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"Her attributes.memberOf lists one link, to engineering:
"memberOf": [ { "id": "<internal id>", "edgeId": "<internal id>", "properties": {}, "objectId": "engineering", "type": "group", "object": { "displayName": "Engineering", "description": "Everyone who builds the product" } }]The link is stored once and read from both ends, so the group’s member list holds Maya as well. Maya can now sign
in to the realm with maya and her password.