Skip to main content

Saving data

Comind API provides the possibility to add new records, delete, edit or run special transitions for existing records.

https://api.comindwork.com/api/tickets/multi

Permissions to edit and delete

During the updates of data - adding, deleting, editing or running specific transitions - the configured authorization is respected.

The system will throw error if the API requests the prohibited for the user transition.

Sample code

The most basic way to create a new task in a Helpdesk workspace:

curl --request POST ^
--url "https://api.comindwork.com/api/tickets/multi" ^
--json "[{title:'New task via API',process_template_id:'v2-default-app-task',project_id:'id-here'}]" ^
--header "Authorization:CMW_AUTH_CODE YOUR-AUTH-CODE-GOES-HERE"

This task can be further modified via API, referencing by ID and providing the name of the action:

curl --request POST ^
--url "https://api.comindwork.com/api/tickets/multi" ^
--json "[{id:'task-guid-goes-here',transition:'edit',title:'Changed title',priority:'high',comment:'Changing this...'}]" ^
--header "Authorization:CMW_AUTH_CODE YOUR-AUTH-CODE-GOES-HERE"

It is possible to delete this task as following:

curl --request POST ^
--url "https://api.comindwork.com/api/tickets/multi" ^
--json "[{id:'task-guid-goes-here',transition:'delete'}]" ^
--header "Authorization:CMW_AUTH_CODE YOUR-AUTH-CODE-GOES-HERE"

Node / Typescript Example

Loading all big deals in CRM workspace, double the price and save back:

// get all deals with 1000+ sum from CRM workspace
async function getBigDeals() {
const workspaceAlias = "CRM";
const appAlias = "DEAL";
const apiEndpoint = `w/${workspaceAlias}/a/${appAlias}/tickets/list`;
const allDeals = await comind.records.retrieve(apiEndpoint, {
limitRecords: 1000,
listOfFields: "id,title,c_amount",
rlx: `c_amount > 1000`,
});
console.warn(`Found ${allDeals.length} deals`);
return allDeals;
}

// get all deals with 1000+ sum from CRM workspace and double the price
async function saveBigDeals() {
const allDeals = await getBigDeals();
for (const deal of allDeals) {
deal.c_amount = deal.c_amount * 2;
deal.transition = "edit";
}
await this.comind.records.save(allDeals);
console.warn(`Saved ${allDeals.length} deals`);
}