Contents
On this page
Add Icon - Plugixa Image Map
POST /plugixa-image-map/v1/icons
Clean an SVG icon and add it to the Media Library, for use as a custom hotspot icon.
Any signed-in user with plugixa_image_map_edit and WordPress’s upload_files. See Roles and permissions. Needs Plugixa Image Map Pro: on the free build this route does not exist and answers 404.
Note. Only this route lets an SVG into the Media Library, and only after cleaning: anything outside a short list of drawing elements and attributes (scripts, links, embedded images, styles, event handlers) is removed. The cleaned file is what is stored, so it can differ from what you sent.
Request
POST https://your-site.example/wp-json/plugixa-image-map/v1/icons
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
svg |
string |
Yes | The SVG markup, 100 KB at most. |
name |
string |
No | A file name. Its extension is replaced with .svg; empty gives icon.svg. |
{
"svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M12 2l3 7h7l-5.5 4 2 7L12 16l-6.5 4 2-7L2 9h7z\"/></svg>",
"name": "star-badge.svg"
}
Responses
201 Created. data is the new attachment.
{
"success": true,
"data": {
"id": 311,
"url": "https://your-site.example/wp-content/uploads/2026/11/star-badge.svg"
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The attachment id |
data.url |
string |
The file’s URL |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_image_map_bad_svg |
svg is empty, over 100 KB, not well-formed XML, has no svg root, contains a DOCTYPE or entity, or has neither a viewBox nor a width and height. |
401 / 403 |
rest_forbidden |
The user may edit maps but not upload files. |
500 |
plugixa_image_map_upload_failed |
The file could not be written to the uploads folder. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-image-map/v1/icons" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M12 2l3 7h7l-5.5 4 2 7L12 16l-6.5 4 2-7L2 9h7z\"/></svg>","name":"star-badge.svg"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-image-map/v1/icons');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'svg' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l3 7h7l-5.5 4 2 7L12 16l-6.5 4 2-7L2 9h7z"/></svg>',
'name' => 'star-badge.svg',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-image-map/v1/icons', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l3 7h7l-5.5 4 2 7L12 16l-6.5 4 2-7L2 9h7z"/></svg>',
name: 'star-badge.svg',
}),
});
const { data } = await response.json();
Quick Links
Share