Overview
The Suppliers API allows you to create, retrieve, update, and delete supplier records in the inventory management system. Suppliers have delivery terms and purchase conditions specific to procurement operations.
Base URL: /api/v1/suppliers
Authentication
All endpoints require JWT authentication via Bearer token in the Authorization header.
Create Supplier
Create a new supplier record.
Required Roles: admin, gestor
Request Body
Request Example
import requests
url = "http://localhost:5000/api/v1/suppliers/"
headers = {
"Authorization" : "Bearer YOUR_JWT_TOKEN" ,
"Content-Type" : "application/json"
}
payload = {
"nombre" : "Distribuidora ABC S.A.C." ,
"tipo_documento" : "RUC" ,
"numero_documento" : "20123456789" ,
"direccion" : "Av. Industrial 500, Callao" ,
"telefono" : "+51 014567890" ,
"email" : "[email protected] " ,
"plazo_entrega_dias" : 7 ,
"condiciones_compra" : "Pago 50 % a delantado, 50 % c ontra entrega"
}
response = requests.post(url, json = payload, headers = headers)
print (response.json())
Response
201 Created
400 Bad Request
409 Conflict
{
"id" : "770e8400-e29b-41d4-a716-446655440002" ,
"nombre" : "Distribuidora ABC S.A.C." ,
"tipo_documento" : "RUC" ,
"numero_documento" : "20123456789" ,
"direccion" : "Av. Industrial 500, Callao" ,
"telefono" : "+51 014567890" ,
"email" : "[email protected] " ,
"plazo_entrega_dias" : 7 ,
"condiciones_compra" : "Pago 50% adelantado, 50% contra entrega"
}
List Suppliers
Retrieve a list of all suppliers with optional search and pagination.
Required Roles: admin, gestor, consultor
Query Parameters
Request Example
import requests
url = "http://localhost:5000/api/v1/suppliers/"
headers = {
"Authorization" : "Bearer YOUR_JWT_TOKEN"
}
params = {
"skip" : 0 ,
"limit" : 10 ,
"q" : "Distribuidora"
}
response = requests.get(url, params = params, headers = headers)
print (response.json())
Response
[
{
"id" : "770e8400-e29b-41d4-a716-446655440002" ,
"nombre" : "Distribuidora ABC S.A.C." ,
"tipo_documento" : "RUC" ,
"numero_documento" : "20123456789" ,
"direccion" : "Av. Industrial 500, Callao" ,
"telefono" : "+51 014567890" ,
"email" : "[email protected] " ,
"plazo_entrega_dias" : 7 ,
"condiciones_compra" : "Pago 50% adelantado, 50% contra entrega"
},
{
"id" : "880e8400-e29b-41d4-a716-446655440003" ,
"nombre" : "Importaciones XYZ E.I.R.L." ,
"tipo_documento" : "RUC" ,
"numero_documento" : "20987654321" ,
"direccion" : "Jr. Importadores 200, Lima" ,
"telefono" : "+51 017654321" ,
"email" : "[email protected] " ,
"plazo_entrega_dias" : 15 ,
"condiciones_compra" : "Crédito 30 dÃas"
}
]
Get Supplier
Retrieve details of a specific supplier by ID.
Required Roles: admin, gestor, consultor
Path Parameters
Request Example
import requests
supplier_id = "770e8400-e29b-41d4-a716-446655440002"
url = f "http://localhost:5000/api/v1/suppliers/ { supplier_id } "
headers = {
"Authorization" : "Bearer YOUR_JWT_TOKEN"
}
response = requests.get(url, headers = headers)
print (response.json())
Response
{
"id" : "770e8400-e29b-41d4-a716-446655440002" ,
"nombre" : "Distribuidora ABC S.A.C." ,
"tipo_documento" : "RUC" ,
"numero_documento" : "20123456789" ,
"direccion" : "Av. Industrial 500, Callao" ,
"telefono" : "+51 014567890" ,
"email" : "[email protected] " ,
"plazo_entrega_dias" : 7 ,
"condiciones_compra" : "Pago 50% adelantado, 50% contra entrega"
}
Update Supplier
Update an existing supplier’s information. Both PUT and PATCH methods are supported for partial updates.
Required Roles: admin, gestor
Path Parameters
Request Body
All fields are optional. Only include fields you want to update.
Request Example
import requests
supplier_id = "770e8400-e29b-41d4-a716-446655440002"
url = f "http://localhost:5000/api/v1/suppliers/ { supplier_id } "
headers = {
"Authorization" : "Bearer YOUR_JWT_TOKEN" ,
"Content-Type" : "application/json"
}
payload = {
"plazo_entrega_dias" : 5 ,
"telefono" : "+51 014567899"
}
response = requests.put(url, json = payload, headers = headers)
print (response.json())
Response
200 OK
404 Not Found
409 Conflict
{
"id" : "770e8400-e29b-41d4-a716-446655440002" ,
"nombre" : "Distribuidora ABC S.A.C." ,
"tipo_documento" : "RUC" ,
"numero_documento" : "20123456789" ,
"direccion" : "Av. Industrial 500, Callao" ,
"telefono" : "+51 014567899" ,
"email" : "[email protected] " ,
"plazo_entrega_dias" : 5 ,
"condiciones_compra" : "Pago 50% adelantado, 50% contra entrega"
}
Delete Supplier
Delete a supplier from the system.
Required Roles: admin, gestor
Path Parameters
Request Example
import requests
supplier_id = "770e8400-e29b-41d4-a716-446655440002"
url = f "http://localhost:5000/api/v1/suppliers/ { supplier_id } "
headers = {
"Authorization" : "Bearer YOUR_JWT_TOKEN"
}
response = requests.delete(url, headers = headers)
print (response.json())
Response
200 OK
404 Not Found
409 Conflict
{
"message" : "Supplier deleted successfully"
}
Suppliers with existing transactions (purchase orders, receipts, etc.) cannot be deleted due to referential integrity constraints. Consider marking them as inactive instead if your business logic supports it.
Error Codes
Status Code Description 200 Success 201 Created 400 Bad Request - Missing required fields or validation error 401 Unauthorized - Invalid or missing JWT token 403 Forbidden - Insufficient permissions for the operation 404 Not Found - Supplier does not exist 409 Conflict - Duplicate document number or email, or integrity constraint violation
Data Models
Supplier Object
Field Type Description id string (UUID) Unique identifier nombre string Supplier name tipo_documento string Document type (RUC, DNI, CE, etc.) numero_documento string Document number (unique) direccion string Physical address telefono string Contact phone number email string Email address (unique) plazo_entrega_dias integer Standard delivery time in days condiciones_compra string Purchase terms and conditions