{
  "openapi": "3.1.0",
  "info": {
    "title": "Stitch Monkeys order requests",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://new.stitchmonkeys.com"
    }
  ],
  "paths": {
    "/api/orders": {
      "post": {
        "summary": "Validate or submit an order request with customer permission",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "validate"
              ]
            },
            "description": "validate checks fields without saving or contacting HQ."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Valid request; validation only."
          },
          "201": {
            "description": "Saved in HQ. A private 90-day token is returned; do not disclose it publicly.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "reference": {
                      "type": "string"
                    },
                    "statusToken": {
                      "type": "string"
                    },
                    "checkoutEligible": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation errors, each with field and message."
          },
          "409": {
            "description": "Request ID reused for different content or processing conflict."
          },
          "503": {
            "description": "Intake not configured. Nothing was confirmed saved."
          }
        }
      },
      "get": {
        "summary": "Read one private request",
        "security": [
          {
            "orderToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Public-safe request status, no internal notes or contact data."
          },
          "401": {
            "description": "Invalid or expired private token."
          }
        }
      }
    },
    "/api/offers": {
      "get": {
        "summary": "List approved fixed packages, never research prices",
        "responses": {
          "200": {
            "description": "Products eligible for checkout. May be empty."
          }
        }
      }
    },
    "/api/payment": {
      "post": {
        "summary": "Get or refresh an accept.blue invoice for an eligible saved order",
        "security": [
          {
            "orderToken": []
          }
        ],
        "description": "Customer permission required. Creates a payment invoice but never charges a card. Customer follows the returned HTTPS payment URL. Custom quote requests are rejected.",
        "responses": {
          "200": {
            "description": "Payment link and gateway-verified status."
          },
          "409": {
            "description": "Review required or payment creation pending."
          },
          "503": {
            "description": "Payment not configured."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "OrderRequest": {
        "type": "object",
        "required": [
          "requestId",
          "service",
          "quantity",
          "contact",
          "consent",
          "delivery"
        ],
        "properties": {
          "requestId": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9-]{16,80}$",
            "description": "Stable unique ID. Reuse on identical retries; use a new ID if details change."
          },
          "service": {
            "type": "string",
            "enum": [
              "embroidery",
              "patches",
              "dtf",
              "screen-printing",
              "promo",
              "unsure",
              "cart"
            ]
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100000
          },
          "contact": {
            "type": "object",
            "required": [
              "name",
              "email"
            ],
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 200
              },
              "email": {
                "type": "string",
                "maxLength": 200,
                "format": "email"
              },
              "phone": {
                "type": "string",
                "maxLength": 200
              },
              "company": {
                "type": "string",
                "maxLength": 200
              }
            }
          },
          "consent": {
            "type": "boolean",
            "const": true
          },
          "deadline": {
            "type": "string",
            "format": "date"
          },
          "deadlineUnknown": {
            "type": "boolean"
          },
          "delivery": {
            "type": "string",
            "enum": [
              "pickup",
              "shipping"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "shop",
              "own",
              "mixed"
            ]
          },
          "dtfFormat": {
            "type": "string",
            "enum": [
              "finished",
              "transfers"
            ]
          },
          "patchType": {
            "type": "string",
            "enum": [
              "Embroidered",
              "Woven",
              "PVC",
              "Leather",
              "Chenille",
              "Sublimated",
              "Help me choose"
            ]
          },
          "backing": {
            "type": "string",
            "enum": [
              "Sew-on",
              "Iron-on",
              "Hook-and-loop",
              "Help me choose"
            ]
          },
          "dimensionsUnknown": {
            "type": "boolean"
          },
          "width": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 48
          },
          "height": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 48
          },
          "items": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "id",
                "quantity"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000
                }
              }
            }
          },
          "artwork": {
            "type": "object",
            "required": [
              "name",
              "base64"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "mime": {
                "type": "string"
              },
              "base64": {
                "type": "string",
                "contentEncoding": "base64",
                "description": "PNG, JPG, WebP or PDF. Decoded limit 2 MB. Content type is checked by HQ."
              }
            }
          },
          "itemNotes": {
            "type": "string",
            "maxLength": 2000
          },
          "placement": {
            "type": "string",
            "maxLength": 2000
          },
          "sizes": {
            "type": "string",
            "maxLength": 2000
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "shippingAddress": {
            "type": "string",
            "maxLength": 2000
          },
          "application": {
            "type": "string",
            "maxLength": 2000
          },
          "threadNotes": {
            "type": "string",
            "maxLength": 2000
          },
          "inkColors": {
            "type": "string",
            "maxLength": 2000
          }
        },
        "description": "Additional service-dependent requirements are returned as structured field errors by validate. Patch minimum 25, screen printing minimum 12. Explicitly specify a future deadline or deadlineUnknown=true. Shipping requires shippingAddress. Apparel needs itemNotes, source and placement. Patches need patchType, backing and dimensions or dimensionsUnknown=true. DTF needs dtfFormat."
      }
    },
    "securitySchemes": {
      "orderToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Per-order private token returned by submission."
      }
    }
  }
}