Api Reference

Inventory Adjustments

Edit this page

Inventory Adjustments API

Scope: Workspace-scoped — requires authenticated organization context and valid credentials for that workspace.

Endpoints

Create Adjustment

POST /api/inventory/adjustments

Adjust inventory quantity for a stock line. Creates a stock transaction and updates the inventory item.

Request Body:

1{
2 "inventoryItemId": "item_123",
3 "newQtyOnHand": 150,
4 "reasonCodeId": "reason_456",
5 "comment": "Cycle count adjustment",
6 "rootCause": "Physical count discrepancy"
7}

Request Fields:

| Field | Type | Required | Description | |-------|------|----------|-------------| | inventoryItemId | string | Yes | Inventory item ID to adjust | | newQtyOnHand | number | Yes | New quantity on hand | | reasonCodeId | string | Yes | Reason code for the adjustment | | comment | string | No | Optional comment | | rootCause | string | No | Required for healthcare large negative adjustments |

Response:

1{
2 "success": true,
3 "transaction": {
4 "id": "txn_789",
5 "inventoryItemId": "item_123",
6 "transactionType": "ADJUSTMENT",
7 "deltaQty": 50,
8 "reasonCodeId": "reason_456",
9 "createdAt": "2024-01-15T10:30:00Z"
10 },
11 "inventoryItem": {
12 "id": "item_123",
13 "productMasterId": "prod_123",
14 "locationId": "loc_123",
15 "qtyOnHand": 150,
16 "qtyAvailable": 150,
17 "qtyReserved": 0
18 },
19 "message": "Adjusted +50 units"
20}

Get Adjustment History

GET /api/inventory/adjustments

Get stock history and adjustment records with filtering and pagination.

Query Parameters:

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | inventoryItemId | string | No | Filter by inventory item | | productMasterId | string | No | Filter by product | | locationId | string | No | Filter by location | | startDate | string | No | Filter from date (ISO format) | | endDate | string | No | Filter to date (ISO format) | | limit | integer | No | Maximum results (default: 50) | | offset | integer | No | Offset for pagination (default: 0) |

Response:

1{
2 "entries": [
3 {
4 "id": "txn_789",
5 "inventoryItemId": "item_123",
6 "transactionType": "ADJUSTMENT",
7 "deltaQty": 50,
8 "qtyBefore": 100,
9 "qtyAfter": 150,
10 "reasonCode": "Cycle Count",
11 "comment": "Physical count adjustment",
12 "createdAt": "2024-01-15T10:30:00Z",
13 "createdBy": "user_456"
14 }
15 ],
16 "total": 25,
17 "pagination": {
18 "limit": 50,
19 "offset": 0,
20 "hasMore": false
21 }
22}

Example Requests

Create Adjustment

1curl -X POST "https://app.betterdata.co/api/inventory/adjustments" \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "inventoryItemId": "item_123",
6 "newQtyOnHand": 150,
7 "reasonCodeId": "reason_456",
8 "comment": "Cycle count adjustment"
9 }'

Get Adjustment History

1curl -X GET "https://app.betterdata.co/api/inventory/adjustments?locationId=loc_123&startDate=2024-01-01&endDate=2024-01-31&limit=50" \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json"

Common Errors

400 Bad Request

1{
2 "error": "inventoryItemId, newQtyOnHand, and reasonCodeId are required"
3}

Cause: Missing required fields in request body.

Solution: Ensure all required fields are included.

400 Adjustment Failed

1{
2 "error": "Adjustment failed: Insufficient permissions"
3}

Cause: User lacks required permissions or adjustment validation failed.

Solution: Verify user has inventory.adjust permission and check adjustment rules.



Permissions & Roles

Creating adjustments requires inventory management permissions. Some adjustments may require approval.