Contents
On this page

Create Customer - Plugixa POS for WooCommerce

POST /plugixa-pos/v1/customers

Create a WooCommerce customer account at the counter, so it can be attached to the sale.

Needs a user with the plugixa_pos_sell capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; other roles only when you grant it.

Request

POST https://your-site.example/wp-json/plugixa-pos/v1/customers

Request body

Content type: application/json

Field Type Required Description
email string Yes A valid email no other user has.
first_name string No First name.
last_name string No Last name.
phone string No Billing phone.
{
  "email": "jeanne.roux@example.com",
  "first_name": "Jeanne",
  "last_name": "Roux",
  "phone": "06 12 34 56 78"
}

Responses

201 Created. data is the customer, fields as in Search Customers.

{
  "success": true,
  "data": {
    "id": 103,
    "name": "Jeanne Roux",
    "email": "jeanne.roux@example.com",
    "phone": "06 12 34 56 78",
    "first_name": "Jeanne",
    "last_name": "Roux",
    "roles": ["customer"]
  }
}

Errors

Status Code When
422 plugixa_pos_invalid_email The email is missing or not valid. data.field is email.
409 plugixa_pos_customer_exists A user with this email already exists.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-pos/v1/customers" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"email":"jeanne.roux@example.com","first_name":"Jeanne","last_name":"Roux","phone":"06 12 34 56 78"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/customers');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'email'      => 'jeanne.roux@example.com',
        'first_name' => 'Jeanne',
        'last_name'  => 'Roux',
        'phone'      => '06 12 34 56 78',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/customers', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ email: 'jeanne.roux@example.com', first_name: 'Jeanne', last_name: 'Roux', phone: '06 12 34 56 78' }),
});
const { data } = await response.json();

Quick Links

Share