Create a batch
Endpoint Overview
This API endpoint provides a detailed overview of the endpoint responsible for creating a batch within the Inventory module of the Juleb ERP.
Endpoint Details
- Method: POST
- URL:
/api/v1/inventory/batch
Parameters
- Path Parameters: None
- Query Parameters: None
{
"name": string,
"product_id": integer,
"company_id": integer,
"life_date": string,
"production_date": 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/batch`, {
name: "api test",
product_id: 7,
company_id: 1,
life_date: "2026-01-01",
production_date: "2023-01-01"
}, {
headers: {
'accept': '*/*',
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
curl -X POST \
"https://$ACCOUNT_NAME.juleb.com/api/v1/inventory/batch" \
-H 'accept: */*' \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"name": "api test",
"product_id": 7,
"company_id": 1,
"life_date": "2026-01-01",
"production_date": "2023-01-01"
}'
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/batch'
headers = {
'accept': '*/*',
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
"name": "api test",
"product_id": 7,
"company_id": 1,
"life_date": "2026-01-01",
"production_date": "2023-01-01"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
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;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
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 = "{"
+ "\"name\": \"api test\","
+ "\"product_id\": 7,"
+ "\"company_id\": 1,"
+ "\"life_date\": \"2026-01-01\","
+ "\"production_date\": \"2023-01-01\""
+ "}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://" + accountName + ".juleb.com/api/v1/inventory/batch"))
.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() == 200) {
System.out.println(response.body());
} else {
System.out.println("Error: " + response.statusCode() + ", " + response.body());
}
}
}
Response
{
"data": {
"id": 43737,
"message_main_attachment_id": null,
"name": "api test",
"ref": null,
"product_id": 7,
"product_uom_id": 1,
"note": null,
"company_id": 1,
"create_uid": 2,
"create_date": "2024-09-03T22:55:05.085Z",
"write_uid": 2,
"write_date": "2024-09-03T22:55:05.085Z",
"life_date": "2026-01-01T00:00:00.000Z",
"use_date": null,
"removal_date": null,
"alert_date": null,
"product_expiry_reminded": null,
"gti_number": null,
"production_date": "2023-01-01T00:00:00.000Z",
"batch_number": null,
"gl_number": null,
"serial_id": null,
"scanned_code": "5555012",
"scanned_code_numeric": null,
"lot_code": "012",
"lot_number": "5555012",
"batch_name": null,
"stock_inventory_tag_id": null,
"is_frozen": null,
"j_batch_qty": 0,
"is_frozen_transfer": null,
"j_life_date_str": "2026-01-01",
"product_package_id": null,
"j_sale_price": null
}
}