Create a Product Template
Endpoint Overview
This API endpoint provides a detailed overview of the endpoint responsible for creating a product template within the Inventory module of the Juleb ERP. A product template holds the generic information shared by a product (name, category, pricing, units of measure, tracking, classification, etc.) — the actual sellable variant(s) are managed separately under Product.
Endpoint Details
- Method: POST
- URL:
/api/v1/inventory/product-template
Parameters
- Path Parameters: None
- Query Parameters: None
Request Body
{
"type": "product",
"categ_id": integer,
"name": string,
"list_price": integer,
"taxes_id": integer[],
"supplier_taxes_id": integer[],
"j_active_ingredient": integer[],
"uom_id": integer,
"uom_po_id": integer,
"default_code": string,
"barcode": string,
"tracking": "none",
"gtin": string,
"is_rsd_product": boolean,
"j_name_ar": string,
"active": boolean,
"product_brand_id": integer,
"pos_categ_id": integer,
"j_manufacture_country": integer,
"j_category_2": integer,
"j_category_3": integer,
"j_category_4": integer,
"j_category_5": integer,
"j_category_6": integer,
"j_category_7": integer,
"j_brand": string,
"j_brand_ar": string,
"consumption_rule": "category",
"responsible_id": integer
}
Field Reference
| Field | Type | Required | Description |
|---|---|---|---|
type | string | No | Product type: product, service, or consu. Defaults to product. |
categ_id | integer | Yes | Product Category ID — see Product Category. |
name | string | Yes | Product name. |
list_price | integer | No | Sales price. |
taxes_id | integer[] | No | Customer taxes applied when selling. Defaults to []. |
supplier_taxes_id | integer[] | No | Vendor taxes applied when buying. Defaults to []. |
j_active_ingredient | integer[] | No | Active Ingredient IDs — see Active Ingredient. Defaults to []. |
uom_id | integer | No | Unit of Measure ID. Defaults to 1. |
uom_po_id | integer | No | Purchase Unit of Measure ID. Defaults to 1. |
default_code | string | No | Internal reference/SKU. Omit or send null/false to auto-generate one. |
barcode | string | No | Product barcode. |
tracking | string | No | Stock tracking method. Accepted values are none (no lot/serial tracking) and lot (tracked by batch/lot number, required to use batch/lot_name elsewhere in the API). Defaults to none. |
gtin | string | No | GS1 GTIN code for the product, used for QR/barcode-based lookups (see POS Order's selectProductByGtin). |
is_rsd_product | boolean | No | Marks the product as tracked by the external RSD (track-and-trace) system. Defaults to false. |
j_name_ar | string | No | Arabic product name. |
active | boolean | No | Whether the product is active (false archives it). Defaults to true. |
product_brand_id | integer | No | Product Brand ID — see Product Brand. |
pos_categ_id | integer | No | POS Category ID the product is sold under in the POS app. |
j_manufacture_country | integer | No | Manufacturing country ID. |
j_category_2 – j_category_7 | integer | No | Additional, business-defined classification category IDs (secondary through seventh category). |
j_brand | string | No | Free-text brand name. |
j_brand_ar | string | No | Free-text brand name in Arabic. |
consumption_rule | string | No | How the product is consumed: product or category. Defaults to category. |
responsible_id | integer | No | User ID responsible for the product's logistics. |
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/product-template`, {
type: 'product',
categ_id: 12,
name: 'Paracetamol 500mg',
list_price: 10,
uom_id: 1,
uom_po_id: 1,
tracking: 'lot',
barcode: '6281006280012',
is_rsd_product: true
}, {
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 '{
"type": "product",
"categ_id": 12,
"name": "Paracetamol 500mg",
"list_price": 10,
"uom_id": 1,
"uom_po_id": 1,
"tracking": "lot",
"barcode": "6281006280012",
"is_rsd_product": true
}' \
"https://$ACCOUNT_NAME.juleb.com/api/v1/inventory/product-template"
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/product-template'
headers = {
'accept': '*/*',
'Authorization': f'******',
'Content-Type': 'application/json'
}
data = {
'type': 'product',
'categ_id': 12,
'name': 'Paracetamol 500mg',
'list_price': 10,
'uom_id': 1,
'uom_po_id': 1,
'tracking': 'lot',
'barcode': '6281006280012',
'is_rsd_product': True
}
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 = "{"
+ "\"type\": \"product\","
+ "\"categ_id\": 12,"
+ "\"name\": \"Paracetamol 500mg\","
+ "\"list_price\": 10,"
+ "\"uom_id\": 1,"
+ "\"uom_po_id\": 1,"
+ "\"tracking\": \"lot\","
+ "\"barcode\": \"6281006280012\","
+ "\"is_rsd_product\": true"
+ "}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://" + accountName + ".juleb.com/api/v1/inventory/product-template"))
.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": 9123,
"name": "Paracetamol 500mg",
"categ_id": 12,
"list_price": 10,
"default_code": "PROD9123",
"tracking": "lot",
"barcode": "6281006280012"
}
}