{
    "openapi": "3.1.0",
    "info": {
        "title": "Batch Dispatch wholesale API",
        "version": "1.0.0",
        "description": "Batch Dispatch is a wholesale marketplace: bulk stock direct from suppliers, sold by the piece, kg or bale. Flow: search_lots \u2192 get_lot \u2192 get_quote (exact delivered price, shows blockers) \u2192 confirm with the buyer \u2192 create_order \u2192 give the buyer each pay_url. Agents never pay; the buyer pays by card and the money is held until they confirm the goods arrived as described. Suppliers pay no commission; buyers pay a 5% buyer protection fee, shown in get_quote. Respect each lot's moq and each supplier's minimum order. If nothing fits, use request_stock."
    },
    "servers": [
        {
            "url": "https://batchdispatch.com/wp-json/bd/v1"
        }
    ],
    "paths": {
        "/agent/search": {
            "get": {
                "operationId": "search_lots",
                "summary": "Search live wholesale lots (bulk stock: clothing by the kg or piece, bales, returns, electronics and more). Returns price per unit, minimum order (moq), stock, supplier country and link.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Plain-English error in `message`"
                    }
                },
                "parameters": [
                    {
                        "name": "query",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "description": "Free text, e.g. \"carhartt jackets\" or \"grade A jeans\""
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "grade",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "brand",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "max_unit_price",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "number"
                        }
                    },
                    {
                        "name": "currency",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "description": "ISO code the buyer thinks in; adds an approximate converted price"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ]
            }
        },
        "/agent/categories": {
            "get": {
                "operationId": "list_categories",
                "summary": "What is in stock now: live lot count by category, grade and brand.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Plain-English error in `message`"
                    }
                },
                "parameters": []
            }
        },
        "/agent/quote": {
            "post": {
                "operationId": "get_quote",
                "summary": "Exact delivered price before ordering, per supplier: goods, carriage, VAT, the 5% buyer protection fee and total, plus anything blocking the order (supplier minimum, sold out). Creates nothing.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Plain-English error in `message`"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "items",
                                    "country"
                                ],
                                "properties": {
                                    "items": {
                                        "type": "array",
                                        "minItems": 1,
                                        "items": {
                                            "type": "object",
                                            "required": [
                                                "listing_id",
                                                "qty"
                                            ],
                                            "properties": {
                                                "listing_id": {
                                                    "type": "integer"
                                                },
                                                "qty": {
                                                    "type": "integer",
                                                    "minimum": 1,
                                                    "description": "Units of the lot's unit (piece, kg, bale...). At least its moq."
                                                }
                                            }
                                        }
                                    },
                                    "country": {
                                        "type": "string",
                                        "description": "Delivery country, ISO 3166 alpha-2, e.g. GB, DE, US"
                                    },
                                    "email": {
                                        "type": "string",
                                        "description": "Optional buyer email; applies their no-fee referral pairs"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/agent/order": {
            "post": {
                "operationId": "create_order",
                "summary": "Place the order for a human buyer and get one pay link per supplier. The buyer opens pay_url and pays by card on Stripe; agents cannot pay. Money is held until the buyer confirms the goods arrived. Unpaid orders expire after 24 hours and hold no stock. Confirm the get_quote total with the buyer first.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Plain-English error in `message`"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "items",
                                    "email",
                                    "name",
                                    "address",
                                    "country"
                                ],
                                "properties": {
                                    "items": {
                                        "type": "array",
                                        "minItems": 1,
                                        "items": {
                                            "type": "object",
                                            "required": [
                                                "listing_id",
                                                "qty"
                                            ],
                                            "properties": {
                                                "listing_id": {
                                                    "type": "integer"
                                                },
                                                "qty": {
                                                    "type": "integer",
                                                    "minimum": 1,
                                                    "description": "Units of the lot's unit (piece, kg, bale...). At least its moq."
                                                }
                                            }
                                        }
                                    },
                                    "email": {
                                        "type": "string",
                                        "description": "Buyer email; receipts and tracking go here"
                                    },
                                    "name": {
                                        "type": "string",
                                        "description": "Buyer or business name"
                                    },
                                    "address": {
                                        "type": "string",
                                        "description": "Full delivery address including postcode"
                                    },
                                    "country": {
                                        "type": "string",
                                        "description": "ISO 3166 alpha-2"
                                    },
                                    "agent": {
                                        "type": "string",
                                        "description": "Name of your agent or app, for our records"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/agent/order-status": {
            "post": {
                "operationId": "get_order_status",
                "summary": "Status of an order (confirmed = awaiting payment, paid, completed). Needs the order reference and the buyer email.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Plain-English error in `message`"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "reference",
                                    "email"
                                ],
                                "properties": {
                                    "reference": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/agent/request": {
            "post": {
                "operationId": "request_stock",
                "summary": "Ask us to find stock the catalogue does not show. We contact matching wholesale suppliers and email their offers to the buyer.",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Plain-English error in `message`"
                    }
                },
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "email",
                                    "description"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string",
                                        "description": "What, which grade or condition, any brands"
                                    },
                                    "quantity": {
                                        "type": "string",
                                        "description": "e.g. \"500kg a month\" or \"3 bales\""
                                    },
                                    "budget": {
                                        "type": "string",
                                        "description": "e.g. \"\u00a34/kg\""
                                    },
                                    "country": {
                                        "type": "string",
                                        "description": "Delivery country, ISO 3166 alpha-2"
                                    },
                                    "agent": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/listings/{id}": {
            "get": {
                "operationId": "get_lot",
                "summary": "Full details of one lot: description, photos and video, grade, pieces, weight, moq, minimum spend, stock, supplier.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    }
}