Customers API
Customers who buy from the company, companies and private persons, and the contact persons of each customer. Orders, invoices and payments of a customer are found by filtering on the customer: customer.id=5. For access, paging, filters and getting only changes, see API basics.
Customers
GET /api/customer/search
Example request
curl -g -G 'https://{company}.smarton.app/api/customer/search' \
-H 'Authorization: <token>' \
--data-urlencode 'paginate=true' \
--data-urlencode 'limit=500' \
--data-urlencode 'offset=0' \
--data-urlencode 'partialJoin[type][]=name' \
--data-urlencode 'partialJoin[country][]=name' \
--data-urlencode 'sort[id]=asc'
Fields
| Field | Meaning |
|---|---|
id, name, alias | ID, name and short name. |
registrationCode, vatCode | Company code and VAT code. |
type, country | Customer type and country. |
addressInline, invoiceAddress | Address in one line and the address for invoices. |
phone, email, emailFinance, website | Contacts of the customer. |
discount | The customer's discount in percent. |
creditAmount, remnantCredit | Credit limit and the part of it still left. |
totalInvoiced, totalPaid, remnant | Amount invoiced, amount paid, and what is still unpaid (totalInvoiced minus totalPaid). |
debtor | Marked as a debtor. |
active, hideInPos | Active customer; hidden in the POS. |
comments, createdAt, updatedAt | Comments and when the record was created and last changed. |
Contact persons
GET /api/customer_employee/search?customer.id=5&partialJoin[customer][]=name
The people of a customer: name, firstName, lastName, phone, mobile, email and customer. With an API key, personal codes, dates of birth and health-related fields are not returned.
Orders, invoices and payments of a customer
GET /api/order/search?customer.id=5&paginate=true&limit=200&sort[createdAt]=asc GET /api/invoice/search?customer.id=5 GET /api/payment/search?customer.id=5
The fields are described in Orders API and Accounting API.
Creating and changing customers
Use the general write calls with the resource customer (or customer_employee for contact persons), for example POST /api/customer/create with name, registrationCode and vatCode. See API basics → Writing data. This needs a login with the permission to create customers.
With an API key
Customers and contact persons belong to the Customers area of an API key. Their orders and invoices need the Sales area, and payments the Accounting area.
English