POST 5 min read

Create Part

POST /api/v1/parts

Add a new part to your inventory

Create Part

Add a new part to your inventory for a specific company.

Request Body

Field Type Required Description
company_id integer Yes The company to add the part to
name string Yes Part name (max 255 chars)
part_number string No Manufacturer part number (max 100 chars)
sku string No Stock keeping unit (max 100 chars)
description string No Part description
category string No Part category (max 100 chars)
brand string No Brand name (max 100 chars)
cost_price number No Cost price (min 0)
selling_price number No Selling price (min 0)
quantity_in_stock integer No Current stock quantity (min 0)
reorder_level integer No Low stock threshold (min 0)
unit string No Unit of measure (max 20 chars)
is_active boolean No Whether part is active

Example Request

curl -X POST "https://hydra.marketdragon.ph/api/v1/parts" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "company_id": 1,
    "name": "Brake Pad Set",
    "part_number": "BP-78901",
    "sku": "SKU-045",
    "description": "Premium ceramic brake pads for sedans",
    "category": "Brakes",
    "brand": "StopMax",
    "cost_price": 450.00,
    "selling_price": 750.00,
    "quantity_in_stock": 50,
    "reorder_level": 10,
    "unit": "set",
    "is_active": true
  }'

Example Response

{
    "data": {
        "id": 45,
        "company_id": 1,
        "name": "Brake Pad Set",
        "part_number": "BP-78901",
        "sku": "SKU-045",
        "description": "Premium ceramic brake pads for sedans",
        "category": "Brakes",
        "brand": "StopMax",
        "cost_price": "450.00",
        "selling_price": "750.00",
        "quantity_in_stock": 50,
        "reorder_level": 10,
        "unit": "set",
        "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-20T10:15:00+00:00",
        "updated_at": "2024-01-20T10:15:00+00:00"
    }
}

Error Responses

403 Forbidden

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

422 Validation Error

{
    "message": "The name field is required.",
    "errors": {
        "name": ["The name field is required."],
        "company_id": ["The selected company id is invalid."]
    }
}
Back to Parts
Was this helpful?