Skip to main content
The Products API provides comprehensive endpoints for managing pharmaceutical product catalogs in the VIGIA pharmacovigilance platform.

Base Path

/api/v1/products

Authentication

All endpoints require authentication via the get_current_user dependency. Include your JWT token in the Authorization header:
Authorization: Bearer YOUR_JWT_TOKEN

Key Features

  • CRUD Operations: Create, read, update, and delete product records
  • Advanced Search: Text-based search across multiple fields with filtering
  • Bulk Import: Import/update multiple products via JSON payload
  • Technical Datasheets: Upload and manage PDF technical documentation
  • Audit Trail: All product operations are automatically audited

Product Model

Products include the following key fields:
FieldTypeDescription
idintegerUnique product identifier
productostringProduct name
ifastringActive pharmaceutical ingredient (IFA)
forma_farmaceuticastringPharmaceutical form
presentacion_farmaceuticastringPharmaceutical presentation
viastringRoute of administration
estado_registrostringRegistration status
numero_registrostringSanitary registration number (unique identifier)
fecha_venc_registrodateRegistration expiration date
fecha_primer_registrodateFirst registration date
comercializabooleanCurrently marketed
pais_comercializacionstringMarketing country
laboratorio_paisstringLaboratory/country
ficha_tecnica_urlstringURL to technical datasheet PDF
comentariosstringAdditional comments

Endpoints

Create Product

POST /products/

Create a new product record.
Request Body:
{
  "producto": "Paracetamol 500mg",
  "ifa": "Paracetamol",
  "forma_farmaceutica": "Tableta",
  "numero_registro": "RS-12345",
  "estado_registro": "Vigente",
  "comercializa": true
}
Response: 201 Created
{
  "id": 123,
  "producto": "Paracetamol 500mg",
  "ifa": "Paracetamol",
  "numero_registro": "RS-12345",
  "created_at": "2026-03-03T10:30:00Z",
  "updated_at": "2026-03-03T10:30:00Z"
}

List Products

GET /products/

Retrieve a paginated list of products with optional filtering and sorting.
Query Parameters:
ParameterTypeDefaultDescription
qstring""Search text (searches producto, ifa, numero_registro)
estadostring”all”Filter by registration status
comercializastring”all”Filter by marketing status (“si”, “no”, “all”)
sortstring”producto”Sort field (producto, ifa, id, created_at, numero_registro)
orderstring”asc”Sort order (asc, desc)
offsetinteger0Pagination offset
limitinteger50Results per page (max 200)
numero_registrostringnullExact match filter by registration number
Example Request:
GET /api/v1/products/?q=paracetamol&comercializa=si&limit=20&sort=created_at&order=desc
Response: 200 OK
{
  "items": [
    {
      "id": 123,
      "producto": "Paracetamol 500mg",
      "ifa": "Paracetamol",
      "numero_registro": "RS-12345",
      "comercializa": true
    }
  ],
  "total": 45,
  "offset": 0,
  "limit": 20
}

Search Products (Autocomplete)

GET /products/search

Fast search endpoint optimized for autocomplete functionality.
Query Parameters:
  • term or q (required): Search term (min 2 characters)
  • limit (optional, default: 8, max: 50): Maximum results
Example:
GET /api/v1/products/search?term=para&limit=5
Response:
{
  "items": [
    {
      "id": 123,
      "producto": "Paracetamol 500mg",
      "ifa": "Paracetamol",
      "numero_registro": "RS-12345"
    }
  ],
  "total": 3,
  "limit": 5
}

Get Product by ID

GET /products/{product_id}

Retrieve a single product by its ID.
Response: 200 OK or 404 Not Found

Update Product

PUT /products/{product_id}

Update an existing product. Only provided fields will be updated.
Request Body:
{
  "estado_registro": "Vencido",
  "comercializa": false
}
Response: 200 OK The update operation automatically tracks changes and stores them in the audit log with a diff of modified fields.

Delete Product

DELETE /products/{product_id}

Permanently delete a product record.
Response: 200 OK
{
  "ok": true
}

Lookup by Registration Number

GET /products/by-registro

Find a product by its sanitary registration number.
Query Parameters:
  • registro or numero_registro: Registration number (exact match)
Example:
GET /api/v1/products/by-registro?registro=RS-12345
Alternative Path-based Lookup:
GET /api/v1/products/by-registro/RS-12345

Bulk Import

POST /products/bulk

Create or update multiple products in a single operation.
Upsert Logic: Products are matched by numero_registro. If a match is found, the product is updated; otherwise, a new product is created. Request Body:
{
  "items": [
    {
      "producto": "Ibuprofeno 400mg",
      "ifa": "Ibuprofeno",
      "numero_registro": "RS-67890",
      "comercializa": true
    },
    {
      "producto": "Amoxicilina 500mg",
      "ifa": "Amoxicilina",
      "numero_registro": "RS-11111"
    }
  ]
}
Response: 200 OK
{
  "created": 15,
  "updated": 8,
  "skipped": 2,
  "errors": [
    {
      "index": 5,
      "numero_registro": "RS-INVALID",
      "error": "Invalid format"
    }
  ],
  "total_processed": 25
}
Requirements:
  • Each item must include at minimum: producto and numero_registro
  • Unknown fields are ignored
  • Invalid items are skipped and reported in errors

Technical Datasheet Management

Upload Technical Datasheet

POST /products/{product_id}/ficha-tecnica

Upload a PDF technical datasheet for a product.
Request: Multipart form-data with PDF file Response: 201 Created
{
  "url": "/media/products/123/ficha-20260303-103045.pdf",
  "abs_url": "http://api.example.com/media/products/123/ficha-20260303-103045.pdf"
}

Get Technical Datasheet URL

GET /products/{product_id}/ficha-tecnica

Retrieve the URL of the product’s technical datasheet.
Response: 200 OK or 404 Not Found
{
  "url": "/media/products/123/ficha-20260303-103045.pdf",
  "abs_url": "http://api.example.com/media/products/123/ficha-20260303-103045.pdf"
}

Delete Technical Datasheet

DELETE /products/{product_id}/ficha-tecnica

Remove the technical datasheet reference and delete the physical file.
Response: 200 OK
{
  "ok": true
}

Audit Trail

All product operations are automatically audited with the following actions:
  • PRODUCT_CREATE - Product creation
  • PRODUCT_LIST - Product listing
  • PRODUCT_UPDATE - Product updates (includes change diff)
  • PRODUCT_DELETE - Product deletion
  • PRODUCT_BULK_IMPORT - Bulk import operations
  • PRODUCT_FICHA_UPLOAD - Technical datasheet upload
  • PRODUCT_FICHA_DELETE - Technical datasheet deletion
Audit logs include user information, timestamps, and detailed change history.

Build docs developers (and LLMs) love