{
  "openapi": "3.1.0",
  "info": {
    "title": "Ask Cold Front Boardshop for an offer",
    "version": "1.0.0",
    "description": "Ask the store for an offer on one of its products; on this API each offer comes with its own single-use discount code. On the web form at https://coldfrontboardshop.com/offer a code comes from Accept, with the box ticked to say the buyer agrees. Asking is free, nothing is bought or reserved, and no personal data is needed. Offers are set by the store, within limits it chose."
  },
  "servers": [
    {
      "url": "https://coldfrontboardshop.com"
    }
  ],
  "paths": {
    "/api/offers/options": {
      "get": {
        "operationId": "getOfferOptions",
        "summary": "Before you ask for an offer: the kinds of offer the store can make on a product",
        "description": "A read-only lookup. Names the kinds of offer open for the product, the list price, standard delivery and the priorities the store understands. It gives no amounts.",
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The product: its page URL on the store, its handle, a Shopify product or variant id, or its name."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What the store can offer on this product.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/offers/request": {
      "post": {
        "operationId": "requestOffer",
        "summary": "Ask for an offer: up to three concrete offers with exact totals, or the reason there are none",
        "description": "The same request always gets the same offers, and your_price does not change them. Each offer comes with its discount code (code), valid for 60 minutes, and a cart link that carries it (cart_url); code_expires_at is then the offer's one deadline, and it has no expires_at.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfferRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The offers, or the reason there are none.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfferReply"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "requestOfferByQuery",
        "summary": "Ask for an offer, with the fields as query parameters",
        "description": "For clients that can only send GET. Each offer comes with its discount code (code), valid for 60 minutes, and a cart link that carries it (cart_url); code_expires_at is then the offer's one deadline, and it has no expires_at.",
        "parameters": [
          {
            "name": "product",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The product: its page URL on the store, its handle, a Shopify product or variant id, or its name."
            }
          },
          {
            "name": "quantity",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 1
            }
          },
          {
            "name": "priority",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "lowest_price",
                "fast_delivery",
                "easy_returns",
                "extras",
                "repeat_purchase"
              ],
              "description": "What matters most to the buyer. Left out, the reply asks."
            }
          },
          {
            "name": "need_by_days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "minimum": 0,
              "description": "How many days from today the buyer can wait for delivery."
            }
          },
          {
            "name": "competing_offer_url",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uri",
              "description": "Another shop's public page for the same product, new and in stock, at a lower price. The store fetches it itself."
            }
          },
          {
            "name": "your_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 100000,
              "description": "your_price is the price per item the buyer would pay, before delivery and tax, in the product's currency: a number above 0 and up to 100000, with at most two decimals. Anything else is left out, with a note. It does not change the offers, which are the same with or without it. Each offer then says meets_your_price, true when its price per item after its price cut, before delivery, is at or below your_price; your_price_met says whether any offer does; and the first note gives the answer in words."
            }
          },
          {
            "name": "note",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "A short note for the merchant. It does not change the offer and is no place for personal details."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The offers, or the reason there are none.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfferReply"
                }
              }
            }
          }
        }
      }
    },
    "/api/offers/accept": {
      "post": {
        "operationId": "acceptOffer",
        "summary": "The discount code of an offer and the ways to use it",
        "description": "No order is placed and no payment is taken. The code is valid for 60 minutes. Accepting the same offer again returns the same code. Here an offer from a request already carries its code, and this returns that code.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AcceptRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The code and how to use it, or why none was issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AcceptReply"
                }
              }
            }
          }
        }
      }
    },
    "/api/offers/status": {
      "get": {
        "operationId": "getOfferStatus",
        "summary": "Where an offer stands",
        "parameters": [
          {
            "name": "offer_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Whether the offer is open, accepted or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "OfferRequest": {
        "type": "object",
        "required": [
          "product"
        ],
        "properties": {
          "product": {
            "type": "string",
            "description": "The product: its page URL on the store, its handle, a Shopify product or variant id, or its name."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 1
          },
          "priority": {
            "type": "string",
            "enum": [
              "lowest_price",
              "fast_delivery",
              "easy_returns",
              "extras",
              "repeat_purchase"
            ],
            "description": "What matters most to the buyer. Left out, the reply asks."
          },
          "need_by_days": {
            "type": "number",
            "minimum": 0,
            "description": "How many days from today the buyer can wait for delivery."
          },
          "competing_offer_url": {
            "type": "string",
            "format": "uri",
            "description": "Another shop's public page for the same product, new and in stock, at a lower price. The store fetches it itself."
          },
          "your_price": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 100000,
            "description": "your_price is the price per item the buyer would pay, before delivery and tax, in the product's currency: a number above 0 and up to 100000, with at most two decimals. Anything else is left out, with a note. It does not change the offers, which are the same with or without it. Each offer then says meets_your_price, true when its price per item after its price cut, before delivery, is at or below your_price; your_price_met says whether any offer does; and the first note gives the answer in words."
          },
          "note": {
            "type": "string",
            "description": "A short note for the merchant. It does not change the offer and is no place for personal details."
          }
        }
      },
      "Offer": {
        "type": "object",
        "properties": {
          "offer_id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "headline": {
            "type": "string"
          },
          "meets_your_price": {
            "type": "boolean",
            "description": "Given when the request had your_price: true when this offer's price per item, after its price cut and before delivery, is at or below it."
          },
          "meets_deadline": {
            "type": "boolean",
            "description": "Given when the request had need_by_days: false when this offer arrives later than that."
          },
          "components": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              }
            }
          },
          "quantity": {
            "type": "integer"
          },
          "unit_price": {
            "type": "number"
          },
          "items_total": {
            "type": "number"
          },
          "shipping_total": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "list_total": {
            "type": "number"
          },
          "you_save": {
            "type": "number"
          },
          "extras_value": {
            "type": "number"
          },
          "ship_days": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "description": "When the offer closes, for an offer without a code. An offer that carries a code has no expires_at: code_expires_at is its deadline."
          },
          "code": {
            "type": "string",
            "description": "The offer's single-use discount code. Using it at checkout takes this offer; one code applies per order."
          },
          "cart_url": {
            "type": "string",
            "description": "A cart with this offer's item and code."
          },
          "code_expires_at": {
            "type": "string",
            "description": "When the code stops working: the offer's one deadline when a code is attached."
          }
        }
      },
      "OfferReply": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "For example offer, price_matched, price_beaten, cannot_match_best_effort, no_offer, unavailable or slow_down."
          },
          "your_price": {
            "type": "number",
            "description": "The your_price that was read from the request, when one could be read."
          },
          "your_price_met": {
            "type": "boolean",
            "description": "Given with your_price: whether any offer reaches it. The first note says which, or names the closest offer."
          },
          "offers": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "$ref": "#/components/schemas/Offer"
            }
          },
          "question": {
            "type": [
              "object",
              "null"
            ],
            "description": "Asked when no priority was given: asking again with one of its options gets an offer built around it. Null when a priority was given, or when a verified lower price leaves the offers the same for every priority (proof.priority_matters is false); next then says so."
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "proof": {
            "type": [
              "object",
              "null"
            ],
            "description": "What the store found behind the competing-offer link. When it shows a lower price, priority_matters and deadline_matters say whether another priority, or another need_by_days, would change the offers."
          },
          "how_to_use": {
            "type": "string",
            "description": "How to use the codes that come with the offers."
          },
          "next": {
            "type": "string"
          }
        }
      },
      "AcceptRequest": {
        "type": "object",
        "required": [
          "offer_id",
          "user_approved"
        ],
        "properties": {
          "offer_id": {
            "type": "string",
            "description": "The offer_id of the chosen offer."
          },
          "user_approved": {
            "type": "boolean",
            "description": "true when the buyer has seen this offer and agreed to it. Here the code already came with the offer."
          }
        }
      },
      "AcceptReply": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "accepted: an offer from a request already carries its code."
          },
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cart_url": {
            "type": "string",
            "description": "Checkout link: a cart with codes, or a draft invoice with the quote already applied."
          },
          "settlement": {
            "type": "string",
            "enum": [
              "native",
              "function",
              "draft"
            ]
          },
          "invoice_url": {
            "type": "string",
            "description": "For draft settlement, use this quote checkout directly; codes is empty."
          },
          "alternatives": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Offer"
            },
            "description": "Different terms requiring fresh approval when the original offer is not deliverable."
          },
          "apply": {
            "type": "object",
            "description": "How to use the code: as a link, or in the browser on the store's site."
          },
          "terms": {
            "description": "Exact approved terms of the checkout offer."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null for draft invoices: no automatic quote expiry is claimed."
          },
          "after_purchase": {
            "type": "array",
            "description": "Parts of the offer that are attached to the order after it is placed."
          }
        }
      }
    }
  }
}
