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.

This quickstart walks you through the full buyer journey on the AgroPulse platform: creating an account, obtaining a JWT token, browsing available produce from a farmer, placing an order, and initializing payment through the Squad gateway. By the end you will have a working order and a checkout URL you can use to complete payment. All requests target the Django development server running at http://localhost:8000.
Replace the UUID values in the examples below with real IDs returned from the API.
1

Register a user

Create a new BUYER account by posting to /api/users/. The role field accepts BUYER, SELLER, or TRANSPORTER. The password_confirm field must match password.
curl -s -X POST http://localhost:8000/api/users/ \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123",
    "password_confirm": "securepassword123",
    "full_name": "Jane Buyer",
    "phone_number": "+2348012345678",
    "role": "BUYER"
  }'
A successful response returns HTTP 201 Created with the new user object, including the UUID you will need in later steps:
{
  "id": "a1b2c3d4-0000-0000-0000-000000000001",
  "full_name": "Jane Buyer",
  "email": "[email protected]",
  "phone_number": "+2348012345678",
  "role": "BUYER",
  "is_active": true,
  "farmer_profile": null,
  "buyer_profile": null,
  "transporter_profile": null,
  "created_at": "2026-05-13T10:00:00Z",
  "updated_at": "2026-05-13T10:00:00Z"
}
2

Obtain a JWT token

Exchange your credentials for an access token and a refresh token. The access token is required for every authenticated request.
curl -s -X POST http://localhost:8000/api/token/ \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123"
  }'
Response:
{
  "access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Store the access token. Pass it as Authorization: Bearer <access_token> in all subsequent requests. See Authentication for token lifetimes and how to refresh.
3

Browse available produce

List produce that is currently available for purchase. Pass your access token in the Authorization header.
curl -s http://localhost:8000/api/produces/ \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
Response:
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "b2c3d4e5-0000-0000-0000-000000000002",
      "farmer": "f3a4b5c6-0000-0000-0000-000000000003",
      "produce_name": "Roma Tomatoes",
      "category": "VEGETABLES",
      "unit_price": "850.00",
      "quantity_available": 200,
      "harvest_date": "2026-05-10",
      "availability_status": "AVAILABLE",
      "created_at": "2026-05-10T08:00:00Z",
      "updated_at": "2026-05-10T08:00:00Z"
    }
  ]
}
Note the produce id and the farmer UUID — you will need both when placing the order.
4

Place an order

Create an order by referencing your buyer profile UUID, the farmer’s profile UUID, and the produce items you want. The delivery_type must be PICKUP or DELIVERY.
curl -s -X POST http://localhost:8000/api/orders/ \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "buyer": "a1b2c3d4-0000-0000-0000-000000000001",
    "farmer": "f3a4b5c6-0000-0000-0000-000000000003",
    "delivery_type": "DELIVERY",
    "total": "8500.00"
  }'
The API creates the order with order_status: "PENDING" and returns the new order object including its UUID. Record the order id — you will pass it to the payment endpoint in the next step. Then add line items by calling POST /api/order-items/ with the order UUID, produce UUID, quantity, and unit price.
5

Initialize payment

Start a payment session for the order. The API calls the Squad payment gateway and returns a checkout_url that you redirect your user to in order to complete payment.
curl -s -X POST http://localhost:8000/api/payments/initialize_payment/ \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "order_id": "c4d5e6f7-0000-0000-0000-000000000004"
  }'
Response:
{
  "status": "success",
  "checkout_url": "https://sandbox.squadco.com/pay/abc123xyz",
  "transaction_ref": "AGROPULSE-c4d5e6f7-..."
}
Redirect the buyer to checkout_url to complete payment. Once payment is confirmed by Squad’s webhook, the order order_status transitions from PENDING to PAID.
Use the Squad sandbox environment for testing payments. Set SQUAD_SECRET_KEY to your sandbox key and configure SQUAD_BASE_URL to the Squad sandbox endpoint in your .env file.

Build docs developers (and LLMs) love