{
  "swagger": "2.0",
  "info": {
    "title": "SpreadAPI",
    "description": "Run Excel spreadsheet calculations in your flows. SpreadAPI turns published Excel models into an API — send inputs, your formulas compute, results come back. Input fields are generated automatically from each service.",
    "version": "1.0.0",
    "contact": {
      "name": "SpreadAPI",
      "url": "https://spreadapi.io"
    }
  },
  "host": "spreadapi.io",
  "basePath": "/api/v1",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "service_token": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Enter your SpreadAPI service token prefixed with 'Bearer ', e.g. 'Bearer svc_tk_...'. Create a token in the service's API settings. Public services need no token."
    }
  },
  "security": [
    {
      "service_token": []
    }
  ],
  "paths": {
    "/services/{serviceId}/execute": {
      "post": {
        "operationId": "Calculate",
        "summary": "Calculate",
        "description": "Run a calculation in a published SpreadAPI service and return the computed outputs.",
        "x-ms-visibility": "important",
        "parameters": [
          {
            "name": "serviceId",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Service ID",
            "x-ms-url-encoding": "single",
            "description": "The ID of the published service. Find it in the service's Integration panel or in its URL."
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "required": [
                "inputs"
              ],
              "properties": {
                "inputs": {
                  "type": "object",
                  "x-ms-summary": "Inputs",
                  "description": "The service's input parameters (generated from the selected service).",
                  "x-ms-dynamic-schema": {
                    "operationId": "GetInputSchema",
                    "parameters": {
                      "serviceId": {
                        "parameter": "serviceId"
                      }
                    },
                    "value-path": "schema"
                  }
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calculation result",
            "schema": {
              "$ref": "#/definitions/ExecuteResponse"
            }
          },
          "400": {
            "description": "Invalid inputs — the message names the parameter and what is wrong"
          },
          "401": {
            "description": "Authentication required or token rejected"
          },
          "404": {
            "description": "Service not found or not published"
          }
        }
      }
    },
    "/services/{serviceId}/input-schema": {
      "get": {
        "operationId": "GetInputSchema",
        "summary": "Get input schema",
        "description": "Returns the service's input parameters as a JSON Schema. Used internally to render the Calculate action's input fields.",
        "x-ms-visibility": "internal",
        "parameters": [
          {
            "name": "serviceId",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Service ID",
            "x-ms-url-encoding": "single"
          }
        ],
        "responses": {
          "200": {
            "description": "Input schema",
            "schema": {
              "type": "object",
              "properties": {
                "schema": {
                  "type": "object",
                  "description": "JSON Schema of the service inputs"
                }
              }
            }
          }
        }
      }
    }
  },
  "definitions": {
    "ExecuteResponse": {
      "type": "object",
      "properties": {
        "service": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "x-ms-summary": "Service ID"
            },
            "name": {
              "type": "string",
              "x-ms-summary": "Service name"
            }
          }
        },
        "outputs": {
          "type": "array",
          "x-ms-summary": "Outputs",
          "description": "The calculated output values.",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "x-ms-summary": "Output name"
              },
              "title": {
                "type": "string",
                "x-ms-summary": "Output label"
              },
              "value": {
                "x-ms-summary": "Value"
              }
            }
          }
        },
        "metadata": {
          "type": "object",
          "properties": {
            "executionTime": {
              "type": "integer",
              "x-ms-summary": "Execution time (ms)"
            },
            "cached": {
              "type": "boolean",
              "x-ms-summary": "From cache"
            }
          }
        }
      }
    }
  },
  "x-ms-connector-metadata": [
    {
      "propertyName": "Website",
      "propertyValue": "https://spreadapi.io"
    },
    {
      "propertyName": "Privacy policy",
      "propertyValue": "https://airrange.io/privacy-policy"
    },
    {
      "propertyName": "Categories",
      "propertyValue": "Data;Productivity"
    }
  ]
}
