{
  "openapi": "3.1.0",
  "info": {
    "title": "DeadlineSF API",
    "version": "1.0.0",
    "description": "Free AB 2013 patch and Scan checkout for AI agents and people. Not legal advice.",
    "contact": {
      "email": "info@deadlinesf.net"
    }
  },
  "servers": [
    {
      "url": "https://deadlinesf.net"
    }
  ],
  "paths": {
    "/catalog.json": {
      "get": {
        "operationId": "getCatalog",
        "summary": "Price catalog",
        "responses": {
          "200": {
            "description": "Packages and prices (USD cents)"
          }
        }
      }
    },
    "/scan-deliverable.json": {
      "get": {
        "operationId": "getScanDeliverable",
        "summary": "What the $3,500 Scan delivers",
        "responses": {
          "200": {
            "description": "Scan scope, deliverables, turnaround and how to buy"
          }
        }
      }
    },
    "/systems-deliverable.json": {
      "get": {
        "operationId": "getSystemsDeliverable",
        "summary": "What the $50,000 Systems engagement delivers",
        "responses": {
          "200": {
            "description": "Systems scope, deliverables and how to buy"
          }
        }
      }
    },
    "/everything-deliverable.json": {
      "get": {
        "operationId": "getEverythingDeliverable",
        "summary": "What the $120,000 Everything package delivers",
        "responses": {
          "200": {
            "description": "Everything scope, deliverables and how to buy"
          }
        }
      }
    },
    "/api/free-patch": {
      "get": {
        "operationId": "getPatchFields",
        "summary": "\u00a7 3111(a)(1)-(12) field list",
        "responses": {
          "200": {
            "description": "Fields",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "application/vnd.cyclonedx+json": {
                "schema": {
                  "type": "object",
                  "description": "CycloneDX 1.6 BOM",
                  "externalDocs": {
                    "url": "https://cyclonedx.org/docs/1.6/json/"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "cyclonedx = CycloneDX 1.6 ML-BOM",
            "schema": {
              "type": "string",
              "enum": [
                "cyclonedx"
              ]
            }
          }
        ]
      },
      "post": {
        "operationId": "requestFreePatch",
        "summary": "Build a free AB 2013 (Cal. Civ. Code \u00a7 3111) patch",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Patch HTML, missing fields, evidence hints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "application/vnd.cyclonedx+json": {
                "schema": {
                  "type": "object",
                  "description": "CycloneDX 1.6 BOM",
                  "externalDocs": {
                    "url": "https://cyclonedx.org/docs/1.6/json/"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad input"
          }
        },
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "cyclonedx = CycloneDX 1.6 ML-BOM",
            "schema": {
              "type": "string",
              "enum": [
                "cyclonedx"
              ]
            }
          }
        ]
      }
    },
    "/api/create-checkout": {
      "post": {
        "operationId": "createCheckout",
        "summary": "Start checkout. ui_mode hosted returns a Stripe-hosted URL for agents.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hosted: { url, id, package, amount, currency, mode, expires_at, repo_url, next_steps }. Embedded: { clientSecret, publishableKey, mode }"
          },
          "400": {
            "description": "Unknown package"
          }
        }
      }
    },
    "/api/checkout-status": {
      "get": {
        "operationId": "checkoutStatus",
        "summary": "Poll after payment.",
        "parameters": [
          {
            "name": "session_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "{ paid, product, repo_on_file }"
          }
        }
      }
    },
    "/api/scan-repo": {
      "post": {
        "operationId": "scanRepo",
        "summary": "Add the repository to a paid Scan with none on file. https URL; never replaces one on file.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "session_id",
                  "repo_url"
                ],
                "properties": {
                  "session_id": {
                    "type": "string",
                    "pattern": "^cs_(live|test)_[A-Za-z0-9]{10,200}$"
                  },
                  "repo_url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 255
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, repo_on_file }"
          },
          "400": {
            "description": "Bad session_id or repo_url"
          },
          "402": {
            "description": "Not paid"
          },
          "403": {
            "description": "Not a Scan"
          },
          "409": {
            "description": "Repository already on file"
          },
          "429": {
            "description": "Too many tries"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcp",
        "summary": "MCP server (Streamable HTTP, JSON-RPC 2.0). Tools: get_catalog, request_free_patch, start_scan_checkout, check_scan_status, submit_scan_repo, get_ab2013_checklist.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response"
          },
          "202": {
            "description": "Notification accepted"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PatchRequest": {
        "type": "object",
        "properties": {
          "developer": {
            "type": "string"
          },
          "system": {
            "type": "string"
          },
          "contact": {
            "type": "string"
          },
          "answers": {
            "type": "object",
            "description": "Keys: field id (e.g. ctl-synthetic-data) or (a)(n)",
            "additionalProperties": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          },
          "repo_url": {
            "type": "string",
            "description": "Public https://github.com/<owner>/<repo>"
          },
          "format": {
            "type": "string",
            "enum": [
              "standalone",
              "fragment",
              "cyclonedx"
            ]
          }
        }
      },
      "CheckoutRequest": {
        "type": "object",
        "required": [
          "package"
        ],
        "properties": {
          "package": {
            "type": "string",
            "enum": [
              "scan_3500",
              "systems_50000",
              "everything_120000"
            ]
          },
          "ui_mode": {
            "type": "string",
            "enum": [
              "hosted",
              "embedded"
            ],
            "default": "embedded"
          },
          "customer_email": {
            "type": "string",
            "format": "email"
          },
          "repo_url": {
            "type": "string",
            "format": "uri",
            "description": "Scan: repository URL (pre-fills checkout)"
          }
        }
      }
    }
  }
}
