POST 5 min read

Adjust Stock

POST /api/v1/parts/{id}/adjust-stock

Adjust the stock quantity of a part

Adjust Stock

Adjust the stock quantity of a part. Use positive numbers to add stock, negative numbers to remove stock.

Path Parameters

Parameter Type Description
id integer The part ID

Request Body

Field Type Required Description
quantity integer Yes Amount to adjust (positive to add, negative to subtract)
reason string No Reason for the adjustment (max 255 chars)

Example Request - Adding Stock

curl -X POST "https://hydra.marketdragon.ph/api/v1/parts/1/adjust-stock" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": 25,
    "reason": "Received shipment from supplier"
  }'

Example Request - Removing Stock

curl -X POST "https://hydra.marketdragon.ph/api/v1/parts/1/adjust-stock" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": -5,
    "reason": "Damaged items disposed"
  }'

Example Response

{
    "data": {
        "id": 1,
        "company_id": 1,
        "name": "Oil Filter",
        "part_number": "OF-12345",
        "sku": "SKU-001",
        "description": "Premium oil filter for most vehicles",
        "category": "Filters",
        "brand": "FilterPro",
        "cost_price": "150.00",
        "selling_price": "250.00",
        "quantity_in_stock": 30,
        "reorder_level": 10,
        "unit": "pcs",
        "is_active": true,
        "stock_status": "in_stock",
        "is_low_stock": false,
        "profit_margin": 66.67,
        "thumbnail_url": null,
        "image_url": null,
        "created_at": "2024-01-15T08:30:00+00:00",
        "updated_at": "2024-01-20T16:45:00+00:00"
    }
}

Stock Status Values

After adjustment, the stock_status field reflects the current inventory level:

Status Condition
in_stock quantity_in_stock > reorder_level
low_stock quantity_in_stock <= reorder_level and quantity_in_stock > 0
out_of_stock quantity_in_stock <= 0

Error Responses

403 Forbidden

{
    "message": "You do not have access to this part."
}

422 Validation Error

{
    "message": "The quantity field is required.",
    "errors": {
        "quantity": ["The quantity field is required."]
    }
}
Back to Parts
Was this helpful?