POST
Ticket.StockProductAdd
Insert a ticket_products row and deduct inventory from ec_product (and storage_products when the product uses storages). Matches dashboard customer-tickets ticket_product_add. This is NOT Ticket.ProductsByCustomer (PO/invoice picker).
Permissions
- User must be logged in with a valid bearer token.
- Returned or changed records are limited by the user permissions, team access, folder access, and account settings.
Action
- Runs the Ticket.StockProductAdd function and returns JSON.
Push Service
No push is sent because this function only reads data or returns helper information.
Automation
No automation is run for this function.
Special Instructions
- Call Ticket.StockProductSearch first to pick product_id and see has_storage.
- If has_storage=1, call Ticket.StockProductStorages then send storage_id (required).
- qty must be > 0. Returns Not enough stock when inventory is insufficient.
- Response items[] is the refreshed ticket product list.
Required Parameters
| Name | Type | Sample | Explanation |
|---|---|---|---|
ticket_idpost | int | 900 | Ticket id. Aliases: id, data_id, t_id. |
product_idpost | int | 42 | ec_product id from StockProductSearch. |
qtypost | number | 2 | Quantity to attach and deduct. Must be > 0. |
Optional Parameters
| Name | Type | Sample | What it gives |
|---|---|---|---|
storage_idpost | int | 3 | Required when product has storages (has_storage=1). From StockProductStorages. |
Authentication
Send the bearer token returned by Login in the request header.
Authorization: Bearer YOUR TOKEN
Sample Request
{
"url": "\/app\/Ticket.StockProductAdd",
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR TOKEN"
},
"body": {
"ticket_id": "900",
"product_id": "42",
"qty": "2",
"storage_id": "3"
},
"url_user": "https:\/\/{user}.bull36.com\/app\/Ticket.StockProductAdd",
"url_domain": "https:\/\/{domain}\/app\/Ticket.StockProductAdd"
}Endpoint
POST /app/Ticket.StockProductAdd
POST https://{user}.bull36.com/app/Ticket.StockProductAdd
POST https://{domain}/app/Ticket.StockProductAddSample Output
{
"success": 1,
"message": "Success",
"id": 7,
"items": [
{
"id": 7,
"product_id": 42,
"product_name": "Widget A",
"qty": 2,
"storage_id": 3,
"storage_name": "Main"
}
]
}JavaScript Example
const token = 'YOUR TOKEN';
const body = new URLSearchParams({ ticket_id: '900', product_id: '42', qty: '2', storage_id: '3' });
const res = await fetch('/app/Ticket.StockProductAdd', { method: 'POST', headers: { Authorization: 'Bearer ' + token }, body });
console.log(await res.json());Error Example
{
"success": 0,
"message": "Not enough stock"
}