# Campaigns

Source: https://docs.qvoice.net/api/campaigns/

## Contact center - Campaigns API documentation

## Table of contents

Get access token

Get Campaigns status and Leads by status

Get Leads status by Campaign

Get Queues status

Get Campaigns activity

Add Lead to campaign

Set Lead status

Delete Lead

Set call disposition to voicemail

## Endpoints

### Get access token

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/login |
| *verb* | POST |
| *request body* | {   "username": "yourUserName",   "password": "yourPassword",   "domain": "yourTenant"  } |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Response body:  {      "user": {          ...      },      "access\_token": "**{access\_token\_value}**",      "refresh\_token": "**{refresh\_token\_value}**"  } |
| 400 | The information sent is invalid. |
| 500 | Error due to an internal issue. |

### Get Campaigns status and Leads by Status

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/reports/campaigns/leads/status |
| *verb* | GET |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Response body:  {    “campaing\_id\_1”: {         “name”: “campaign\_1”,         “status”: “stopped”,         “total\_leads”: 44,         “leads\_by\_status”: {            “new”: 4,            “success”: 10,            “failed”: 5,            “success”: 25          }    }     …    “campaing\_id\_n”: {         “name”: “campaign\_n”,         “status”: “stopped”,         “total\_leads”: 53,         “leads\_by\_status”: {            “new”: 8,           “success”: 15,           “failed”: 5,           “success”: 25          }    }  } |
| 400 | The information sent is invalid. |
| 500 | Internal server error |

### Get Leads status by Campaign

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/config/campaigns/{campaign\_id}/leads |
| query param | page\_size |
| query param | next\_start\_key |
| *verb* | GET |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Response body:  {   "data":    [{      "created": 1665762498,      "campaign\_id": "210ea5d942f41744f1ef37e84a4965e0",      "number": "+12131204",      "status": "new",      "retries": 11,      "first\_name": "Piper",      "last\_name": "Huffman",      "priority": 4,      "id": "210ea5d942f41744f1ef37e84a59878d"    },    {      "created": 1665762674,      "campaign\_id": "210ea5d942f41744f1ef37e84a4965e0",      "number": "+12131214",      "status": "new",      "retries": 11,      "first\_name": "Yash",      "last\_name": "Ellwood",      "priority": 4,      "id": "210ea5d942f41744f1ef37e84a5a1f95"    }  ], “next\_start\_key”: “9f6b620d4d5e82e16a822fdff7210a8f” } |
| 400 | The information sent is invalid. |
| 500 | Internal server error |

### Get Queues Status

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/callcenter/queues/status |
| *verb* | GET |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Response body:  [{     "id": "9ba7842e-f51c-4156-9bee-1f4aa7466b1e",     "name": "QueueName",     "extension": "5586",     "max\_time\_caller\_in\_queue": 120,     "strategy": "single",    "agents": [    {      "id": "8d0af2bafb82d021dc1fb5b09996d7d6",      "name": "Agent1 Name",      "extension": "5865",      "extension\_is\_valid": true,      "delay": 0,      "timeout": 15,      "logged\_in": false,      "status": "idle",      "registered": false,      "tags": [{                     "id": "6057e10976cba5c054d4a00e8aad9bc8",                     "name": "Batch-W??B1",                     "color": "#b306f1"                   }]    }],     "calls": {},     "total\_agents": 1,      "logged\_in\_agents": 0,      "logged\_out\_agents": 1,      "idle\_agents": 0,      "misconfigured\_agents": 0,       "agents\_registered": 0,       "agents\_on\_call": 0  }] |
| 400 | The information sent is invalid. |
| 500 | Internal server error |

### Get Campaigns activity

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/reports/campaigns/leads/history?starDate=1652977920&endDate=1652978220220&pageSize=1000 |
| *verb* | GET |
| *query param* | startDate: lower time limit in Unix timestamp |
| *query param* | endDate: upper time limit in Unix timestamp |
| *query param* | pageSize: max quantity of records to get |
| *query param* | startKey: pagination index |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Response body:  [{      "datetime": "2022-10-19 23:31:58 +0000 UTC",      "timestamp": 1666222318,      "campaign\_name": "load\_test\_camp\_1",      "lead\_name": "Raven Shields",      "lead\_number": "+12195011918",      "agent\_name": "Jim Jones71",      "agent\_extension": "1071",      "lead\_history": [          {              "agent": {                  "delay": 0,                  "device\_endpoints": [],                  "email": "jones8@jones.com",                  "endpoint": "009ec0f42923cceb8ce819aee367a215",                  "ext": "1008",                  "first\_name": "Jim",                  "last\_answered": 1666221871.9237537,                  "last\_attempt": 1666221871.916515,                  "last\_hangup": 0,                  "last\_name": "Jones8",                  "status": "idle",                  "timeout": 20,                  "total\_talk\_time": 0,                  "type": "user"              },              "event": "campaign dial",              "ext": "1008",              "last\_attempt": 1666222318.0263362,              "type": "dial agent",              "uuid": "d7bf2f395cf9adddece9dd8df49712f13d39-clicktocall"          }] |
| 400 | The information sent is invalid. |
| 500 | Internal server error |

### Add Lead to campaign

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/config/campaigns/{campaign\_id}/lead |
| *verb* | PUT |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |
| *Request body* | {      “number”: string,      “retries”: int,      “first\_name”: string,      “last\_name”:  string,      “type”: string,      “priority”: int,      “ticket\_id”:  string,      “note”: string,      “cool\_off”: int  } |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Lead added to campaign successfully. |
| 400 | The information sent is invalid. |
| 500 | Internal server error |

### Set lead status

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/config/campaigns/leads/{leadID}/status/{status} |
| *verb* | POST |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Lead status set successfully. |
| 400 | The information sent is invalid. |
| 500 | Error due to an internal issue. |

### Delete lead

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/config/campaigns/leads/{leadID} |
| *verb* | DELETE |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Lead deleted successfully. |
| 400 | The information sent is invalid. |
| 500 | Error due to an internal issue. |

### Set call disposition to Voicemail

|  |  |
| --- | --- |
| ***Request*** | |
| *endpoint* | https://{portalURL}:9443/api/v2/config/campaigns/call/{cdrID}/disposition/voicemail |
| *verb* | PUT |
| *header* | X-Account-ID: {account\_id} |
| *header* | Authorization: “Bearer **{access\_token\_value}**” |

|  |  |
| --- | --- |
| ***Response*** | |
| ***Code*** | ***Description*** |
| 200 | Call disposition set successfully. |
| 400 | The information sent is invalid. |
| 500 | Error due to an internal issue. |
