Step 1: Create a User
To create a new user, you will use the Users: Create endpoint (see docs). In the request body, the required fields to create a user are:
id
firstName
lastName
emailAddress
If you want the newly created user to be able to log into the Yext platform upon creation, then you will also need to provide at least one Access Control in the acl field of the request body. An Access Control (ACL) is defined by:
- The
roleId
androleName
fields, which can be found by making a request to: - The
onType
field, which represents the type of object the role is to be applied to. This value is one of:- ACCOUNT - if you would like the user to have the permissions associated with the selected role on the entire account
- ENTITY - if you would like the user to have the permissions associated with the selected role on a specific entity
- FOLDER - if you would like the user to have the permissions associated with the selected role on the entities in a specific folder
- The
on
field, which represents the id of the object the role is to be applied to. For example:- If onType = ACCOUNT,
on
== account id - If onType = ENTITY,
on
is the entity id - If onType = FOLDER,
on
is the folder id
- If onType = ACCOUNT,
- The
accountId
field, which is the id of the Yext account the user should be created under.
Now, you are ready to make your call! In this example, we are creating a user for John Doe
with the built-in Account Manager
role applied to the full account.
POST https://api.yextapis.com/v2/accounts/{accountId}/users?v=YYYYMMDD&api_key=API_KEY
{
"id": "testUser",
"firstName": "John",
"lastName": "Doe",
"username": "johnDoeSuperTest",
"emailAddress": "john.doe@emails.com",
"acl": [{
"roleId": "20",
"roleName": "Account Manager",
"on": "Your account id",
"accountId": "You account id",
"onType": "ACCOUNT"
}]
}
If the request is successful, you will get a 201 response containing the User id
you provided.
Feedback
<% elem.innerText %>