Creates an audit of materials or products at a storage location. Pass only the actual stock: Controlata calculates the expected stock on the audit date.
v1/audits/add.php
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| storage_id | int | Yes | Storage location the audit is carried out at |
| materials | array | materials or products | Audit lines for materials |
| products | array | materials or products | Audit lines for products |
| date | string | No | Audit date, YYYY-MM-DD. Default today |
materials and products line:
| Field | Type | Required | Description |
|---|---|---|---|
| id | int | id or sku | Material or product ID |
| sku | string | id or sku | SKU |
| actual | float | Yes | Actual stock, 0 or greater |
| notes | string | No | Line notes |
Lines are passed in one array only: an audit counts either materials or products.
The number is assigned automatically. A new audit is created with the status from the Default status for new audits setting.
Example request
{
"storage_id": 3998,
"date": "2026-09-30",
"materials": [
{
"id": 2051,
"actual": 3.8
},
{
"sku": "M022",
"actual": 0,
"notes": "Not found at the storage location"
}
]
}
Example response
{
"success": true,
"audit_id": 1699,
"num": 24,
"status": 1
}
The response returns the ID, number and status code of the new audit. The expected stock and the per-line difference are returned by v1/audits/get_entry.
Errors
| Error | Reason |
|---|---|
| No storage_id in input | storage_id is missing |
| Storage ID is not set | storage_id is 0 or empty |
| Storage ID not found | Storage location not found or deleted |
| Storage location 4001 does not store materials | The storage location does not store items of the audit type (for products: does not store products) |
| An audit counts either materials or products. Create separate audits | Both materials and products were passed |
| No products or materials in input | No line was passed |
| Materials is not an array | materials is not an array (same for products) |
| Line 0 of materials must be an object | The line is not an object (instead of 0, the line number) |
| SKU or id not set for material 0 | The line has neither id nor sku |
| Material with id 2051 not found | Material not found or deleted (for a SKU: Material with SKU "M022" not found) |
| Actual must be 0 or greater for material with id 2051 | actual is missing, not a number or below 0 |
| Material with id 2051 is listed twice | The item is listed in two lines |
| Date is not a valid date in format YYYY-MM-DD | Invalid date format |