{
  "openapi": "3.1.0",
  "info": {
    "title": "Data Figure Studio API",
    "version": "1.0.0",
    "description": "Compose publication-ready multi-panel scientific figures: aligned-grid layout engine with axis-line alignment and plot-area matching, plus Pro purchases via PayPal. The MCP endpoint at /api/mcp exposes the same capabilities as tools."
  },
  "servers": [
    {
      "url": "https://data-figure-studio.vercel.app"
    }
  ],
  "paths": {
    "/api/pricing": {
      "get": {
        "summary": "Live pricing and payment configuration status",
        "responses": {
          "200": {
            "description": "Pricing object",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/compose": {
      "post": {
        "summary": "Compose a figure layout from panel dimensions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "panels"
                ],
                "properties": {
                  "panels": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 52,
                    "items": {
                      "type": "object",
                      "required": [
                        "w",
                        "h"
                      ],
                      "properties": {
                        "w": {
                          "type": "number"
                        },
                        "h": {
                          "type": "number"
                        },
                        "axes": {
                          "type": "object",
                          "properties": {
                            "ax": {
                              "type": "number"
                            },
                            "ay": {
                              "type": "number"
                            },
                            "l": {
                              "type": "number"
                            },
                            "t": {
                              "type": "number"
                            },
                            "r": {
                              "type": "number"
                            },
                            "b": {
                              "type": "number"
                            }
                          }
                        }
                      }
                    }
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "width": {
                        "type": "number",
                        "default": 180
                      },
                      "gap": {
                        "type": "number"
                      },
                      "margin": {
                        "type": "number"
                      },
                      "font": {
                        "type": "number"
                      },
                      "columns": {
                        "type": "integer",
                        "default": 0
                      },
                      "scaling": {
                        "type": "string",
                        "enum": [
                          "plot",
                          "uniform"
                        ]
                      },
                      "alignAxes": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Figure geometry in millimetres",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "width": {
                      "type": "number"
                    },
                    "height": {
                      "type": "number"
                    },
                    "panels": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "pro": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/api/mcp": {
      "get": {
        "summary": "MCP server info (tools list summary)",
        "responses": {
          "200": {
            "description": "Server info JSON"
          }
        }
      },
      "post": {
        "summary": "MCP JSON-RPC endpoint (protocol 2024-11-05). Tools: compose_figure, get_pricing, create_paypal_checkout, capture_paypal_purchase.",
        "responses": {
          "200": {
            "description": "JSON-RPC response"
          }
        }
      }
    },
    "/api/create-paypal-order": {
      "post": {
        "summary": "Create a PayPal Checkout order for the Pro High-Res Pass",
        "responses": {
          "200": {
            "description": "{ url (approve link), id (order id) }"
          },
          "501": {
            "description": "paypal_not_configured"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pack": {
                    "type": "string",
                    "enum": [
                      "p1",
                      "p4",
                      "p10"
                    ],
                    "default": "p1",
                    "description": "Credit pack: p1 = 1 figure $0.99, p4 = 4 figures $2.99, p10 = 10 figures $5.99. Prices are fixed server-side."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/capture-paypal-order": {
      "post": {
        "summary": "Capture an approved PayPal order; returns the 7-day unlock token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "order_id"
                ],
                "properties": {
                  "order_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{ ok, exp, token }"
          }
        }
      }
    },
    "/api/create-usdc-order": {
      "post": {
        "summary": "Create a USDC payment order (Solana or Ethereum) for a credit pack",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "chain",
                  "pack"
                ],
                "properties": {
                  "chain": {
                    "type": "string",
                    "enum": [
                      "solana",
                      "ethereum"
                    ]
                  },
                  "pack": {
                    "type": "string",
                    "enum": [
                      "p1",
                      "p4",
                      "p10"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Order with HMAC order_token; Solana orders include a solana_pay_url + reference"
          }
        }
      }
    },
    "/api/usdc-solana-tx": {
      "post": {
        "summary": "Build the unsigned Solana USDC payment transaction for an order (buyer signs in Phantom)",
        "responses": {
          "200": {
            "description": "{ transaction: base64 unsigned transaction, reference }"
          }
        }
      }
    },
    "/api/verify-usdc-order": {
      "post": {
        "summary": "Verify a USDC payment on-chain and issue the credit token",
        "responses": {
          "200": {
            "description": "{ ok, credits, token, exp, tx } or { ok:false, pending:true, error }"
          }
        }
      }
    }
  }
}
