Step 2: Retrieve Users

Overview

Now that you know how to create a user via the API we will show you how to retrieve a user or set of users. When retrieving users, you have two options: you can also use the Users: List endpoint to retrieve a list of users within the account, or you can use the Users: Get endpoint to retrieve details of a specific user.

Example

Let’s use the Users: Get endpoint to confirm the User you just created:

GET https://api.yextapis.com/v2/accounts/[accountId]/users/[userId]?v=YYYYMMDD&api_key=API_KEY

The response will return a User object with the data you submitted earlier.

{
	"id": "testUser",
	"firstName": "John",
	"lastName": "Doe",
	"username": "johnDoeSuperTest",
	"emailAddress": "john.doe@emails.com",
	"acl": [{
		"roleId": "20",
		"roleName": "Account Manager",
		"on": "Your account id",
		"accountId": "[YOUR ACCOUNT ID]",
		"onType": "ACCOUNT"
	}],
	"sso": false
}

Update a User’s Information

Let’s try editing the User you created. In the request below, we will update the User’s last name from ‘Doe’ to ‘Doehring’. Note you must include the id, firstName, lastName, username, emailAddress fields when editing a User.

PUT https://api.yextapis.com/v2/accounts/{accountId}/users/{userId}?v=YYYYMMDD&api_key=API_KEY

{ 
	"id": "testUser",
	"firstName": "John",
	"lastName": "Doehring",
	"username": "johnDoeSuperTest",
	"emailAddress": "john.doe@emails.com",
}

Similar to the Users: Create request, the response will return a 200 response with the User id in the response body like this:

{
        "id": "testUser"
}

Try making a few more update calls to see what other User details you can edit.

Update a User’s Password

You may have noticed during your testing that the Users: Update call does not let you update the User’s password. For security purposes, you must send the following request to assign a new password to a User:

PUT https://api.yextapis.com/v2/accounts/{accountId}/users/{userId}/password?v=YYYYMMDD&api_key=API_KEY

{
        "newPassword": "myNewPassword"
}

The request should return a 200 response with no response body. Now try updating the password to something a bit more secure and harder to guess.

Feedback