Buy Orders V2

Create direct purchase order

Changed on

Create a direct purchase order from listing

Creates an order directly from a listing with variant selection, bypassing the cart. This implements "Buy Now" functionality for immediate purchases.

Process:

  1. Validates listing exists and is active
  2. Validates variant exists and belongs to listing
  3. Checks variant availability (sufficient stock)
  4. Snapshots variant price at purchase time
  5. Creates order record in V1 orders table
  6. Creates market_orders entry (V1 compatibility)
  7. Creates order_market_items_v2 entry with variant tracking
  8. Allocates stock from variant-specific lots
  9. Returns order details with purchase summary

Uses database transaction for atomicity to ensure all-or-nothing behavior. Stock allocation uses listing_item_lots directly (V2).

Requirements:

  • Validate listing exists and is active
  • Validate variant exists and belongs to listing
  • Check variant availability before order creation
  • Create order with variant-specific line item
  • Allocate stock for the variant
  • Use database transaction for atomicity
  • Snapshot variant price at time of purchase
  • Return order_id and purchase summary
  • Prevent ordering unavailable variants with descriptive error
  • Follow same patterns as cart checkout
post/buy-orders

Request

  • Base URL: /api/v2 (relative, and the document was published on a file host, not at the API’s origin)
  • URL: /api/v2/buy-orders
  • Auth: loggedin (a scheme the document does not define)

Request body

listing_idstring required

UUID of the listing to purchase from

variant_idstring required

UUID of the specific variant to purchase

quantitynumber double required

Quantity to purchase (must be > 0)

Response

Created order with order_id and purchase details

order_idstring required

UUID of the created order

buyer_idstring required

UUID of the buyer

seller_idstring required

UUID of the seller

total_pricenumber double required

Total price in aUEC (atomic units)

statusstring required

Order status

created_atstring required

ISO 8601 timestamp of order creation

Changes

    • ○

      the endpoint scheme security loggedin was added to the API

    • ○

      the endpoint scheme security jwt was removed from the API