# Create Agent

When an integration requires creating users from another platform, we can use this API to create agent-type users so they can make calls.

<p class="callout info">You can check the [Postman Collection](https://www.postman.com/dev-clever-ideas/ucontact/request/s8o7ma2/createagent?tab=overview "Create Agent") to test in your instance.  
</p>

<p class="callout info">All data enclosed in "{{ }}" are values that will be replaced with the client's own data and/or the corresponding instance.</p>

---

### HTTP Request

<table border="1" id="bkmrk-opci%C3%B3n-http-valor-re" style="border-collapse: collapse; width: 100%; height: 89.3907px;"><tbody><tr style="height: 29.7969px;"><td class="align-center" style="width: 22.284%; height: 29.7969px;">**Method**</td><td class="align-center" style="width: 77.8396%; height: 29.7969px;">**Resource**</td></tr><tr style="height: 29.7969px;"><td style="width: 22.284%; height: 29.7969px;">POST</td><td style="width: 77.8396%; height: 29.7969px;">/Integra/resources/sip/addsip</td></tr></tbody></table>

#### Request Header

<table border="1" id="bkmrk-key-value-content-ty" style="border-collapse: collapse; width: 100%; height: 89.3907px;"><tbody><tr style="height: 29.7969px;"><td class="align-center" style="width: 22.284%; height: 29.7969px;">**Key**</td><td class="align-center" style="width: 77.8396%; height: 29.7969px;">**Value**</td></tr><tr style="height: 29.7969px;"><td style="width: 22.284%; height: 29.7969px;">Content-Type</td><td style="width: 77.8396%; height: 29.7969px;">application/x-www-form-urlencoded</td></tr><tr><td style="width: 22.284%;">Authorization</td><td style="width: 77.8396%;">Basic {{Token}}</td></tr></tbody></table>


#### Request Body

<table border="1" id="bkmrk-parametro-tipo-descr" style="border-collapse: collapse; width: 100%; height: 148.562px;"><tbody><tr style="height: 29.7875px;"><td class="align-center" style="width: 21.997%; height: 29.7875px;">**Parameter**</td><td class="align-center" style="width: 17.4327%; height: 29.7875px;">**Type**  
</td><td class="align-center" style="width: 22.3597%; height: 29.7875px;">**Required**</td><td class="align-center" style="width: 38.3094%; height: 29.7875px;">**Description**</td></tr><tr style="height: 29.7875px;"><td style="width: 21.997%; height: 29.7875px;">Phone</td><td class="align-center" style="width: 17.4327%; height: 29.7875px;">Text</td><td class="align-center" style="width: 22.3597%; height: 29.7875px;">Yes</td><td style="width: 38.3094%; height: 29.7875px;">JSON Object</td></tr></tbody></table>

#### JSON Example

<p class="callout info">The data not enclosed in {{ }} will not be modified; they will be sent as fixed data.</p>

```JSON
{
    "LogLevel": "SEVERE",
    "fullname": "{{fullname}}",
    "accountcode": "{{userNameAgent}}",
    "allow": "alaw;ulaw",
    "callerid": "{{phoneNumber}}",
    "id": 407,
    "context": "agentes",
    "defaultuser": "{{phoneNumber}}",
    "did": "",
    "disallow": "all",
    "dtmfmode": "rfc2833",
    "email": "",
    "encryption": "yes",
    "canreinvite": "",
    "insecure": "",
    "host": "dynamic",
    "language": "es",
    "mailbox": "",
    "name": "{{phoneNumber}}",
    "nat": "yes",
    "phonetype": "SoftPhone",
    "pickupgroup": "",
    "callgroup": "",
    "qualify": "yes",
    "record": "agent",
    "secret": "{{passwordAgent}}",
    "subscribecontext": "default",
    "transport": "wss",
    "port": "",
    "outboundproxy": "",
    "type": "friend",
    "limite": "0"
}
```

#### JSON Object description

<table border="1" id="bkmrk-parameter-type-requi" style="border-collapse: collapse; width: 100%; height: 148.562px;"><tbody><tr style="height: 29.7875px;"><td class="align-center" style="width: 33.3663%; height: 29.7875px;">**Parameter**</td><td class="align-center" style="width: 14.2116%; height: 29.7875px;">**Type**  
</td><td class="align-center" style="width: 14.2116%; height: 29.7875px;">**Required**</td><td class="align-center" style="width: 38.3094%; height: 29.7875px;">**Description**</td></tr><tr style="height: 29.7875px;"><td style="width: 33.3663%; height: 29.7875px;">userName</td><td style="width: 14.2116%; height: 29.7875px;">Text</td><td class="align-center" style="width: 14.2116%; height: 29.7875px;">Yes</td><td style="width: 38.3094%; height: 29.7875px;">Agent's username</td></tr><tr style="height: 29.7875px;"><td style="width: 33.3663%; height: 29.7875px;">password</td><td style="width: 14.2116%; height: 29.7875px;">Text</td><td style="width: 14.2116%; height: 29.7875px;">Yes</td><td style="width: 38.3094%; height: 29.7875px;">User's password</td></tr><tr style="height: 29.6px;"><td style="width: 33.3663%; height: 29.6px;">fullname</td><td style="width: 14.2116%; height: 29.6px;">Text</td><td style="width: 14.2116%; height: 29.6px;">Yes</td><td style="width: 38.3094%; height: 29.6px;">Agent´s full name</td></tr><tr style="height: 29.6px;"><td style="width: 33.3663%; height: 29.6px;"><div><div>phoneNumber</div></div></td><td style="width: 14.2116%; height: 29.6px;">Text</td><td style="width: 14.2116%; height: 29.6px;">Yes</td><td style="width: 38.3094%; height: 29.6px;">Agent's phone number (Unique Data)</td></tr></tbody></table>

---

### Code Examples

<p class="callout info">You can copy the following code examples and replace the "{{variable}}" with the correct data.</p>

#### HTTP

```HTTP
POST /Integra/resources/sip/addsip HTTP/1.1
Host: {{dominio}}.ucontactcloud.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {{Token}}
Content-Length: 1228

phone={ "LogLevel": "SEVERE", "fullname": "{{fullname}}", "accountcode": "{{userName}}", "allow": "alaw;ulaw", "callerid": "{{phoneNumber}}", "id": 407, "context": "agentes", "defaultuser": "{{phoneNumber}}", "did": "", "disallow": "all", "dtmfmode": "rfc2833", "email": "", "encryption": "yes", "canreinvite": "", "insecure": "", "host": "dynamic", "language": "es", "mailbox": "", "name": "{{phoneNumber}}", "nat": "yes", "phonetype": "SoftPhone", "pickupgroup": "", "callgroup": "", "qualify": "yes", "record": "agent", "secret": "{{password}}", "subscribecontext": "default", "transport": "wss", "port": "", "outboundproxy": "", "type": "friend", "limite": "0" }
```

##### cURL

```cURL
curl --location --globoff 'https://{{dominio}}.ucontactcloud.com/Integra/resources/sip/addsip' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic {{Token}}' \
--data-urlencode 'phone={ "LogLevel": "SEVERE", "fullname": "{{fullname}}", "accountcode": "{{userName}}", "allow": "alaw;ulaw", "callerid": "{{phoneNumber}}", "id": 407, "context": "agentes", "defaultuser": "{{phoneNumber}}", "did": "", "disallow": "all", "dtmfmode": "rfc2833", "email": "", "encryption": "yes", "canreinvite": "", "insecure": "", "host": "dynamic", "language": "es", "mailbox": "", "name": "{{phoneNumber}}", "nat": "yes", "phonetype": "SoftPhone", "pickupgroup": "", "callgroup": "", "qualify": "yes", "record": "agent", "secret": "{{password}}", "subscribecontext": "default", "transport": "wss", "port": "", "outboundproxy": "", "type": "friend", "limite": "0" }'
```

##### JavaScript

```JavaScript
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
myHeaders.append("Authorization", "Basic VmNpc25lcm9zOjdjMjUyODAyLTljNGEtNDcyZi05MjJiLTQwNGFmY2JjM2Q2MA==");

const urlencoded = new URLSearchParams();
urlencoded.append("phone", "{ \"LogLevel\": \"SEVERE\", \"fullname\": \"{{fullname}}\", \"accountcode\": \"{{userName}}\", \"allow\": \"alaw;ulaw\", \"callerid\": \"{{phoneNumber}}\", \"id\": 407, \"context\": \"agentes\", \"defaultuser\": \"{{phoneNumber}}\", \"did\": \"\", \"disallow\": \"all\", \"dtmfmode\": \"rfc2833\", \"email\": \"\", \"encryption\": \"yes\", \"canreinvite\": \"\", \"insecure\": \"\", \"host\": \"dynamic\", \"language\": \"es\", \"mailbox\": \"\", \"name\": \"{{phoneNumber}}\", \"nat\": \"yes\", \"phonetype\": \"SoftPhone\", \"pickupgroup\": \"\", \"callgroup\": \"\", \"qualify\": \"yes\", \"record\": \"agent\", \"secret\": \"{{password}}\", \"subscribecontext\": \"default\", \"transport\": \"wss\", \"port\": \"\", \"outboundproxy\": \"\", \"type\": \"friend\", \"limite\": \"0\" }");

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

fetch("https://{{dominio}}.ucontactcloud.com/Integra/resources/sip/addsip", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
```

##### JQuery

```JavaScript
var settings = {
  "url": "https://{{dominio}}.ucontactcloud.com/Integra/resources/sip/addsip",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Basic {{Token}}"
  },
  "data": {
    "phone": "{ \"LogLevel\": \"SEVERE\", \"fullname\": \"{{fullname}}\", \"accountcode\": \"{{userName}}\", \"allow\": \"alaw;ulaw\", \"callerid\": \"{{phoneNumber}}\", \"id\": 407, \"context\": \"agentes\", \"defaultuser\": \"{{phoneNumber}}\", \"did\": \"\", \"disallow\": \"all\", \"dtmfmode\": \"rfc2833\", \"email\": \"\", \"encryption\": \"yes\", \"canreinvite\": \"\", \"insecure\": \"\", \"host\": \"dynamic\", \"language\": \"es\", \"mailbox\": \"\", \"name\": \"{{phoneNumber}}\", \"nat\": \"yes\", \"phonetype\": \"SoftPhone\", \"pickupgroup\": \"\", \"callgroup\": \"\", \"qualify\": \"yes\", \"record\": \"agent\", \"secret\": \"{{password}}\", \"subscribecontext\": \"default\", \"transport\": \"wss\", \"port\": \"\", \"outboundproxy\": \"\", \"type\": \"friend\", \"limite\": \"0\" }"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

##### C#

```C#
var options = new RestClientOptions("https://{{dominio}}.ucontactcloud.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/Integra/resources/sip/addsip", Method.Post);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Authorization", "Basic {{Token}}");
request.AddParameter("phone", "{ \"LogLevel\": \"SEVERE\", \"fullname\": \"{{fullname}}\", \"accountcode\": \"{{userName}}\", \"allow\": \"alaw;ulaw\", \"callerid\": \"{{phoneNumber}}\", \"id\": 407, \"context\": \"agentes\", \"defaultuser\": \"{{phoneNumber}}\", \"did\": \"\", \"disallow\": \"all\", \"dtmfmode\": \"rfc2833\", \"email\": \"\", \"encryption\": \"yes\", \"canreinvite\": \"\", \"insecure\": \"\", \"host\": \"dynamic\", \"language\": \"es\", \"mailbox\": \"\", \"name\": \"{{phoneNumber}}\", \"nat\": \"yes\", \"phonetype\": \"SoftPhone\", \"pickupgroup\": \"\", \"callgroup\": \"\", \"qualify\": \"yes\", \"record\": \"agent\", \"secret\": \"{{password}}\", \"subscribecontext\": \"default\", \"transport\": \"wss\", \"port\": \"\", \"outboundproxy\": \"\", \"type\": \"friend\", \"limite\": \"0\" }");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

##### Java

```Java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "phone={ \"LogLevel\": \"SEVERE\", \"fullname\": \"{{fullname}}\", \"accountcode\": \"{{userName}}\", \"allow\": \"alaw;ulaw\", \"callerid\": \"{{phoneNumber}}\", \"id\": 407, \"context\": \"agentes\", \"defaultuser\": \"{{phoneNumber}}\", \"did\": \"\", \"disallow\": \"all\", \"dtmfmode\": \"rfc2833\", \"email\": \"\", \"encryption\": \"yes\", \"canreinvite\": \"\", \"insecure\": \"\", \"host\": \"dynamic\", \"language\": \"es\", \"mailbox\": \"\", \"name\": \"{{phoneNumber}}\", \"nat\": \"yes\", \"phonetype\": \"SoftPhone\", \"pickupgroup\": \"\", \"callgroup\": \"\", \"qualify\": \"yes\", \"record\": \"agent\", \"secret\": \"{{password}}\", \"subscribecontext\": \"default\", \"transport\": \"wss\", \"port\": \"\", \"outboundproxy\": \"\", \"type\": \"friend\", \"limite\": \"0\" }");
Request request = new Request.Builder()
  .url("https://{{dominio}}.ucontactcloud.com/Integra/resources/sip/addsip")
  .method("POST", body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .addHeader("Authorization", "Basic {{Token}}")
  .build();
Response response = client.newCall(request).execute();
```

##### Python

```Python
import http.client

conn = http.client.HTTPSConnection("{{dominio}}.ucontactcloud.com")
payload = 'phone={ "LogLevel": "SEVERE", "fullname": "{{fullname}}", "accountcode": "{{userName}}", "allow": "alaw;ulaw", "callerid": "{{phoneNumber}}", "id": 407, "context": "agentes", "defaultuser": "{{phoneNumber}}", "did": "", "disallow": "all", "dtmfmode": "rfc2833", "email": "", "encryption": "yes", "canreinvite": "", "insecure": "", "host": "dynamic", "language": "es", "mailbox": "", "name": "{{phoneNumber}}", "nat": "yes", "phonetype": "SoftPhone", "pickupgroup": "", "callgroup": "", "qualify": "yes", "record": "agent", "secret": "{{password}}", "subscribecontext": "default", "transport": "wss", "port": "", "outboundproxy": "", "type": "friend", "limite": "0" }'
headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
  'Authorization': 'Basic {{Token}}'
}
conn.request("POST", "/Integra/resources/sip/addsip", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

---

### HTTP Response

<p class="callout warning">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.</p>

<p class="callout warning">The received response is in text format, so it will need to be converted to JSON to view the data correctly.</p>

#### Successful Response

```JSON
1
```

#### Error Response

```JavaScript
0
```