The Subscriptions API lets buyers set up recurring produce orders from a specific farmer at a chosen frequency — daily, weekly, or monthly. Once created, a subscription automatically tracks the next expected order date and advances it after each fulfilment cycle. Both buyers and farmers have scoped read access to their own subscriptions; staff accounts see all records. Lifecycle transitions (pause, resume, cancel) are handled through dedicated action endpoints rather than generic PATCH requests, keeping state changes explicit and auditable. All endpoints require a valid JWT Bearer token.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.
Base path
Authentication
All endpoints require a JWT Bearer token in theAuthorization header.
Endpoints
| Method | Path | Description | Auth required |
|---|---|---|---|
GET | /api/subscriptions/ | List subscriptions scoped to the authenticated user | Yes |
POST | /api/subscriptions/ | Create a new subscription | Yes |
GET | /api/subscriptions/{id}/ | Retrieve a subscription with full buyer/farmer/produce detail and last 10 orders | Yes |
PUT | /api/subscriptions/{id}/ | Full update of a subscription | Yes |
PATCH | /api/subscriptions/{id}/ | Partial update of a subscription | Yes |
DELETE | /api/subscriptions/{id}/ | Delete a subscription | Yes |
POST | /api/subscriptions/{id}/pause/ | Pause an active subscription | Yes |
POST | /api/subscriptions/{id}/resume/ | Resume a paused subscription | Yes |
POST | /api/subscriptions/{id}/cancel/ | Cancel a subscription | Yes |
GET | /api/subscriptions/my_subscriptions/ | Subscriptions belonging to the authenticated buyer | Yes |
GET | /api/subscriptions/active_subscriptions/ | All subscriptions where active is true | Yes |
GET | /api/subscription-orders/ | List subscription orders scoped to the authenticated user | Yes |
GET | /api/subscription-orders/{id}/ | Retrieve a single subscription order with payment detail | Yes |
GET | /api/subscription-orders/pending_orders/ | All subscription orders with status PENDING | Yes |
GET | /api/subscription-orders/due_orders/ | Orders scheduled for today or earlier that are PENDING or CONFIRMED | Yes |
GET | /api/subscription-payments/ | List subscription payments scoped to the authenticated user | Yes |
GET | /api/subscription-payments/{id}/ | Retrieve a single subscription payment | Yes |
GET | /api/subscription-payments/pending_payments/ | All subscription payments with status PENDING | Yes |
Create a subscription
POST /api/subscriptions/
Creates a new Subscription record linking a buyer to a specific farmer’s produce at a recurring frequency. The system enforces a unique_together constraint on (buyer, farmer, produce) — a buyer can hold only one active subscription per farmer-produce combination. The id, subscription_start_date, created_at, and updated_at fields are set automatically. Status defaults to ACTIVE.
UUID of the
BuyerProfile setting up the subscription.UUID of the
FarmerProfile supplying the produce.UUID of the
Produce item to receive on a recurring basis.Delivery cadence. Must be one of:
DAILY, WEEKLY, MONTHLY. Defaults to WEEKLY if omitted.Number of units expected per delivery cycle. Defaults to
1 if omitted.ISO 8601 date (
YYYY-MM-DD) of the first — or next — expected order. The date advances automatically after each cycle based on the chosen frequency.Example request
Example response
Subscription lifecycle actions
Use the action endpoints below to transition a subscription’s status. Each action accepts aPOST with no request body and returns the updated subscription object.
Pause a subscription
POST /api/subscriptions/{id}/pause/
Sets status to PAUSED and active to false. Paused subscriptions are excluded from automated order generation.
Resume a subscription
POST /api/subscriptions/{id}/resume/
Sets status back to ACTIVE and active to true. Only meaningful on a PAUSED subscription.
Cancel a subscription
POST /api/subscriptions/{id}/cancel/
Sets status to CANCELLED, active to false, and stamps subscription_end_date with today’s date. Cancellation is permanent — use pause if you intend to resume later.
Frequency values
| Value | Next order date advance | Description |
|---|---|---|
DAILY | +1 day | A new order is expected every calendar day. |
WEEKLY | +7 days | A new order is expected every seven days. |
MONTHLY | +30 days | A new order is expected every thirty days. |
Status values
| Value | active flag | Description |
|---|---|---|
ACTIVE | true | Subscription is running and eligible for automated order generation. |
PAUSED | false | Subscription is temporarily suspended. Can be resumed. |
CANCELLED | false | Subscription has been permanently ended. subscription_end_date is set. |
Subscription orders
Each time a subscription cycle falls due, the system auto-generates aSubscriptionOrder record linked to the parent subscription. Subscription orders are read-only through the API — you cannot create or modify them directly.
SubscriptionOrder records capture the quantity, unit price, total amount, and scheduled date for each cycle. Each order progresses through its own order_status: PENDING → CONFIRMED → DELIVERED (or FAILED / SKIPPED). A SubscriptionPayment record is associated one-to-one with each order and tracks payment processing separately.
Use GET /api/subscription-orders/due_orders/ to retrieve orders scheduled for today or earlier that are still in PENDING or CONFIRMED state — useful for automated fulfilment workflows.
The
orders field on a subscription detail response (GET /api/subscriptions/{id}/) includes the 10 most recent subscription orders, ordered by scheduled date descending. Retrieve the full order history through /api/subscription-orders/?subscription={id}.Query parameters
The list endpoint (GET /api/subscriptions/) supports the following query parameters for filtering and ordering.
Filter by subscription status. One of:
ACTIVE, PAUSED, CANCELLED.Filter by delivery frequency. One of:
DAILY, WEEKLY, MONTHLY.Filter by the
active boolean flag. Use true for running subscriptions, false for paused or cancelled ones.Sort results by a field name. Supported fields:
created_at, next_expected_order_date. Prefix with - for descending order (e.g., -created_at).Subscription object
UUID primary key. Auto-generated on creation, never editable.
UUID of the
BuyerProfile that owns the subscription.Full name of the buyer. Read-only, derived from the linked
BuyerProfile.UUID of the
FarmerProfile supplying the produce.Full name of the farmer. Read-only, derived from the linked
FarmerProfile.UUID of the
Produce item covered by the subscription.Name of the produce item. Read-only, derived from the linked
Produce record.Current unit price of the produce as a decimal string (e.g.,
"12.50"). Read-only.Delivery cadence. One of:
DAILY, WEEKLY, MONTHLY. Defaults to WEEKLY.Number of units expected per delivery cycle. Defaults to
1.ISO 8601 date (
YYYY-MM-DD) of the next scheduled order. Advances automatically after each cycle.true when the subscription is ACTIVE; false when PAUSED or CANCELLED.Current lifecycle status. One of:
ACTIVE, PAUSED, CANCELLED. Defaults to ACTIVE.ISO 8601 date the subscription was created. Set automatically, read-only.
ISO 8601 date the subscription was cancelled.
null until the subscription is cancelled.ISO 8601 timestamp of record creation. Read-only.
ISO 8601 timestamp of the last update. Read-only.
The
unique_together constraint on (buyer, farmer, produce) means a buyer can hold exactly one subscription per farmer-produce combination. Attempting to create a duplicate returns a 400 Bad Request.