{
  "openapi": "3.1.0",
  "info": {
    "title": "Granita merchant API",
    "version": "1.0.0",
    "description": "A provisioned pilot requires merchant authentication and explicit catalog, domain and delivery settings. The public example never creates a live inquiry."
  },
  "servers": [
    {
      "url": "/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "operator": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Firebase ID token"
      },
      "buyer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Scoped buyer session"
      }
    },
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "sku": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "sourceUrl": {
            "type": "string",
            "format": "uri"
          },
          "fetchedAt": {
            "type": "string"
          },
          "verification": {
            "type": "string"
          },
          "variantId": {
            "type": "string"
          },
          "cartEligible": {
            "type": "boolean"
          },
          "safetyReview": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "title",
          "unit",
          "sourceUrl",
          "fetchedAt"
        ]
      },
      "Line": {
        "type": "object",
        "properties": {
          "product": {
            "$ref": "#/components/schemas/Product"
          },
          "quantity": {
            "type": [
              "integer",
              "null"
            ]
          },
          "page": {
            "type": "integer"
          },
          "included": {
            "type": "boolean"
          },
          "evidence": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "product",
          "quantity",
          "page",
          "included",
          "evidence",
          "note"
        ]
      },
      "LineEdit": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "quantity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 99999
          },
          "included": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "quantity",
          "included"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "tenant": {
            "type": "object"
          }
        },
        "required": [
          "token",
          "tenant"
        ]
      },
      "Inquiry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "projectId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "source": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            }
          }
        },
        "required": [
          "id",
          "projectId",
          "title",
          "email",
          "source",
          "status",
          "lines"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    }
  },
  "paths": {
    "/runtime": {
      "get": {
        "summary": "Discover the current authentication and pilot configuration",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/embed/{slug}": {
      "get": {
        "summary": "Read the public installation settings",
        "security": [],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/sessions": {
      "post": {
        "summary": "Start a short-lived buyer session for a verified storefront",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "slug": {
                    "type": "string"
                  },
                  "parentOrigin": {
                    "type": "string"
                  }
                },
                "required": [
                  "slug",
                  "parentOrigin"
                ]
              }
            }
          }
        }
      }
    },
    "/projects": {
      "post": {
        "summary": "Upload a project PDF, at most 5 MB and 20 pages",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [],
        "responses": {
          "202": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "state"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        }
      }
    },
    "/projects/{id}": {
      "get": {
        "summary": "Poll processing state and read the current product list",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Cancel an unsubmitted project",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{id}/bom": {
      "patch": {
        "summary": "Save edits against the current revision",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "revision": {
                    "type": "integer"
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/LineEdit"
                    }
                  }
                },
                "required": [
                  "revision",
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/inquiries": {
      "post": {
        "summary": "Save a durable inquiry and queue configured destinations",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "type": "string"
                  },
                  "revision": {
                    "type": "integer"
                  },
                  "email": {
                    "type": "string"
                  },
                  "company": {
                    "type": "string"
                  },
                  "note": {
                    "type": "string"
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/LineEdit"
                    }
                  }
                },
                "required": [
                  "projectId",
                  "revision",
                  "email",
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/cart": {
      "post": {
        "summary": "Create an eligible cart handoff to the merchant store",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "projectId": {
                    "type": "string"
                  },
                  "revision": {
                    "type": "integer"
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/LineEdit"
                    }
                  }
                },
                "required": [
                  "projectId",
                  "revision",
                  "lines"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/workspace": {
      "get": {
        "summary": "Read the role-scoped merchant workspace",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/project-session": {
      "post": {
        "summary": "Start an internal sales project",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/catalog": {
      "put": {
        "summary": "Publish a reviewed catalog version",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "version": {
                    "type": "integer"
                  },
                  "products": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Product"
                    }
                  }
                },
                "required": [
                  "version",
                  "products"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/stock": {
      "put": {
        "summary": "Update product availability with optimistic concurrency",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string"
                  },
                  "revision": {
                    "type": "integer"
                  }
                },
                "required": [
                  "id",
                  "quantity",
                  "status",
                  "revision"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/settings": {
      "put": {
        "summary": "Configure branding, privacy, retention and launch gates",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        }
      }
    },
    "/admin/domains": {
      "post": {
        "summary": "Issue or verify a DNS website challenge",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string"
                  },
                  "verify": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "origin",
                  "verify"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/team": {
      "post": {
        "summary": "Grant or update a role for an existing identity",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "uid": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string"
                  }
                },
                "required": [
                  "uid",
                  "role"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/inquiries/{id}": {
      "patch": {
        "summary": "Update inquiry status, notes and owner",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "revision": {
                    "type": "integer"
                  },
                  "status": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "owner": {
                    "type": "string"
                  }
                },
                "required": [
                  "revision",
                  "status",
                  "notes",
                  "owner"
                ]
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Erase a merchant inquiry and schedule document deletion",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/connect/{kind}": {
      "post": {
        "summary": "Start OAuth or save verified connector settings",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Disconnect an external destination",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/deliveries/{id}/retry": {
      "post": {
        "summary": "Retry a failed delivery with a known receipt state",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/projects/{id}/pdf": {
      "get": {
        "summary": "Download a private source document while retained",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/catalog/versions": {
      "get": {
        "summary": "List published catalog versions",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/catalog/restore": {
      "post": {
        "summary": "Republish an earlier catalog snapshot",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "current": {
                    "type": "integer"
                  },
                  "restore": {
                    "type": "integer"
                  }
                },
                "required": [
                  "current",
                  "restore"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/stock/bulk": {
      "put": {
        "summary": "Atomically save up to 500 reviewed stock records",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "quantity": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "revision": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "id",
                        "quantity",
                        "status",
                        "revision"
                      ]
                    }
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/admin/stock/{id}/history": {
      "get": {
        "summary": "Read up to 25 recorded availability changes",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/processing": {
      "put": {
        "summary": "Set the approved function mapping and gated model policy",
        "security": [
          {
            "operator": []
          }
        ],
        "parameters": [
          {
            "name": "X-Merchant",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "aiEnabled": {
                    "type": "boolean"
                  },
                  "verifyDrawingCandidates": {
                    "type": "boolean"
                  },
                  "functions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "aiEnabled",
                  "verifyDrawingCandidates",
                  "functions"
                ]
              }
            }
          }
        }
      }
    },
    "/metrics": {
      "post": {
        "summary": "Increment an allowlisted consented anonymous event",
        "security": [
          {
            "buyer": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "Rejected request or unavailable service",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string"
                  },
                  "consent": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "event",
                  "consent"
                ]
              }
            }
          }
        }
      }
    }
  }
}
