Create a Return to Vendor
Endpoint Overview
This API endpoint provides a detailed overview of the endpoint responsible for creating a return to vendor (sending stock back out to a supplier) within the Inventory module of the Juleb ERP. A single call can create one or many returns at once.
Endpoint Details
- Method: POST
- URL:
/api/v1/inventory/picking/return
Parameters
- Path Parameters: None
- Query Parameters: None
Request Body
The request body must wrap the return (or returns) to create under a PartnerPicking key -
either a single object, or an array to create several returns in one call. Same shape and
fields as Create a delivery (companyId, partnerId /
partner_code for the vendor, reason, note, origin, autoValidate, autoCreateBatch,
rsd_deserialization, global_import, international_export, lines[]):
{
"PartnerPicking": {
"companyId": integer,
"partnerId": integer,
"partner_code": string,
"reason": string,
"note": string,
"origin": string,
"autoValidate": boolean,
"autoCreateBatch": boolean,
"rsd_deserialization": boolean,
"global_import": boolean,
"international_export": boolean,
"lines": [
{
"productId": integer,
"default_code": string,
"productQty": integer,
"batch": string,
"expiry": string
}
]
}
}
Response
- 201 OK: Successfully created the record.
- 400 Bad Request: Bad request.
- 401 Unauthorized: Unauthorized.
Response Body
{
"data": {
...record fields
}
}
Example
Request
- NodeJS
- curl
- python
- java
const axios = require('axios');
const accountName = process.env.ACCOUNT_NAME;
const apiKey = process.env.API_KEY;
axios.post(`https://${accountName}.juleb.com/api/v1/inventory/picking/return`, {
PartnerPicking: {
companyId: 1,
partnerId: 51,
reason: "Damaged goods",
lines: [
{
productId: 34969,
productQty: 5,
batch: "13200001"
}
]
}
}, {
headers: {
'accept': '*/*',
'Authorization': `TOKEN`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
curl -X POST \
-H "accept: */*" \
-H "Authorization: ******" \
-H "Content-Type: application/json" \
-d '{
"PartnerPicking": {
"companyId": 1,
"partnerId": 51,
"reason": "Damaged goods",
"lines": [
{
"productId": 34969,
"productQty": 5,
"batch": "13200001"
}
]
}
}' \
"https://$ACCOUNT_NAME.juleb.com/api/v1/inventory/picking/return"
import os
import requests
account_name = os.getenv('ACCOUNT_NAME')
api_key = os.getenv('API_KEY')
url = f'https://{account_name}.juleb.com/api/v1/inventory/picking/return'
headers = {
'accept': '*/*',
'Authorization': f'******',
'Content-Type': 'application/json'
}
data = {
'PartnerPicking': {
'companyId': 1,
'partnerId': 51,
'reason': 'Damaged goods',
'lines': [
{
'productId': 34969,
'productQty': 5,
'batch': '13200001'
}
]
}
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 201:
print(response.json())
else:
print(f'Error: {response.status_code}', response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
public class Main {
public static void main(String[] args) throws Exception {
String accountName = System.getenv("ACCOUNT_NAME");
String apiKey = System.getenv("API_KEY");
String json = "{"
+ "\"PartnerPicking\": {"
+ "\"companyId\": 1,"
+ "\"partnerId\": 51,"
+ "\"reason\": \"Damaged goods\","
+ "\"lines\": [{"
+ "\"productId\": 34969,"
+ "\"productQty\": 5,"
+ "\"batch\": \"13200001\""
+ "}]"
+ "}"
+ "}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://" + accountName + ".juleb.com/api/v1/inventory/picking/return"))
.header("accept", "*/*")
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
if (response.statusCode() == 201) {
System.out.println(response.body());
} else {
System.out.println("Error: " + response.statusCode() + ", " + response.body());
}
}
}
Response
{
"data": {
"id": 11020,
"name": "Demo/RET/00045",
"origin": null,
"note": null,
"state": "assigned",
"partner_id": 51,
"company_id": 1,
"code": "Damaged goods",
"is_return": true
}
}