Skip to main content

Search Movements

GET /api/v1/reports/movements/search

Advanced search for inventory movements with multiple filter options and pagination support.

Query Parameters

start_date
string
Start date for the search range in YYYY-MM-DD format (e.g., 2026-01-01)
end_date
string
End date for the search range in YYYY-MM-DD format (e.g., 2026-03-04)
product_id
string
Filter movements for a specific product ID (UUID format)
movement_type
string
Filter by movement type. Available values:
  • ENTRY - Incoming inventory
  • EXIT - Outgoing inventory
  • ADJUSTMENT - Stock adjustments
user_id
string
Filter movements by the user who performed them (UUID format)
skip
integer
default:"0"
Number of records to skip for pagination
limit
integer
default:"100"
Maximum number of records to return (max: 100)

Authorization

Requires one of the following roles:
  • admin
  • gestor
  • consultor

Response

{
  "status": "success",
  "count": 2,
  "movements": [
    {
      "movement_id": "123e4567-e89b-12d3-a456-426614174000",
      "product_id": "223e4567-e89b-12d3-a456-426614174001",
      "product_name": "Product A",
      "product_sku": "SKU-001",
      "movement_type": "ENTRY",
      "quantity": 50,
      "batch_id": "BATCH-001",
      "unit_cost": 50.00,
      "total_cost": 2500.00,
      "timestamp": "2026-03-04T10:30:00Z",
      "user_id": "323e4567-e89b-12d3-a456-426614174002",
      "user_name": "John Doe",
      "notes": "Received from supplier XYZ"
    },
    {
      "movement_id": "133e4567-e89b-12d3-a456-426614174003",
      "product_id": "223e4567-e89b-12d3-a456-426614174001",
      "product_name": "Product A",
      "product_sku": "SKU-001",
      "movement_type": "EXIT",
      "quantity": -20,
      "batch_id": "BATCH-001",
      "unit_cost": 50.00,
      "total_cost": -1000.00,
      "timestamp": "2026-03-04T14:15:00Z",
      "user_id": "333e4567-e89b-12d3-a456-426614174004",
      "user_name": "Jane Smith",
      "notes": "Sale to customer ABC"
    }
  ]
}

Pagination

Use the skip and limit parameters to paginate through large result sets:
# First page (records 1-100)
curl -X GET "https://api.example.com/api/v1/reports/movements/search?skip=0&limit=100" \
  -H "Authorization: Bearer YOUR_TOKEN"

# Second page (records 101-200)
curl -X GET "https://api.example.com/api/v1/reports/movements/search?skip=100&limit=100" \
  -H "Authorization: Bearer YOUR_TOKEN"

Filter Examples

Search by Date Range

curl -X GET "https://api.example.com/api/v1/reports/movements/search?start_date=2026-01-01&end_date=2026-03-04" \
  -H "Authorization: Bearer YOUR_TOKEN"

Search by Product

curl -X GET "https://api.example.com/api/v1/reports/movements/search?product_id=223e4567-e89b-12d3-a456-426614174001" \
  -H "Authorization: Bearer YOUR_TOKEN"

Search by Movement Type

curl -X GET "https://api.example.com/api/v1/reports/movements/search?movement_type=ENTRY&start_date=2026-03-01" \
  -H "Authorization: Bearer YOUR_TOKEN"

Search by User

curl -X GET "https://api.example.com/api/v1/reports/movements/search?user_id=323e4567-e89b-12d3-a456-426614174002" \
  -H "Authorization: Bearer YOUR_TOKEN"

Combined Filters

curl -X GET "https://api.example.com/api/v1/reports/movements/search?start_date=2026-01-01&end_date=2026-03-04&movement_type=EXIT&product_id=223e4567-e89b-12d3-a456-426614174001&limit=50" \
  -H "Authorization: Bearer YOUR_TOKEN"

Error Responses

400
error
Invalid start_date format
{
  "error": "Invalid start_date format"
}
400
error
Invalid end_date format
{
  "error": "Invalid end_date format"
}

Use Cases

Audit Trail

Track all movements for a specific product to maintain detailed audit records.

User Activity

Monitor inventory actions performed by specific users for accountability.

Period Analysis

Analyze movement patterns within specific date ranges for reporting.

Movement Type Analysis

Filter by movement type to analyze entries, exits, or adjustments separately.

Code Reference

Implemented in backend/Report/Adapters/report_controller.py:250

Build docs developers (and LLMs) love