Contents
On this page

Check Addresses - Plugixa Permalink Manager

POST /plugixa-permalink-manager/v1/uris/check

Check what each address would be saved as and whether it is free, without saving anything.

Needs the plugixa_permalink_manager_edit capability.

Note. The check is about the address only. It does not ask whether the item exists, is excluded, or may be edited by you: Update Address can still refuse a row that passed.

Request

POST https://your-site.example/wp-json/plugixa-permalink-manager/v1/uris/check

Request body

Content type: application/json

Field Type Required Description
items array Yes Up to 100 rows, each { kind, id, uri }. kind is post or term and defaults to post.

Two rows of the same request that want the same address are reported against each other: the first keeps it and the second is refused, the way a save of both would go.

{
  "items": [
    {
      "kind": "post",
      "id": 36,
      "uri": "Shop/Tents/Skyline 2"
    },
    {
      "kind": "post",
      "id": 41,
      "uri": "shop/tents/skyline-2"
    }
  ]
}

Responses

200 OK. data has one result per row, in the order sent.

{
  "success": true,
  "data": [
    {
      "key": "post:36",
      "ok": true,
      "normalized": "shop/tents/skyline-2"
    },
    {
      "key": "post:41",
      "ok": false,
      "normalized": "shop/tents/skyline-2",
      "owner": {
        "kind": "post",
        "id": 36,
        "title": "Skyline 2 Tent",
        "edit_url": "https://your-site.example/wp-admin/post.php?post=36&action=edit"
      },
      "error": {
        "code": "plugixa_permalink_manager_uri_conflict_pending",
        "message": "Another row you are editing wants the same address."
      }
    }
  ]
}
Field Type Meaning
data[].key string kind:id of the row
data[].ok boolean Whether the address could be saved
data[].normalized string The address as it would be stored. Absent when it cannot be cleaned
data[].owner object Who already uses it: kind, id, title (only when you may see it) and edit_url (only when you may edit it)
data[].suggestion string|null A free address, when the address belongs to another item
data[].error.code string plugixa_permalink_manager_uri_conflict (another item has it), plugixa_permalink_manager_uri_conflict_pending (an earlier row of this request wants it), or one of the address errors of Update Address

Errors

Status Code When
400 plugixa_permalink_manager_invalid items is missing, not a list, or longer than 100.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-permalink-manager/v1/uris/check" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"items":[{"kind":"post","id":36,"uri":"Shop/Tents/Skyline 2"},{"kind":"post","id":41,"uri":"shop/tents/skyline-2"}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-permalink-manager/v1/uris/check');
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([
        'items' => [
            [
                'kind' => 'post',
                'id'   => 36,
                'uri'  => 'Shop/Tents/Skyline 2',
            ],
            [
                'kind' => 'post',
                'id'   => 41,
                'uri'  => 'shop/tents/skyline-2',
            ],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`);
const response = await fetch('https://your-site.example/wp-json/plugixa-permalink-manager/v1/uris/check', {
  method: 'POST',
  headers: {
    'Authorization': auth,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    items: [
      { kind: 'post', id: 36, uri: 'Shop/Tents/Skyline 2' },
      { kind: 'post', id: 41, uri: 'shop/tents/skyline-2' },
    ],
  }),
});
const { data } = await response.json();

Quick Links

Share