POST/ form/
Create a pop-up
You can create customized pop-ups.
Attributes
Optional unless marked required
- name
- Name of the pop-up. Can't be empty.
- content
- Content of the pop-up, HTML allowed.
- description
- Description of the pop-up.
- author
- ID of the agent group shown as the author. Set automatically when not sent.
- category
- ID of a pop-up category.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/form/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"name": "Spring sale banner",
"content": "<p>Spring sale: 20% off everything this week.</p>",
"description": "Shown on the home page."
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/form/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Spring sale banner",
content: "<p>Spring sale: 20% off everything this week.</p>",
description: "Shown on the home page.",
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/form/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "Spring sale banner",
"content" => "<p>Spring sale: 20% off everything this week.</p>",
"description" => "Shown on the home page.",
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/form/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"name": "Spring sale banner",
"content": "<p>Spring sale: 20% off everything this week.</p>",
"description": "Shown on the home page.",
},
)
print(response.json())
Response examples
- 201 Created
- 400 Bad Request
{
"key": "8c22a7ee-cec3-47e7-b4c8-35fba1037571",
"name": "Spring sale banner",
"description": "Shown on the home page.",
"content": "<p>Spring sale: 20% off everything this week.</p>",
"author": 1,
"category": null,
"folder": null
}
{"content": ["This field is required."]}A 400 names the fields: This field is required. for a missing name or content (a body with neither also lists author, though it's optional), This field may not be blank. for an empty name, and Invalid pk "123" - object does not exist. for a category that doesn't exist. An author no agent group has answers 400 with a bare list: ["Agent group id is not valid"].
Pop-ups can't be deleted or changed through the API; do that in the panel. The key in the response is the pop-up's 36-character key, used by Get single pop-up.
Response fields
Fields returned in the 201 Created response body.
- key
- Unique key of the pop-up.
- name
- A pop-up name.
- description
- A description of your pop-up.
- content
- A content of your pop-up (HTML can be used inside).
- author
- ID of the agent group shown as the author.
- category
- A unique identifier for a pop-up category automatically generated by User
- folder
- ID of the folder the pop-up is in, or
null.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.