{
 "openapi": "3.1.0",
 "info": {
  "title": "Phoenix Nest Firewood agent API",
  "version": "1.0.0",
  "description": "Quote, order, pick a delivery time, ask for a callback and check an order for seasoned firewood from Phoenix Nest, in Greenup, Kentucky and the surrounding Tri-State (KY, OH, WV). No account or key. Orders are confirmed at once and Phoenix Nest texts every customer afterwards. Alex at Phoenix Nest looks at every order and will call or text if anything needs further attention. Pay by card with the pay_url link, or cash on delivery. Repeat the message from a placed order, an order status, a quote or a contact answer to the customer word for word. Other messages are for you."
 },
 "servers": [
  {
   "url": "https://www.firewood.ltd/api/agent/v1"
  }
 ],
 "paths": {
  "/": {
   "get": {
    "operationId": "index",
    "summary": "This API: its routes and where the other documents are",
    "responses": {
     "200": {
      "description": "The index.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Index"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/products": {
   "get": {
    "operationId": "listProducts",
    "summary": "The catalog",
    "description": "Every product on sale, with its slug, description and pickup price. Use the slug in quote and order requests.",
    "responses": {
     "200": {
      "description": "The catalog.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Catalog"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Not available right now (code unavailable): pickup or delivery prices could not be read. Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/quote": {
   "get": {
    "operationId": "quoteGet",
    "summary": "Prices for an address or for pickup (query parameters)",
    "description": "The same quote as POST /quote, for readers that can only open a link. Give street, city, state and zip, or pickup=1. Delivery prices include delivery to the address. in_area false means we do not deliver there (still HTTP 200). Each price row has checkout_url: give it to the customer, who finishes at checkout. Opening it orders nothing. The same answer as text: GET /quote.txt with the same parameters (on the site root).",
    "responses": {
     "200": {
      "description": "Prices, or in_area false.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Quote"
        }
       }
      }
     },
     "400": {
      "description": "pickup is not 1, 0, true or false (code bad_request).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "A field is missing or wrong (code invalid).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Not available right now (code unavailable): pickup or delivery prices could not be read. Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "street",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "Delivery street address. Required unless pickup=1."
     },
     {
      "name": "city",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "state",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "2-letter state code, such as KY."
     },
     {
      "name": "zip",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "5-digit ZIP code."
     },
     {
      "name": "pickup",
      "in": "query",
      "required": false,
      "schema": {
       "enum": [
        "1",
        "0",
        "true",
        "false"
       ]
      },
      "description": "1 for pickup at the yard (no address). Absent or 0 means delivery."
     }
    ]
   },
   "post": {
    "operationId": "quote",
    "summary": "Prices for an address or for pickup",
    "description": "Delivery prices include delivery to the address. in_area false means we do not deliver there (still HTTP 200). For pickup send {\"pickup\": true}. Each price row has checkout_url, an order link for the customer (null for accessories, which are added at checkout). The same quote is GET /quote with query parameters.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/QuoteRequest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Prices, or in_area false.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Quote"
        }
       }
      }
     },
     "400": {
      "description": "Not JSON, not an object, wrong Content-Type, over 16 KB, or pickup is neither a JSON boolean nor null (code bad_request).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "A field is missing or wrong (code invalid).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "Not available right now (code unavailable): pickup or delivery prices could not be read. Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/delivery-times": {
   "get": {
    "operationId": "deliveryTimes",
    "summary": "Delivery or pickup times open now",
    "description": "Offer these to the customer and pass the chosen one as delivery_slot when ordering. An empty times list means a time cannot be booked in the chat: place the order anyway and Phoenix Nest texts a link to pick one.",
    "parameters": [
     {
      "name": "fulfilment",
      "in": "query",
      "required": true,
      "schema": {
       "enum": [
        "delivery",
        "pickup"
       ]
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The open times.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DeliveryTimes"
        }
       }
      }
     },
     "422": {
      "description": "A field is missing or wrong (code invalid).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/orders": {
   "post": {
    "operationId": "placeOrder",
    "summary": "Place an order",
    "description": "One firewood item (quantity 1), optional fire starter accessories and an optional delivery_slot. The order is confirmed at once. Pay by card with pay_url, or cash on delivery. Phoenix Nest texts the customer, with a link to pick a time if none was picked or the picked time could not be held. A phone number can have one open order at a time: a second attempt answers 409 duplicate_open_order with the existing reference. A 503 (code unavailable) means the order was not placed. A 500 (code server_error) can come after the order was placed: do not place it again. Have the customer call or text (606) 644-9876. On 422 out_of_area Phoenix Nest already has the customer's details (details_sent true): do not also send them with /contact.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/OrderRequest"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Order confirmed.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Order"
        }
       }
      }
     },
     "400": {
      "description": "Not JSON, not an object, wrong Content-Type, or over 16 KB (code bad_request).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "This phone number already has an open order (code duplicate_open_order, with its reference).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "A field is wrong (code invalid), or the address is outside the service area (code out_of_area, with details_sent true: Phoenix Nest already has the customer's name, phone and address).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). The order may have been placed. Do not place it again; call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "503": {
      "description": "The order was not placed (code unavailable). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/orders/{reference}": {
   "get": {
    "operationId": "orderStatus",
    "summary": "Status of an order",
    "description": "Found by reference and the phone number it was placed with. A wrong phone and an unknown reference give the same 404.",
    "parameters": [
     {
      "name": "reference",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "phone",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The order status.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/OrderStatus"
        }
       }
      }
     },
     "404": {
      "description": "No order matches (code not_found).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "A field is missing or wrong (code invalid).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/contact": {
   "post": {
    "operationId": "contact",
    "summary": "Ask Phoenix Nest to text or call back",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ContactRequest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Received.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ContactReceipt"
        }
       }
      }
     },
     "400": {
      "description": "Not JSON, not an object, wrong Content-Type, or over 16 KB (code bad_request).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "A field is missing or wrong (code invalid).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited (code rate_limited).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "Server error (code server_error). Call or text Phoenix Nest.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Address": {
    "type": "object",
    "required": [
     "street",
     "city",
     "state",
     "zip"
    ],
    "properties": {
     "street": {
      "type": "string"
     },
     "city": {
      "type": "string"
     },
     "state": {
      "type": "string",
      "description": "2-letter code",
      "examples": [
       "KY"
      ]
     },
     "zip": {
      "type": "string",
      "description": "5 digits"
     }
    }
   },
   "Catalog": {
    "type": "object",
    "properties": {
     "products": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "slug": {
         "type": "string",
         "examples": [
          "cord-mixed"
         ]
        },
        "name": {
         "type": "string"
        },
        "description": {
         "type": "string"
        },
        "fulfilment": {
         "type": "array",
         "items": {
          "enum": [
           "pickup",
           "delivery"
          ]
         }
        },
        "pickup_price": {
         "type": [
          "number",
          "null"
         ]
        }
       }
      }
     },
     "split_line": {
      "type": [
       "string",
       "null"
      ]
     },
     "service_area": {
      "type": "string"
     },
     "phone": {
      "type": "string"
     }
    }
   },
   "QuoteRequest": {
    "type": "object",
    "description": "address is required unless pickup is true. pickup is a JSON boolean or null (null or absent means false).",
    "properties": {
     "address": {
      "$ref": "#/components/schemas/Address"
     },
     "pickup": {
      "type": [
       "boolean",
       "null"
      ],
      "description": "true for pickup; false, null or absent for delivery."
     }
    }
   },
   "Quote": {
    "type": "object",
    "properties": {
     "in_area": {
      "type": "boolean"
     },
     "fulfilment": {
      "enum": [
       "pickup",
       "delivery"
      ]
     },
     "prices": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "slug": {
         "type": "string"
        },
        "name": {
         "type": "string"
        },
        "price": {
         "type": "number"
        },
        "checkout_url": {
         "type": [
          "string",
          "null"
         ],
         "description": "An order link for this product, quantity 1, at this address or for pickup: a page with the price and a \"Continue to checkout\" button. Give it to the customer. Opening it orders nothing. Null for accessories."
        }
       }
      }
     },
     "message": {
      "type": "string"
     }
    }
   },
   "Index": {
    "type": "object",
    "properties": {
     "name": {
      "type": "string"
     },
     "version": {
      "type": "string"
     },
     "openapi": {
      "type": "string",
      "format": "uri"
     },
     "mcp": {
      "type": "string",
      "format": "uri"
     },
     "llms_txt": {
      "type": "string",
      "format": "uri"
     },
     "routes": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "method": {
         "type": "string"
        },
        "path": {
         "type": "string"
        },
        "summary": {
         "type": "string"
        }
       }
      }
     }
    }
   },
   "Time": {
    "type": "object",
    "properties": {
     "date": {
      "type": "string",
      "format": "date"
     },
     "slot_key": {
      "type": "string"
     },
     "label": {
      "type": "string",
      "examples": [
       "Friday, December 12, 8-10 AM"
      ]
     }
    }
   },
   "DeliveryTimes": {
    "type": "object",
    "properties": {
     "times": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Time"
      }
     },
     "message": {
      "type": "string"
     }
    }
   },
   "OrderRequest": {
    "type": "object",
    "required": [
     "customer",
     "fulfilment",
     "product"
    ],
    "properties": {
     "customer": {
      "type": "object",
      "required": [
       "name",
       "phone"
      ],
      "properties": {
       "name": {
        "type": "string"
       },
       "phone": {
        "type": "string",
        "description": "US number with area code"
       },
       "email": {
        "type": "string"
       }
      }
     },
     "fulfilment": {
      "enum": [
       "delivery",
       "pickup"
      ]
     },
     "address": {
      "$ref": "#/components/schemas/Address"
     },
     "product": {
      "type": "string",
      "description": "A firewood slug from /products, such as cord-mixed."
     },
     "accessories": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "slug",
        "quantity"
       ],
       "properties": {
        "slug": {
         "type": "string",
         "description": "An accessory slug from /products, such as acc-102."
        },
        "quantity": {
         "type": "integer",
         "minimum": 1,
         "maximum": 10
        }
       }
      }
     },
     "delivery_slot": {
      "type": "object",
      "required": [
       "date",
       "slot_key"
      ],
      "description": "One of the times from /delivery-times.",
      "properties": {
       "date": {
        "type": "string",
        "format": "date"
       },
       "slot_key": {
        "type": "string"
       }
      }
     },
     "notes": {
      "type": "string",
      "maxLength": 2000
     },
     "agent": {
      "type": "string",
      "maxLength": 100,
      "description": "Name of the calling agent."
     }
    }
   },
   "Order": {
    "type": "object",
    "properties": {
     "reference": {
      "type": "string"
     },
     "status": {
      "const": "confirmed"
     },
     "fulfilment": {
      "enum": [
       "delivery",
       "pickup"
      ]
     },
     "items": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "slug": {
         "type": "string"
        },
        "name": {
         "type": "string"
        },
        "price": {
         "type": "number"
        }
       }
      }
     },
     "total": {
      "type": "number"
     },
     "pay_url": {
      "type": "string",
      "format": "uri",
      "description": "Pay by card now. Cash on delivery is the alternative."
     },
     "delivery_time": {
      "type": [
       "object",
       "null"
      ],
      "description": "The time booked from delivery_slot, status requested; null when none was asked for or the time could not be held (then Phoenix Nest texts a link to pick one; do not offer other times or place the order again).",
      "properties": {
       "date": {
        "type": "string"
       },
       "slot_key": {
        "type": "string"
       },
       "label": {
        "type": "string"
       },
       "status": {
        "type": "string"
       }
      }
     },
     "message": {
      "type": "string"
     }
    }
   },
   "OrderStatus": {
    "type": "object",
    "properties": {
     "reference": {
      "type": "string"
     },
     "status": {
      "enum": [
       "awaiting_confirmation",
       "confirmed",
       "delivered",
       "cancelled"
      ]
     },
     "scheduled_date": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "message": {
      "type": "string"
     }
    }
   },
   "ContactRequest": {
    "type": "object",
    "required": [
     "name",
     "phone",
     "message"
    ],
    "properties": {
     "name": {
      "type": "string"
     },
     "phone": {
      "type": "string"
     },
     "email": {
      "type": "string"
     },
     "message": {
      "type": "string",
      "maxLength": 2000
     },
     "address": {
      "$ref": "#/components/schemas/Address"
     }
    }
   },
   "ContactReceipt": {
    "type": "object",
    "properties": {
     "received": {
      "type": "boolean"
     },
     "message": {
      "type": "string"
     }
    }
   },
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "description": "Every error: {\"error\": {\"code\", \"message\"}}, plus extra fields for some codes.",
    "properties": {
     "error": {
      "type": "object",
      "required": [
       "code",
       "message"
      ],
      "properties": {
       "code": {
        "enum": [
         "bad_request",
         "invalid",
         "not_found",
         "out_of_area",
         "duplicate_open_order",
         "rate_limited",
         "unavailable",
         "server_error"
        ]
       },
       "message": {
        "type": "string"
       },
       "reference": {
        "type": "string",
        "description": "duplicate_open_order only."
       },
       "details_sent": {
        "type": "boolean",
        "description": "out_of_area on /orders only: Phoenix Nest already has the customer's details."
       }
      }
     }
    }
   }
  }
 }
}