Property Types (Collections)
Esta página aún no se encuentra traducida al español.
Overview
Property types, also know as collections, are versatile databases that can be set up to carry out diverse functions in the Cotalker environment. Property types can store company assets, describe workflow states, act as a filter, contain options for multiple-choice questions in surveys, grant permissions, and much more. Some common examples include "Store Locations", "Company Departments", "Products", "Clients", "Contacts", "Brands", "Task States", among others.
Property types contain properties or elements, which can be thought of as the rows in a table or better yet, as the documents in a MongoDB collection. Each property has at least a "Name", a "Code" and a "Unique Id". These fields are the basic columns of the table. But each collection may have more columns by adding fields, making properties more descriptive. For example, a collection that holds "store locales" can have additional fields that contain address, employee number, store size, performance indicators, or any other information that needs to be associated with the collection's properties.
These are just some of the most basic API requests. For a complete list of endpoints, consult our API documentation on Swagger.
Get Property Types
Returns all property types within the company.
GET /propertyTypesEndpoint URL
https://www.cotalker.com/api/v2/propertyTypes
Headers
Header | Description | Required | Values |
---|---|---|---|
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
search | Returns property types with field values that match the query. | string | Optional | |
limit | Limits the amount of property types returned in the response. | number | Optional | By default, the limit is set to 10. |
page | Makes the response display data from the indicated page number. | number | Optional | Best used in combination with the "limit" parameter. |
count | Adds the counter field with the total amount of property types within the company. | boolean | Optional | |
orderBy | Orders the property types by ascendeing or descending order according to their modifiedAt field. | string | Optional | Options: asc , desc |
sortBy | Sorts property types in the response according to the their creation date or the last time they were modified. | string | Optional | Options are: createdAt , modifiedAt . |
ids | Returns property types with the IDs indicated in the array. | ObjectId<COTPropertyType>[ ] | Optional | |
codes | Returns property types with the code names indicated in the array. | string[ ] | Optional | Code names are stored in the code field within the COTPropertyType data model. |
isActive | Returns property types according to their isActive status. | string | Optional | Options are: all , true , false |
viewPermissions | Returns property types based on whether they have or don't have viewing permissions. | boolean | Optional | Viewing permissions are indicated in the viewPermissions field in the COTPropertyType data model. |
modified | Returns property types with the indicated modification date in the modifiedAt field. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_gt | Returns property types modified after the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_gte | Returns property types with a value in the modifiedAt field equal to or greater than the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_lt | Returns property types modified before the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
modified_lte | Returns property types with a value in the modifiedAt field equal to or less than the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
created | Returns property types with the indicated creation date in the createdAt field. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
created_gt | Returns property types created after the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
created_gte | Returns property types with a value in the createdAt field equal to or greater than the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
created_lt | Returns property types created before the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
created_lte | Returns property types with a value in the createdAt field equal to or less than the indicated date and time. | ISODate | Optional | YYYY-MM-DDTHH:mm:ss.SSSZ |
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Samples
- cURL (default)
- cURL (query)
- Typescript (default)
This default request gets all the property types in the company.
curl --location --request GET 'https://www.cotalker.com/api/v2/propertyTypes' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
This request gets property types by their code names.
curl --location --request GET 'https://www.cotalker.com/api/v2/propertyTypes?codes=mammals_00&codes=sea_mammals&codes=land_mammals_00&debug=true&count=true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
This example gets all the property types in the company.
// $ACCESS_TOKEN stored in .env file.
import { PropertyTypeGetCollection, Configuration, V2PropertyTypesApi} from "@cotalker/cotalker-api";
const api = new V2PropertyTypesApi(new Configuration({
basePath: 'https://www.cotalker.com/api',
accessToken: process.env.ACCESS_TOKEN,
apiKey: 'true',
}));
async function getPropertyTypes(): Promise<PropertyTypeGetCollection | undefined> {
const response = await api.getV2PropertyTypes();
return response.data?.data;
}
getPropertyTypes().then(propertyTypes => console.log(propertyTypes)).catch(e=>console.log(e))
Response Sample
Responses follow the COTPropertyType data model.
Get a Property Type by Id
Returns the property type indicated by the Id.
GET /propertyTypes/{id}Endpoint URL
https://www.cotalker.com/api/v2/propertyTypes/{id}
Path Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
id | The ObjectId of the property type that is to be returned. | ObjectId<COTPropertyType> | Required |
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Grants access to request the endpoint. | Required | true |
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Sample
curl --location --request GET 'https://www.cotalker.com/api/v2/propertyTypes/61a0cd6dc8f28f266b614d60' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN'
Response Sample
The response follows the COTPropertyType data model.
Create a New Property Type
Creates a new property type within the company.
POST /propertyTypesEndpoint URL
https://www.cotalker.com/api/v2/propertyTypes
Headers
Header | Description | Required | Values |
---|---|---|---|
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Admin | Grants administrative access to create a new property type. | Required | true |
Content-Type | Indicates the body's format. | Required | application/json |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
debug | Adds the debug field with error notifications. | string | Optional | Option: true |
Request Body
Only required fields are listed below. For a complete schema description, please go to the COTPropertyType data model. Unrequired fields that are not submitted are either filled in automatically or left blank.
Element | Description | Type | Required | Notes |
---|---|---|---|---|
display | The property type name users will see on the platform. | string | Required | |
code | The property type's unique identification name. | string | Required | Maximum 60 characters; only lowercase letters, numbers, and underscores allowed; must be unique. |
Request Sample
Property type created with the minimum required fields:_
curl --location --request POST 'https://www.cotalker.com/api/v2/propertyTypes' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"display": "Warehouse Supplies",
"code": "warehouse_supplies_00"
}'
Response Sample
Go to COTPropertyType for a complete description of the response.
{
"isActive": true,
"viewPermissions": [],
"_id": "61a0cd6dc8f28f266b614d60",
"display": "warehouse supplies",
"code": "warehouse_supplies_00",
"company": "6136968b580aaf2b0e49d844",
"createdAt": "2021-11-26T11:55:38.190Z",
"modifiedAt": "2021-11-26T11:55:38.190Z",
"schemaNodes": [],
"__v": 0
}
Update a Property Type
Updates or edits an existing property type's data.
PATCH /propertyTypes/{id}Endpoint URL
https://www.cotalker.com/api/v2/propertyTypes/{id}
Path Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
id | The ObjectId of the property type that is to be modified. | ObjectId<COTPropertyType> | Required |
Headers
Header | Description | Required | Values |
---|---|---|---|
Admin | Grants administrative access to modify a property type. | Required | true |
Authorization | Sends your access token to make an API request. Click here to see how to obtain an access token. | Required | Bearer $ACCESS_TOKEN |
Content-Type | Sets the body's format. | Required | application/json |
Query Parameters
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
debug | Adds the debug field with error notifications. | string | Optional | Option: 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 COTPropertyType data model.
Request Sample
This sample adds a viewing permission to a property type:
curl --location --request PATCH 'https://www.cotalker.com/api/v2/propertyTypes/61a0d8729726b9c9fd398846?debug=true' \
--header 'Admin: true' \
--header 'Authorization: Bearer $ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"viewPermissions": ["admin-properties-read"]
}'
Response Sample
Go to COTPropertyType for a complete description of the response.
{
"isActive": true,
"viewPermissions": [
"admin-properties-read"
],
"_id": "61a0cb3a2c62a400076efa0f",
"display": "Warehouse Supplies",
"code": "warehouse_supplies_00",
"company": "6136968b580aaf2b0e49d844",
"createdAt": "2021-11-26T11:55:38.190Z",
"modifiedAt": "2021-11-26T11:55:38.190Z",
"schemaNodes": [],
"__v": 1
}