Saltar al contendio prinicipal

Users

Advertencia

Esta página aún no se encuentra traducida al español.

Overview

A user represents a person or bot that can perform actions within a company and execute client-side actions such as participating in tasks, entering channels, answering surveys, and sending messages.

The users endpoint can be used to search for users, retrieve information, or group them by filtering their data. All this allows using user information for further automations.

additional resources

These are just some of the most basic API requests. For a complete list of endpoints, consult our API documentation on Swagger.

Get Users

Returns data from all users in the company.

GET /users

Endpoint URL

https://www.cotalker.com/api/v2/users

Headers

HeaderDescriptionRequiredValues
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN

Query Parameters

ParameterDescriptionTypeRequiredNotes
searchReturns users that match the keywords in the users.search array.stringOptional
limitLimits the amount of users returned in the response.numberOptionalBy default, the limit is set to 10.
pageMakes the response display data from the indicated page number.numberOptionalBest used in combination with the "limit" parameter.
countAdds the counter field with the total amount of users.booleanOptional
orderByOrders the users by ascendeing or descending order according to the users.modifiedAt field.stringOptionalOptions: asc, desc
sortByFor the user endpoint, the response is sorted only by its default, i.e., the users.modifiedAt field.stringOptional
isActiveReturns users according to their users.isActive status.stringOptionalOptions are: all, true, false
emailReturns users with the emails contained in the array.string[ ]Optional
botReturns users with the indicated COTBot ObjectIds in their users.bot field.ObjectId<COTBot>[ ]Optional
idReturns users with the indicated ObjectIds in their users._id field.ObjectId<COTUser>[ ]Optional
relatedUserReturns users related to the indicated user according the users.companies.hierarchy field.ObjectId<COTUser>Optional
propertyReturns users associated with the indicated property: users.properties.ObjectId<COTProperty>Optional
accessRoleReturns users with the indicated access role: users.accessRoles.ObjectID<COTAccessRole>Optional
jobReturns users associated with the indicated job title: users.job.ObjectId<COTJobTitle>Optional
modifiedReturns users with the indicated modification date: users.modifiedAtISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
modified_gtReturns users modified after the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
modified_gteReturns users with a users.modifiedAt equal to or greater than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
createdReturns users with the indicated creation date: users.createdAtISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_gtReturns users created after the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_gteReturns users with a users.createdAt equal to or greater than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_ltReturns users created before the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
created_lteReturns users with a users.createdAt equal to or less than the indicated date and time.ISODateOptionalYYYY-MM-DDTHH:mm:ss.SSSZ
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Samples

This default request gets all the user data in the company.

curl --location --request GET 'https://www.cotalker.com/api/v2/users' \
--header 'Authorization: Bearer $ACCESS_TOKEN'

Response Sample

Responses follow the COTUser data model.


Get Current User

Returns the current user data.

GET /users/me

Endpoint URL

https://www.cotalker.com/api/v2/users/me

Headers

HeaderDescriptionRequiredValues
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN

Request Sample

curl --location --request GET 'https://www.cotalker.com/api/v2/users/me' \
--header 'Authorization: Bearer $ACCESS_TOKEN'

Response Sample

Response follows the COTUser data model.


Get User by Id

Returns the user indicated by the Id.

GET /users/{id}

Endpoint URL

https://www.cotalker.com/api/v2/users/{id}

Path Parameters

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the user that is to be returned.ObjectId<COTUser>Required

Headers

HeaderDescriptionRequiredValues
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Sample

curl --location --request GET 'https://www.cotalker.com/api/v2/users/6194f0345923b62967d7ba46' \
--header 'Authorization: Bearer $ACCESS_TOKEN'

Response Sample

Response follows the COTUser data model.


Create a New User

Creates a new user in the company following the COTUser data model.

POST /users

Endpoint URL

https://www.cotalker.com/api/v2/users

Headers

HeaderDescriptionRequiredValues
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
AdminGrants administrative access to create a user.Requiredtrue
Content-TypeSets the body's format.Requiredapplication/json

Query Parameters

ParameterDescriptionTypeRequiredNotes
notifyEmailSends an email notification to the newly created user. Only works when no password has been set.stringOptionalOption: true
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Body

Only required fields are listed below. For a complete schema description, please go to the COTUser data model. Unrequired fields that are not submitted are either filled in automatically or left blank.

ElementDescriptionTypeRequiredNotes
accessRolesThe access roles the user has been designated.ObjectID<COTAccessRole>[ ]Required
emailThe user's email.stringRequiredThe email cannot be changed.
nameUser's full name.object
name.displayNameDisplayed name on channel.stringRequired
name.namesThe user's first and second names.stringRequired
name.lastNameThe user's surname.stringRequired
name.secondLastNameThe user's second surname.stringRequired

Request Sample

User created with minimum fields required:

curl --location --request POST 'https://www.cotalker.com/api/v2/users?debug=true' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": {
"displayName": "Ma Tianbo",
"names": "Tianbo",
"lastName": "Ma",
"secondLastName": ""
},
"email": "apple@jingmen.com",
"accessRoles": [
"619538262eebe7f03bde3db0",
"6195382e7fde7e397f8b1f88",
"61953833306b4481a5f5a34b"
]
}'

Response Sample

Go to COTUser for a complete description of the response.

{
"_id": "61953bf9bdc3558a4966e54d", // automatically generated ObjectId
"name": {
"displayName": "",
"names": "Tianbo",
"lastName": "Ma",
"secondLastName": ""
},
"properties": [],
"accessRoles": [ // ObjectId<COTAccessRole>[ ]
"619538262eebe7f03bde3db0",
"6195382e7fde7e397f8b1f88",
"61953833306b4481a5f5a34b"
],
"isActive": true,
"termsConditions": false,
"search": [ // automatically generated keywords
"tianbo",
"ma",
"apple",
"jingmen",
"com",
"applejingmencom"
],
"isOnline": false,
"email": "apple@jingmen.com",
"companies": [
{
"hierarchy": {
"boss": [],
"peers": [],
"subordinate": []
},
"_id": "61953bd8a1dd11a1943c28be", // automatically generated ObjectId
"companyId": "61953bd2155295659c76859c" // ObjectId<COTCompany>
}
],
"lastRequestDate": "2021-11-17T15:34:42.171Z",
"createdAt": "2021-11-17T15:34:42.171Z",
"modifiedAt": "2021-11-17T15:34:42.206Z",
"extensions": {}
}

Update a User

Adds, updates, or edits an existing user's information.

PATCH /users/{id}

Endpoint URL

https://www.cotalker.com/api/v2/users/{id}

Path Parameters

ParameterDescriptionTypeRequiredNotes
idThe ObjectId of the user that is to be modified.ObjectId<COTUser>Required

Headers

HeaderDescriptionRequiredValues
AuthorizationSends your access token to make an API request.
Click here to see how to obtain an access token.
RequiredBearer $ACCESS_TOKEN
AdminGrants administrative access to modify a user.Requiredtrue
Content-TypeSets the body's format.Requiredapplication/json

Query Parameters

ParameterDescriptionTypeRequiredNotes
debugAdds the debug field with error notifications.stringOptionalOption: true

Request Body

Only the fields that are being updated or added are required to be put into the body. For a complete schema description, please go to the COTUser data model.

Request Sample

Updating a user's phone number:

curl --location --request PATCH 'https://www.cotalker.com/api/v2/users/61953bf9bdc3558a4966e54d' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"phone": "8675309"
}'

Response Sample

Go to COTUser for a complete description of the response.

{
"_id": "61953bf9bdc3558a4966e54d", // automatically generated ObjectId
"name": {
"displayName": "",
"names": "Tianbo",
"lastName": "Ma",
"secondLastName": ""
},
"properties": [],
"accessRoles": [ // ObjectId<COTAccessRole>[ ]
"619538262eebe7f03bde3db0",
"6195382e7fde7e397f8b1f88",
"61953833306b4481a5f5a34b"
],
"isActive": true,
"termsConditions": false,
"search": [ // automatically generated keywords
"tianbo",
"ma",
"apple",
"jingmen",
"com",
"applejingmencom"
],
"isOnline": false,
"email": "apple@jingmen.com",
"companies": [
{
"hierarchy": {
"boss": [],
"peers": [],
"subordinate": []
},
"_id": "61953bd8a1dd11a1943c28be", // automatically generated ObjectId
"companyId": "61953bd2155295659c76859c" // ObjectId<COTCompany>
}
],
"lastRequestDate": "2021-11-17T15:34:42.171Z",
"createdAt": "2021-11-17T15:34:42.171Z",
"modifiedAt": "2021-11-17T15:34:42.206Z",
"phone": "8675309",
"extensions": {}
}