Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OluwagbeminiyiA/agro_pulse-API/llms.txt

Use this file to discover all available pages before exploring further.

The Orders API is the transactional core of the AgroPulse platform. Buyers use it to place orders for produce from a specific farmer, and both buyers and farmers can track order progress through a lifecycle of statuses — from PENDING through to COMPLETED or CANCELLED. Role-based visibility is enforced automatically: buyers see only their own orders, farmers see only orders placed against their produce, and staff accounts have full access. All endpoints require a valid JWT Bearer token.

Base path

/api/orders/

Authentication

All endpoints require a JWT Bearer token in the Authorization header.

Endpoints

MethodPathDescriptionAuth required
GET/api/orders/List orders (scoped to the authenticated user)Yes
POST/api/orders/Create a new orderYes
GET/api/orders/{id}/Retrieve a single order with its line itemsYes
PUT/api/orders/{id}/Full update of an orderYes
PATCH/api/orders/{id}/Partial update of an orderYes
DELETE/api/orders/{id}/Delete an orderYes
GET/api/orders/my_orders/Orders belonging to the authenticated userYes
GET/api/orders/pending_orders/All orders with status PENDINGYes
GET/api/orders/by_status/Filter orders by a specific status valueYes
PATCH/api/orders/{id}/update_status/Transition an order to a new statusYes

Create an order

POST /api/orders/ Creates a new Order record linking a buyer to a farmer. The id, order_status, created_at, and updated_at fields are set automatically. order_status always starts as PENDING.
buyer
string
required
UUID of the BuyerProfile placing the order.
farmer
string
required
UUID of the FarmerProfile whose produce is being ordered.
total
number
required
Total monetary value of the order. Decimal, up to 2 decimal places (e.g., 135.00).
delivery_type
string
required
How the order will be fulfilled. Must be one of: PICKUP, DELIVERY.

Example request

curl --request POST \
  --url https://api.agropulse.example.com/api/orders/ \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "buyer": "c2d5f3b8-44e0-4c9f-b6a1-83d2e4f0a716",
    "farmer": "b7d2e4f6-91c3-4a2b-8d0e-56f7a8b9c012",
    "total": "135.00",
    "delivery_type": "DELIVERY"
  }'

Example response

{
  "id": "f3a1c7e9-55b2-4d0e-c8f4-94e5g6h7i820",
  "buyer": "c2d5f3b8-44e0-4c9f-b6a1-83d2e4f0a716",
  "buyer_business_name": "Accra Fresh Markets Ltd",
  "buyer_email": "[email protected]",
  "farmer": "b7d2e4f6-91c3-4a2b-8d0e-56f7a8b9c012",
  "farmer_farm_name": "Golden Harvest Farms",
  "farmer_user_email": "[email protected]",
  "total": "135.00",
  "order_status": "PENDING",
  "delivery_type": "DELIVERY",
  "created_at": "2026-05-13T12:00:00.000000Z",
  "updated_at": "2026-05-13T12:00:00.000000Z"
}

Update order status

PATCH /api/orders/{id}/update_status/ Transitions an order to a new status value. Only order_status is accepted in the request body. Supplying an invalid status value returns a 400 Bad Request with the list of valid options.
order_status
string
required
The target status for the order. Must be one of: PENDING, PAID, PROCESSING, IN_TRANSIT, COMPLETED, CANCELLED.

Order status values

StatusDescription
PENDINGOrder created but not yet paid for.
PAIDPayment received; awaiting processing.
PROCESSINGFarmer is preparing the order.
IN_TRANSITOrder has been dispatched and is on the way.
COMPLETEDOrder successfully delivered and fulfilled.
CANCELLEDOrder was cancelled before fulfilment.

Example request

curl --request PATCH \
  --url https://api.agropulse.example.com/api/orders/f3a1c7e9-55b2-4d0e-c8f4-94e5g6h7i820/update_status/ \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "order_status": "PAID"
  }'

Example response

{
  "id": "f3a1c7e9-55b2-4d0e-c8f4-94e5g6h7i820",
  "buyer": "c2d5f3b8-44e0-4c9f-b6a1-83d2e4f0a716",
  "buyer_business_name": "Accra Fresh Markets Ltd",
  "buyer_email": "[email protected]",
  "farmer": "b7d2e4f6-91c3-4a2b-8d0e-56f7a8b9c012",
  "farmer_farm_name": "Golden Harvest Farms",
  "farmer_user_email": "[email protected]",
  "total": "135.00",
  "order_status": "PAID",
  "delivery_type": "DELIVERY",
  "created_at": "2026-05-13T12:00:00.000000Z",
  "updated_at": "2026-05-13T12:05:00.000000Z"
}

Filter orders

GET /api/orders/ Returns orders scoped to the authenticated user’s role. Use the query parameters below to narrow results. For a status-specific shortcut, use GET /api/orders/by_status/?status=PROCESSING.

Query parameters

buyer
string
Filter by buyer UUID. Returns orders placed by the specified BuyerProfile. Admin only in practice — buyers are automatically scoped to their own profile.
farmer
string
Filter by farmer UUID. Returns orders directed at the specified FarmerProfile.
order_status
string
Filter by status. One of: PENDING, PAID, PROCESSING, IN_TRANSIT, COMPLETED, CANCELLED.
delivery_type
string
Filter by delivery type. One of: PICKUP, DELIVERY.
Search term matched against buyer__business_name and farmer__farm_name.
ordering
string
Sort results by a field name. Supported fields: total, created_at. Prefix with - for descending order (e.g., -created_at).

Example request

curl --request GET \
  --url 'https://api.agropulse.example.com/api/orders/?order_status=PENDING&ordering=-created_at' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Order object

id
string
required
UUID primary key. Auto-generated on creation, never editable.
buyer
string
required
UUID of the BuyerProfile that placed the order.
buyer_business_name
string
required
Business name of the buyer. Read-only, derived from the linked BuyerProfile.
buyer_email
string
required
Email of the buyer’s user account. Read-only.
farmer
string
required
UUID of the FarmerProfile fulfilling the order.
farmer_farm_name
string
required
Name of the farmer’s farm. Read-only, derived from the linked FarmerProfile.
farmer_user_email
string
required
Email of the farmer’s user account. Read-only.
total
string
required
Total order value as a decimal string (e.g., "135.00").
order_status
string
required
Current lifecycle status. One of: PENDING, PAID, PROCESSING, IN_TRANSIT, COMPLETED, CANCELLED. Defaults to PENDING on creation.
delivery_type
string
required
Fulfilment method. One of: PICKUP, DELIVERY.
created_at
string
required
ISO 8601 timestamp of order creation. Read-only.
updated_at
string
required
ISO 8601 timestamp of the last update. Read-only.

Build docs developers (and LLMs) love