curl --request POST \
--url https://api.exowpee.com/v1/catalog/purchases \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.exowpee.com/v1/catalog/purchases"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.exowpee.com/v1/catalog/purchases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.exowpee.com/v1/catalog/purchases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.exowpee.com/v1/catalog/purchases"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.exowpee.com/v1/catalog/purchases")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/catalog/purchases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"company_id": "<string>",
"vendor_id": "<string>",
"reference": "<string>",
"purchase_date": "2023-12-25",
"notes": "<string>",
"status": "<string>",
"is_credit": true,
"cost_total": 123,
"cost_total_includes_vat": true,
"vat_total": 123,
"vat_is_recoverable": true,
"invoice_total": 123,
"cost_leftover": 123,
"invoiced_at": "2023-11-07T05:31:56Z",
"amount_paid": 123,
"amount_debt_adjusted": 123,
"remaining_amount": 123,
"due_date": "2023-12-25",
"payment_status": "<string>",
"need_approval": true,
"cost_strategy": "<string>",
"items": "<array>",
"debt_adjustments": "<array>",
"returns": "<array>",
"pickups": "<array>",
"deliveries": "<array>",
"vendor": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"message": "<string>",
"errors": {}
}Create a purchase
Starts a new purchase to a supplier as a draft, with its lines and costs. It can be on credit if the supplier allows it.
curl --request POST \
--url https://api.exowpee.com/v1/catalog/purchases \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.exowpee.com/v1/catalog/purchases"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.exowpee.com/v1/catalog/purchases', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.exowpee.com/v1/catalog/purchases",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.exowpee.com/v1/catalog/purchases"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.exowpee.com/v1/catalog/purchases")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/catalog/purchases")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"company_id": "<string>",
"vendor_id": "<string>",
"reference": "<string>",
"purchase_date": "2023-12-25",
"notes": "<string>",
"status": "<string>",
"is_credit": true,
"cost_total": 123,
"cost_total_includes_vat": true,
"vat_total": 123,
"vat_is_recoverable": true,
"invoice_total": 123,
"cost_leftover": 123,
"invoiced_at": "2023-11-07T05:31:56Z",
"amount_paid": 123,
"amount_debt_adjusted": 123,
"remaining_amount": 123,
"due_date": "2023-12-25",
"payment_status": "<string>",
"need_approval": true,
"cost_strategy": "<string>",
"items": "<array>",
"debt_adjustments": "<array>",
"returns": "<array>",
"pickups": "<array>",
"deliveries": "<array>",
"vendor": {},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"message": "<string>",
"errors": {}
}purchases.create, purchase_items.create
Conditions
- reference, when sent, must be unique among the company’s purchases.
- The cost mode is chosen by the lines: if any line sends unit_cost, every line must send it, and cost_total, cost_total_includes_vat and vat_total are refused.
- If no line sends unit_cost, cost_total (greater than 0), cost_total_includes_vat and vat_total are required, and vat_rate is refused on lines.
- When cost_total_includes_vat is true, vat_total cannot exceed cost_total.
- vat_is_recoverable is required when the resulting VAT is greater than zero.
- recoverable_vat_total and tax_total are prohibited.
- Each line unit must be distinct, exist in the organization, belong to the item, be active, belong to a product variant and not be archived.
- When is_credit is true, the supplier must be creditable.
- When is_credit is true, a supplier with overdue debts blocks the purchase unless the caller holds the vendors.bypass_due_date_checks permission.
- Amounts must have at most currency_exponent decimals.
- Creates the purchase in draft status with payment_status unpaid, amount_paid, amount_debt_adjusted and remaining_amount at 0, need_approval false and invoiced_at empty; the invoice total is computed but not yet recognised.
- Creates all lines with remaining equal to quantity and computes unit_cost_ttc per line and the cost_leftover.
- For a credit purchase without due_date, due_date is set to purchase_date (or today) plus the supplier’s standard_payment_terms, when those are above 0.
- No stock movement, accounting entry or debt is created at this stage.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Response mode. Default none; none answers 204 No Content.
none, resource Comma-separated JSON keys of the root resource (id is always rendered). Available: id, company_id, vendor_id, reference, purchase_date, notes, status, is_credit, cost_total, cost_total_includes_vat, vat_total, vat_is_recoverable, invoice_total, cost_leftover, invoiced_at, amount_paid, amount_debt_adjusted, remaining_amount, due_date, payment_status, need_approval, cost_strategy, created_at, updated_at.
Comma-separated include paths, each optionally followed by its fields in parentheses: units(id,sku),units.uomUnit(id,name). Max depth 6, max 40 paths. Available: items, items.stockable, items.stockableUnit, debtAdjustments, debtAdjustments.purchase, returns, returns.items, pickups, pickups.items, pickups.costs, deliveries, deliveries.items, deliveries.costs, vendor.
Response
Resource (only with response=resource).
Identifier of the purchase (27-character KSUID).
Identifier of the company the record belongs to.
Identifier of the supplier the goods are bought from.
Free reference of the purchase (for example the supplier's order number); unique among the company's purchases when set.
Date of the purchase (ISO 8601 date), null when not given.
Free notes, up to 1000 characters.
Workflow status: draft (editable), awaiting_approval (waiting for a manager when a credit limit was exceeded), rejected (editable again), pending (confirmed, goods can be received), completed, closed.
True when the purchase is bought on credit from the supplier, so the unpaid amount counts as a debt.
Cost of the purchase as entered. Under the unit cost strategy it is the sum of the line costs before VAT; under the total strategy it is the amount entered by the caller, which includes VAT when cost_total_includes_vat is true. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Whether cost_total already includes VAT. Only meaningful under the total cost strategy; null under the unit strategy.
VAT of the purchase. Computed from the lines under the unit strategy; entered by the caller under the total strategy. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Whether the VAT of this purchase can be recovered. Required when VAT is above zero; null when never set.
Amount invoiced by the supplier, VAT included: the sum of the line totals (unit strategy) or cost_total plus VAT when VAT is not included (total strategy). Recomputed while the purchase is editable; null while not yet computed. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Remainder in the division of the invoice total by the total quantity under the total cost strategy, which cannot be spread evenly over the units. 0 under the unit strategy. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
When the supplier invoice was recognised (ISO 8601), set the first time the purchase becomes pending; null before that.
Cash paid so far against the purchase. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Total of debt adjustments applied to the purchase. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Amount still to be paid to the supplier. 0 before the invoice is recognised and while awaiting approval. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Date by which a credit purchase must be paid (ISO 8601 date); when omitted on a credit purchase, filled from the purchase date (or the creation day) plus the supplier's standard payment terms, if those are above 0.
Payment state: unpaid, partial or paid.
True while the purchase waits for a manager's approval because a supplier debt limit was exceeded.
How costs are entered: unit (a unit_cost per line) or total (one cost_total for the whole purchase).
Lines of the purchase. Present only when requested with include=items.
Debt adjustments of the purchase. Present only when requested with include.
Returns made against the purchase. Present only when requested with include.
Pickup receptions of the purchase. Present only when requested with include.
Delivery receptions of the purchase. Present only when requested with include.
The supplier of the purchase. Present only when requested with include=vendor.
Date and time the record was created (ISO 8601, UTC).
Date and time the record was last changed (ISO 8601, UTC).