Skip to main content

Add Agent to Campaign

When integration requires it, agents can be added to a specific campaign through this API. Below, we outline how to perform this action.

You can check the Postman Collection to test in your instance.

All data enclosed in "{{ }}" are values that will be replaced with the client's own data and/or the corresponding instance.


HTTP Request

Method Resource
POST /Integra/resources/queues/addqueuemember

Request Header

Key Value
Content-Type application/x-www-form-urlencoded
Authorization Basic {{Token}}

Request Body

Parameter Type
Description
queuemember Text (String) An array of objects, where multiple users can be added to multiple campaigns; each object represents a user added to a campaign.

JSON Example

[
    {
        "membername": "{{UserName}}",
        "queueName": "{{CampaignName}}",
        "interface1": "SIP/{{AgentPhoneNumber}}",
        "penalty": 0,
        "paused": 0
    }
]

JSON Description

Parameter Type
Description
UserName Text (String) Agent's username
CampaignName Text (String) Name of the campaign to which the user wishes to be added
PhoneNumber
Text (String) Agent's phone number

Code Examples

You can copy the following code examples and replace the "{{variable}}" with the correct data.

HTTP

POST /Integra/resources/queues/addqueuemember HTTP/1.1
Host: {{domain}}.ucontactcloud.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {{Token}}
Content-Length: 221

queuemember=[{"membername":"{{UserName}}","queueName":"{{CampaignName}}","interface1":"SIP/{{AgentPhoneNumber}}","penalty":0,"paused":0}]
cURL
curl --location --globoff 'https://{{domain}}.ucontactcloud.com/Integra/resources/queues/addqueuemember' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic {{Token}}' \
--data-urlencode 'queuemember=[{"membername":"{{UserName}}","queueName":"{{CampaignName}}","interface1":"SIP/{{AgentPhoneNumber}}","penalty":0,"paused":0}]'
JavaScript
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("Authorization", "Basic {{Token}}");

const urlencoded = new URLSearchParams();
urlencoded.append("queuemember", "[{\"membername\":\"{{UserName}}\",\"queueName\":\"{{CampaignName}}\",\"interface1\":\"SIP/{{AgentPhoneNumber}}\",\"penalty\":0,\"paused\":0}]");

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: urlencoded,
  redirect: "follow"
};

fetch("https://{{domain}}.ucontactcloud.com/Integra/resources/queues/addqueuemember", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
JQuery
var settings = {
  "url": "https://{{domain}}.ucontactcloud.com/Integra/resources/queues/addqueuemember",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Basic {{Token}}"
  },
  "data": {
    "queuemember": "[{\"membername\":\"{{UserName}}\",\"queueName\":\"{{CampaignName}}\",\"interface1\":\"SIP/{{AgentPhoneNumber}}\",\"penalty\":0,\"paused\":0}]"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
C#
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://{{domain}}.ucontactcloud.com/Integra/resources/queues/addqueuemember");
request.Headers.Add("Authorization", "Basic {{Token}}");
var collection = new List<KeyValuePair<string, string>>();
collection.Add(new("queuemember", "[{\"membername\":\"{{UserName}}\",\"queueName\":\"{{CampaignName}}\",\"interface1\":\"SIP/{{AgentPhoneNumber}}\",\"penalty\":0,\"paused\":0}]"));
var content = new FormUrlEncodedContent(collection);
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "queuemember=[{\"membername\":\"{{UserName}}\",\"queueName\":\"{{CampaignName}}\",\"interface1\":\"SIP/{{AgentPhoneNumber}}\",\"penalty\":0,\"paused\":0}]");
Request request = new Request.Builder()
  .url("https://{{domain}}.ucontactcloud.com/Integra/resources/queues/addqueuemember")
  .method("POST", body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .addHeader("Authorization", "Basic {{Token}}")
  .build();
Response response = client.newCall(request).execute();
Python
import http.client

conn = http.client.HTTPSConnection("{{domain}}.ucontactcloud.com")
payload = 'queuemember=[{"membername":"{{UserName}}","queueName":"{{CampaignName}}","interface1":"SIP/{{AgentPhoneNumber}}","penalty":0,"paused":0}]'
headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
  'Authorization': 'Basic {{Token}}'
}
conn.request("POST", "/Integra/resources/queues/addqueuemember", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))




HTTP Response

Responses indicating an error due to the sent data will generally be delivered with an HTTP 200 code and a "0" or "1" in the body of the response, so caution should be exercised when validating the HTTP Response Code.

The received response is in text format, so it will need to be converted to JSON to view the data correctly.

Successful Response

1

Error Response

0