curl --request POST \
--url https://api.exowpee.com/v1/catalog/purchases/{purchase}/items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"quantity": 2,
"unit_cost": 123,
"vat_rate": 50
}
]
}
'import requests
url = "https://api.exowpee.com/v1/catalog/purchases/{purchase}/items"
payload = { "items": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"quantity": 2,
"unit_cost": 123,
"vat_rate": 50
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
stockable_id: '<string>',
stockable_unit_id: '<string>',
quantity: 2,
unit_cost: 123,
vat_rate: 50
}
]
})
};
fetch('https://api.exowpee.com/v1/catalog/purchases/{purchase}/items', 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/{purchase}/items",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'stockable_id' => '<string>',
'stockable_unit_id' => '<string>',
'quantity' => 2,
'unit_cost' => 123,
'vat_rate' => 50
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.exowpee.com/v1/catalog/purchases/{purchase}/items"
payload := strings.NewReader("{\n \"items\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"quantity\": 2,\n \"unit_cost\": 123,\n \"vat_rate\": 50\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/{purchase}/items")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"quantity\": 2,\n \"unit_cost\": 123,\n \"vat_rate\": 50\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/catalog/purchases/{purchase}/items")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"quantity\": 2,\n \"unit_cost\": 123,\n \"vat_rate\": 50\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": "<string>",
"purchase_id": "<string>",
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"stockable": {},
"stockable_unit": {},
"quantity": 123,
"remaining": 123,
"unit_cost": 123,
"vat_rate": "<string>",
"vat_total": 123,
"unit_cost_ttc": 123,
"cost_total": 123,
"cost_total_ttc": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
]{
"message": "<string>",
"errors": {}
}Add purchase lines
Adds product lines to a purchase that can still be edited.
curl --request POST \
--url https://api.exowpee.com/v1/catalog/purchases/{purchase}/items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"quantity": 2,
"unit_cost": 123,
"vat_rate": 50
}
]
}
'import requests
url = "https://api.exowpee.com/v1/catalog/purchases/{purchase}/items"
payload = { "items": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"quantity": 2,
"unit_cost": 123,
"vat_rate": 50
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
stockable_id: '<string>',
stockable_unit_id: '<string>',
quantity: 2,
unit_cost: 123,
vat_rate: 50
}
]
})
};
fetch('https://api.exowpee.com/v1/catalog/purchases/{purchase}/items', 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/{purchase}/items",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'stockable_id' => '<string>',
'stockable_unit_id' => '<string>',
'quantity' => 2,
'unit_cost' => 123,
'vat_rate' => 50
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.exowpee.com/v1/catalog/purchases/{purchase}/items"
payload := strings.NewReader("{\n \"items\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"quantity\": 2,\n \"unit_cost\": 123,\n \"vat_rate\": 50\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/{purchase}/items")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"quantity\": 2,\n \"unit_cost\": 123,\n \"vat_rate\": 50\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/catalog/purchases/{purchase}/items")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"quantity\": 2,\n \"unit_cost\": 123,\n \"vat_rate\": 50\n }\n ]\n}"
response = http.request(request)
puts response.read_body[
{
"id": "<string>",
"purchase_id": "<string>",
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"stockable": {},
"stockable_unit": {},
"quantity": 123,
"remaining": 123,
"unit_cost": 123,
"vat_rate": "<string>",
"vat_total": 123,
"unit_cost_ttc": 123,
"cost_total": 123,
"cost_total_ttc": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
]{
"message": "<string>",
"errors": {}
}purchases.update, purchase_items.create
Conditions
- The purchase must be in draft or rejected status.
- The items array is required and must hold at least one line; each line needs stockable_id, stockable_unit_id (27 characters each) and an integer quantity of at least 1.
- Each stockable_unit_id must be distinct within the request and must not already be a line of the purchase.
- Each unit must exist in the organization, belong to the given item, be active, belong to a product variant and not be archived.
- When the purchase prices its lines per unit (cost strategy unit), every line must carry unit_cost; vat_rate is optional and defaults to 0.
- When the purchase has a single total cost (cost strategy total), unit_cost and vat_rate are refused on every line.
- When the resulting purchase has VAT greater than zero, vat_is_recoverable must have been set; otherwise the call is refused with a validation error.
- Inserts the lines with remaining equal to quantity, then recalculates the purchase totals and the per-unit cost of every line.
- Under the unit strategy cost_total, vat_total and invoice_total are recomputed from the lines; under the total strategy the invoice total is spread over all units and the integer remainder is kept in cost_leftover.
- No stock movement or accounting entry is created.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Identifier of the purchase to add lines to.
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, purchase_id, stockable_id, stockable_unit_id, quantity, remaining, unit_cost, vat_rate, vat_total, unit_cost_ttc, cost_total, cost_total_ttc, 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: stockable, stockable.vat_rate, stockable.taxes, stockable.units, stockableUnit, stockableUnit.uomUnit, stockableUnit.prices, stockableUnit.stockable.
Body
Lines to add; at least one.
1Show child attributes
Show child attributes
Response
Resource (only with response=resource).
Identifier of the purchase line (27-character KSUID).
Identifier of the purchase the line belongs to.
Identifier of the item (product variant) bought.
Identifier of the item unit (unit of measure) bought; unique within a purchase.
The item bought. Present only when requested with include=stockable.
The unit of the line. Present only when requested with include=stockableUnit.
Quantity bought, in the line's unit.
Quantity not yet received. Starts equal to quantity and is reset to quantity when the line is edited.
Cost of one unit before VAT. 0 under the total cost strategy, where costs are not entered per line. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
VAT rate in percent with four decimals (for example "18.0000"); null under the total cost strategy.
VAT of the line (unit cost times quantity times rate, rounded half up). Null under the total cost strategy. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Cost of one unit including VAT; under the total strategy the invoice total divided by the total quantity (integer division). In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Cost of the line before VAT (unit cost times quantity). Null under the total cost strategy. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Cost of the line including VAT. In major units (the stored minor-unit amount divided by 10 to the power currency_exponent).
Date and time the record was created (ISO 8601, UTC).
Date and time the record was last changed (ISO 8601, UTC).