Update the details of an existing supplier by its ID.
Endpoint
PUT /api/v1/suppliers/{id}
Path Parameters
The unique identifier of the supplier to update
Request Body
Name of the supplier company or individual
Contact email address for the supplier
Contact phone number for the supplier
Whether the supplier should be marked as active
Response
Returns the updated supplier object.
Unique identifier of the supplier
Updated name of the supplier
Updated contact email address
Updated contact phone number
Example Request
curl -X PUT https://api.example.com/api/v1/suppliers/1 \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Furniture Co. Ltd.",
"contactEmail": "[email protected]",
"contactPhone": "+1-555-0150",
"isActive": true
}'
Example Response
{
"id": 1,
"name": "Premium Furniture Co. Ltd.",
"contactEmail": "[email protected]",
"contactPhone": "+1-555-0150",
"isActive": true
}
Status Codes
200 OK - Supplier successfully updated
400 Bad Request - Invalid request body or validation error
404 Not Found - Supplier with the specified ID does not exist
Validation Rules
The following validation rules apply:
name - Must not be empty
contactEmail - Must be a valid email format
contactPhone - Must not be empty
isActive - Must be a boolean value
Error Responses
Supplier Not Found
{
"status": 404,
"error": "Not Found",
"message": "Supplier not found with id: 1"
}
Validation Error
{
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"errors": [
{
"field": "contactEmail",
"message": "must be a valid email address"
}
]
}
Use Cases
Deactivating a Supplier
To mark a supplier as inactive without deleting their record:
curl -X PUT https://api.example.com/api/v1/suppliers/1 \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Furniture Co.",
"contactEmail": "[email protected]",
"contactPhone": "+1-555-0100",
"isActive": false
}'
Update only the contact details while keeping other fields the same:
curl -X PUT https://api.example.com/api/v1/suppliers/1 \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Furniture Co.",
"contactEmail": "[email protected]",
"contactPhone": "+1-555-0199",
"isActive": true
}'