Overview
Once the customers are mapped out as organizations, the next step is to start mapping out their employees to the corresponding organization users in the Tesouro platform.Create a user role
Every organization user must have a role. A role defines the permissions that a user has to access and update the organization’s resources in Tesouro. When a token is issued for an organization user, it inherits the permissions of their assigned role. If no role is explicitly assigned to a user, the organization’s default user role is used instead. Roles are created by callingPOST /roles. The partner-level token and the organization ID are required for this action.
In the example below, a new role is created to allow read access to the comment and payable objects:
GET /roles/{role_id}.
Create an organization user
To create an organization user, callPOST /entity-users. Specify the organization ID in the X-Organization-Id request header and the user data in the request body. The role_id field must be populated by the ID of the role created earlier. The request must be authorized using a partner-level access token:
Set the profile picture
To set the organization user’s profile picture, callPOST /files and provide the file as a multipart/form-data request. Use the file field to pass the file, and set the file_type field to userpics:
PATCH /entity-users/{entity_user_id} and provide the document ID in the userpic_file_id field in the request body:
GET /files/{file_id} and DELETE /files, respectively.
List all organization users
To get information about all the organization users managed by the organization, callGET /entity-users.
Retrieve an organization user
To get information about a specific organization user, callGET /entity-users/{entity_user_id}.
Edit an organization user
To edit an existing organization user, callPATCH /entity-users/{entity_user_id}.
Delete an organization user
To delete an existing organization user, callDELETE /entity-users/{entity_user_id}.
Get an organization user token
To make API calls on behalf of an organization user, you need to use an access token of that user. To get this token, callPOST /auth/token with the following request body:
Authorization: Bearer TOKEN request header as an alternative to using a partner-level token.
Get and update the authenticated user info
The authenticated organization user can check all its own information by callingGET /entity-users/me. The request must be authorized using an organization user level-access token:
PATCH /entity-users/me, passing the information they wish to update. In the example below, the last_name field is being updated. The request must be authorized using an organization user level-access token:
Get the role of the authenticated organization user
To retrieve information about the role and permissions assigned to the authenticated organization user, callGET /entity-users/my-role: