POST
/form/Create a pop-up
You can create customized pop-ups.
| Attributes | Type | Required | Description |
|---|---|---|---|
| content | string | yes | A content of your pop-up (HTML can be used inside). |
| name | string | yes | A pop-up name. |
| description | string | no | A description of your pop-up. |
| author | integer | no | A unique identifier for an agent which is given by User.com automatically. |
| category | integer | no | A unique identifier for a pop-up category automatically generated by User.com |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST -H "Authorization: Token <your_64_char_api_key>"
-H "Accept: */*; version=2" -H "Content-Type: application/json" -d '{
"name":"Test pop-up",
"content":"<body><p>My new pop-up</p></body>",
"description":"<body><p>My new pop-up</p></body>"
}' "https://<your_app_subdomain>.user.com/api/public/form/"
var data = JSON.stringify({
"name": "Test pop-up",
"content": "<body><p>My new pop-up</p></body>",
"description": "<body><p>My new pop-up</p></body>"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/form/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/form/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\r\n \"name\":\"Test pop-up\",\r\n \"content\":\"<body><p>My new pop-up</p></body>\",\r\n \"description\":\"<body><p>My new pop-up</p></body>\"\r\n}",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import http.client
conn = http.client.HTTPSConnection("<your_app_subdomain>.user.com")
payload = "{\r\n\t\"name\":\"Test pop-up\",\r\n\t\"content\":\"<body><p>My new pop-up</p></body>\",\r\n\t\"description\":\"<body><p>My new pop-up</p></body>\"\r\n}"
headers = {
'authorization': "Token <your_64_char_api_key>",
'Accept': "*/*; version=2",
'content-type': "application/json"
}
conn.request("POST", "/api/public/form/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response
{
"key": "5afbc0dd-ce7a-4f9c-9ec2-37539ac4c001",
"name": "Test pop-up",
"description": "Pop-up created with API",
"content": "<body><p>My new pop-up</p></body>",
"author": 1,
"category": null
}