Contents
On this page

Create Location - Plugixa Car Rental

POST /plugixa-car-rental/v1/locations

Create a location.

The user needs the plugixa_car_rental_create capability.

Request

POST https://your-site.example/wp-json/plugixa-car-rental/v1/locations

Request body

Content type: application/json

Field Type Required Description
name string Yes Must not be blank.
code string No Upper-cased. Letters, digits, dashes and underscores only. Must not be another live location’s code.
address string No Plain text, line breaks kept.
city string No City.
country string No Country.
latitude number No -90 to 90, rounded to 7 decimals. Empty or null for none.
longitude number No -180 to 180, rounded to 7 decimals. Empty or null for none.
phone string No Phone number.
email string No Must be a valid address when given.
timezone string No A time zone name such as Europe/Paris. Empty means the site’s time zone. Pickup and return times at this location are read on this clock.
opening_hours object No Keys mon to sun, each a list of {"open": "HH:MM", "close": "HH:MM"}. Each opening is before its closing (24:00 is allowed as a closing time) and the times of one day do not overlap. A day left out, or an empty list, is closed. Omitted or null: Monday to Saturday 08:00 to 18:00, closed on Sunday.
allows_pickup boolean No Defaults to true.
allows_return boolean No Defaults to true. A location must allow pickups, returns or both.
after_hours_fee number No When above 0, a pickup or return outside the opening hours is accepted and this fee is added to the price. At 0 (the default) such a time is refused.
image_id integer No An image in the media library, or 0 for none.
sort_order integer No Position in lists, lowest first. Defaults to 0. May be negative.
status string No published (the default) or unpublished.
{
  "name": "Paris Gare de Lyon",
  "code": "PAR-GDL",
  "address": "20 Boulevard Diderot",
  "city": "Paris",
  "country": "France",
  "timezone": "Europe/Paris",
  "opening_hours": {
    "mon": [
      {
        "open": "08:00",
        "close": "19:00"
      }
    ],
    "tue": [
      {
        "open": "08:00",
        "close": "19:00"
      }
    ],
    "wed": [
      {
        "open": "08:00",
        "close": "19:00"
      }
    ],
    "thu": [
      {
        "open": "08:00",
        "close": "19:00"
      }
    ],
    "fri": [
      {
        "open": "08:00",
        "close": "19:00"
      }
    ],
    "sat": [
      {
        "open": "09:00",
        "close": "12:30"
      },
      {
        "open": "14:00",
        "close": "18:00"
      }
    ],
    "sun": []
  },
  "after_hours_fee": 35
}

Responses

201 Created. data is the new location.

{
  "success": true,
  "data": {
    "id": 1,
    "code": "PAR-GDL",
    "name": "Paris Gare de Lyon",
    "address": "20 Boulevard Diderot",
    "city": "Paris",
    "country": "France",
    "latitude": 48.8443,
    "longitude": 2.3743,
    "phone": "+33 1 23 45 67 89",
    "email": "gare-de-lyon@your-site.example",
    "timezone": "Europe/Paris",
    "opening_hours": {
      "mon": [
        {
          "open": "08:00",
          "close": "19:00"
        }
      ],
      "tue": [
        {
          "open": "08:00",
          "close": "19:00"
        }
      ],
      "wed": [
        {
          "open": "08:00",
          "close": "19:00"
        }
      ],
      "thu": [
        {
          "open": "08:00",
          "close": "19:00"
        }
      ],
      "fri": [
        {
          "open": "08:00",
          "close": "19:00"
        }
      ],
      "sat": [
        {
          "open": "09:00",
          "close": "12:30"
        },
        {
          "open": "14:00",
          "close": "18:00"
        }
      ],
      "sun": []
    },
    "allows_pickup": true,
    "allows_return": true,
    "after_hours_fee": 35.0,
    "image_id": null,
    "sort_order": 0,
    "status": "published",
    "created_by": 1,
    "modified_by": 1,
    "created_at": "2026-11-12 09:30:00",
    "modified_at": "2026-11-12 09:30:00",
    "deleted_at": null
  }
}
Field Type Meaning
data.id integer The location’s id
data.code string Your short code, upper case, or empty
data.name string The name customers see
data.city string City
data.status string published or unpublished. Only a published location can be booked
data.allows_pickup boolean Whether cars can be picked up here
data.allows_return boolean Whether cars can be returned here
data.opening_hours object Keys mon to sun, each a list of {open, close} times. An empty list means closed that day
data.timezone string Time zone name, or empty for the site’s own
data.after_hours_fee number Fee for a pickup or return outside the hours. 0 refuses such times
data.latitude number|null Latitude
data.longitude number|null Longitude
data.image_id integer|null Media library image
data.created_at string UTC datetime the record was created
data.modified_at string UTC datetime of the last change. Send it back on an update to be warned of a conflicting edit
data.deleted_at string|null null unless the record is in the trash

Errors

Status Code When
422 plugixa_car_rental_missing_name name is missing or blank.
422 plugixa_car_rental_invalid_code code has a character other than letters, digits, dashes and underscores.
409 plugixa_car_rental_duplicate_code Another live location has this code.
422 plugixa_car_rental_invalid_email email is not a valid address.
422 plugixa_car_rental_out_of_range latitude or longitude is out of range.
422 plugixa_car_rental_invalid_timezone timezone is not a time zone name the server knows.
422 plugixa_car_rental_invalid_hours opening_hours is not in the shape above, a time is not HH:MM, an opening is not before its closing, or two openings overlap.
422 plugixa_car_rental_no_purpose allows_pickup and allows_return were both sent as false.
422 plugixa_car_rental_unknown_reference image_id is not an image.
422 plugixa_car_rental_invalid_choice status is not published or unpublished. data.allowed lists the accepted values.
422 plugixa_car_rental_not_a_number A number field was sent as something else. data.field names it.
422 plugixa_car_rental_negative_number A number field that cannot be negative is. data.field names it.
422 plugixa_car_rental_too_long A text field is longer than its column. data.field names it and data.max gives the limit.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-car-rental/v1/locations" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Paris Gare de Lyon","code":"PAR-GDL","address":"20 Boulevard Diderot","city":"Paris","country":"France","timezone":"Europe/Paris","opening_hours":{"mon":[{"open":"08:00","close":"19:00"}],"tue":[{"open":"08:00","close":"19:00"}],"wed":[{"open":"08:00","close":"19:00"}],"thu":[{"open":"08:00","close":"19:00"}],"fri":[{"open":"08:00","close":"19:00"}],"sat":[{"open":"09:00","close":"12:30"},{"open":"14:00","close":"18:00"}],"sun":[]},"after_hours_fee":35}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-rental/v1/locations');
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([
        'name'            => 'Paris Gare de Lyon',
        'code'            => 'PAR-GDL',
        'address'         => '20 Boulevard Diderot',
        'city'            => 'Paris',
        'country'         => 'France',
        'timezone'        => 'Europe/Paris',
        'opening_hours'   => [
            'mon' => [
                [
                    'open'  => '08:00',
                    'close' => '19:00',
                ],
            ],
            'tue' => [
                [
                    'open'  => '08:00',
                    'close' => '19:00',
                ],
            ],
            'wed' => [
                [
                    'open'  => '08:00',
                    'close' => '19:00',
                ],
            ],
            'thu' => [
                [
                    'open'  => '08:00',
                    'close' => '19:00',
                ],
            ],
            'fri' => [
                [
                    'open'  => '08:00',
                    'close' => '19:00',
                ],
            ],
            'sat' => [
                [
                    'open'  => '09:00',
                    'close' => '12:30',
                ],
                [
                    'open'  => '14:00',
                    'close' => '18:00',
                ],
            ],
            'sun' => [],
        ],
        'after_hours_fee' => 35,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-car-rental/v1/locations', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Paris Gare de Lyon',
    code: 'PAR-GDL',
    address: '20 Boulevard Diderot',
    city: 'Paris',
    country: 'France',
    timezone: 'Europe/Paris',
    opening_hours: {
      mon: [{ open: '08:00', close: '19:00' }],
      tue: [{ open: '08:00', close: '19:00' }],
      wed: [{ open: '08:00', close: '19:00' }],
      thu: [{ open: '08:00', close: '19:00' }],
      fri: [{ open: '08:00', close: '19:00' }],
      sat: [{ open: '09:00', close: '12:30' }, { open: '14:00', close: '18:00' }],
      sun: [],
    },
    after_hours_fee: 35,
  }),
});
const { data } = await response.json();

Quick Links

Share