Contents
On this page

Create Pricing Rule - Plugixa Chauffeur

POST /plugixa-chauffeur/v1/pricing-rules

Create a rule that raises, lowers or sets the fare of matching trips.

Needs Plugixa Chauffeur Pro with an active licence. Needs a signed-in user with the plugixa_chauffeur_manage capability (administrators have it after activation).

Note. A rule is active as soon as it is created, so it changes the next quote. Send "status": "inactive" to prepare it first.

Request

POST https://your-site.example/wp-json/plugixa-chauffeur/v1/pricing-rules

Request body

Content type: application/json

Field Type Required Description
name string Yes Must not be blank.
status string No inactive; anything else is saved as active. Default active.
priority integer No Lower runs first. Default 0.
adjustment_type string No set_value, increase_value, decrease_value, increase_percent or decrease_percent. Anything else is saved as increase_percent. Default increase_percent.
adjustment_value number No An amount in the booking currency, or a percentage. Default 0.
apply_to string No Stored as sent; has no effect. Default total.
stop_processing boolean No Default false.
display_order integer No Default 0.
conditions object No Any of: service_types (distance, hourly, flat), vehicle_ids (integers), days_of_week (0 Sunday to 6 Saturday), date_from and date_to (YYYY-MM-DD, both included), min_distance and max_distance (above 0), min_passengers and max_passengers (above 0). Other keys and empty values are dropped.

Every condition you set must match for the rule to apply. Rules run on every quote and wizard booking, in order of priority, then display_order, then id, and each one changes the running total. A total below 0 becomes 0. See Pricing rules.

{
  "name": "Weekend surcharge",
  "priority": 10,
  "adjustment_type": "increase_percent",
  "adjustment_value": 15,
  "conditions": {
    "service_types": [
      "distance",
      "hourly"
    ],
    "days_of_week": [
      0,
      6
    ]
  }
}

Responses

200 Created. data is the new rule.

{
  "success": true,
  "message": "",
  "data": {
    "id": "4",
    "name": "Weekend surcharge",
    "status": "active",
    "priority": 10,
    "conditions": {
      "service_types": [
        "distance",
        "hourly"
      ],
      "days_of_week": [
        0,
        6
      ]
    },
    "adjustment_type": "increase_percent",
    "adjustment_value": 15.0,
    "apply_to": "total",
    "stop_processing": false,
    "display_order": 0,
    "created_at": "2026-11-12 09:30:00"
  }
}
Field Type Meaning
data.id string The rule id, as a string
data.status string active or inactive. Only active rules run
data.priority integer Lower runs first
data.conditions object|array What a trip must match. An empty [] when the rule has no conditions
data.adjustment_type string set_value, increase_value, decrease_value, increase_percent or decrease_percent
data.adjustment_value number The amount or the percentage
data.apply_to string Stored, but the rule engine does not read it: rules always change the total
data.stop_processing boolean When the rule matches, no later rule runs
data.display_order integer Tie-breaker after priority

Errors

Status Code When
400 rest_error name is missing or blank (“Name is required.”).
500 rest_error The database refused the row.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-chauffeur/v1/pricing-rules" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Weekend surcharge","priority":10,"adjustment_type":"increase_percent","adjustment_value":15,"conditions":{"service_types":["distance","hourly"],"days_of_week":[0,6]}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chauffeur/v1/pricing-rules');
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'             => 'Weekend surcharge',
        'priority'         => 10,
        'adjustment_type'  => 'increase_percent',
        'adjustment_value' => 15,
        'conditions'       => [
            'service_types' => ['distance', 'hourly'],
            'days_of_week'  => [0, 6],
        ],
    ]),
]);
$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-chauffeur/v1/pricing-rules', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Weekend surcharge',
    priority: 10,
    adjustment_type: 'increase_percent',
    adjustment_value: 15,
    conditions: { service_types: ['distance', 'hourly'], days_of_week: [0, 6] },
  }),
});
const { data } = await response.json();

Quick Links

Share