POST
5 min read
Upload Part Image
POST
/api/v1/parts/{id}/image
Upload an image for a part
Upload Part Image
Upload or replace the image for a part. The image will be automatically processed to create thumbnail (150x150) and preview (400x400) versions.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
integer | The part ID |
Request Body
This endpoint expects multipart/form-data with the following field:
| Field | Type | Required | Description |
|---|---|---|---|
image |
file | Yes | Image file (JPEG, PNG, WebP, GIF, max 5MB) |
Example Request
curl -X POST "https://hydra.marketdragon.ph/api/v1/parts/1/image" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json" \
-F "image=@/path/to/part-image.jpg"
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": 25,
"reorder_level": 10,
"unit": "pcs",
"is_active": true,
"stock_status": "in_stock",
"is_low_stock": false,
"profit_margin": 66.67,
"thumbnail_url": "https://your-bucket.s3.amazonaws.com/parts/1/conversions/thumb.jpg",
"image_url": "https://your-bucket.s3.amazonaws.com/parts/1/conversions/preview.jpg",
"created_at": "2024-01-15T08:30:00+00:00",
"updated_at": "2024-01-20T16:45:00+00:00"
}
}
Image Processing
Uploaded images are automatically processed:
| Version | Size | Usage |
|---|---|---|
thumbnail_url |
150x150 | List views, compact displays |
image_url |
400x400 | Detail views, previews |
Supported Formats
- JPEG (.jpg, .jpeg)
- PNG (.png)
- WebP (.webp)
- GIF (.gif)
Limits
- Maximum file size: 5MB
- Uploading a new image replaces any existing image
Error Responses
403 Forbidden
{
"message": "You do not have access to this part."
}
422 Validation Error
{
"message": "The image field is required.",
"errors": {
"image": ["The image field is required."]
}
}
422 Invalid File Type
{
"message": "The image must be a file of type: jpeg, png, webp, gif.",
"errors": {
"image": ["The image must be a file of type: jpeg, png, webp, gif."]
}
}
Back to Parts
Was this helpful?