{
  "openapi": "3.1.0",
  "info": {
    "title": "Fliinow Simulator API",
    "version": "1.0.0",
    "description": "Public, read-only, key-less API to simulate Fliinow travel financing. Same numbers as https://simulador.fliinow.com.\n\nRate limits: 120 requests per 60 s per IP, advertised with IETF RateLimit headers and Retry-After on 429. Sandbox: the API is stateless and side-effect free, so production doubles as the sandbox — no test mode or test data is needed.",
    "contact": {
      "name": "Fliinow",
      "url": "https://fliinow.com"
    },
    "x-versioning-policy": "Semantic versioning; breaking changes ship under a new major path with 6 months notice."
  },
  "servers": [
    {
      "url": "https://cexixtzrgewcqfkdullf.supabase.co/functions/v1/api"
    }
  ],
  "externalDocs": {
    "url": "https://simulador.fliinow.com/developers.md"
  },
  "security": [],
  "paths": {
    "/terms": {
      "get": {
        "operationId": "listTerms",
        "summary": "List limits and terms",
        "description": "Returns min/max amount, management fee and available terms with TIN/TAE.",
        "responses": {
          "200": {
            "description": "Terms",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "minAmount": {
                      "type": "number"
                    },
                    "maxAmount": {
                      "type": "number"
                    },
                    "managementFeePercent": {
                      "type": "number"
                    },
                    "terms": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "months": {
                            "type": "integer"
                          },
                          "tin": {
                            "type": "number"
                          },
                          "tae": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "500": {
            "description": "Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (120 requests / 60 s per IP).",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/simulate": {
      "get": {
        "operationId": "simulateFinancing",
        "summary": "Simulate one financing",
        "description": "Monthly installment, management fee, interest and total for an amount and term.",
        "parameters": [
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "description": "Trip amount in EUR (60–5000)",
            "schema": {
              "type": "number",
              "minimum": 60,
              "maximum": 5000
            },
            "example": 2000
          },
          {
            "name": "months",
            "in": "query",
            "required": true,
            "description": "Term in months",
            "schema": {
              "type": "integer",
              "enum": [
                3,
                6,
                9,
                12
              ]
            },
            "example": 6
          }
        ],
        "responses": {
          "200": {
            "description": "Simulation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Simulation"
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (120 requests / 60 s per IP).",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/compare": {
      "get": {
        "operationId": "compareTerms",
        "summary": "Compare all terms",
        "description": "Simulations for 3, 6, 9 and 12 months for one amount.",
        "parameters": [
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "description": "Trip amount in EUR (60–5000)",
            "schema": {
              "type": "number",
              "minimum": 60,
              "maximum": 5000
            },
            "example": 2000
          }
        ],
        "responses": {
          "200": {
            "description": "Comparison",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "amount": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Simulation"
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "422": {
            "description": "Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimit-Policy"
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (120 requests / 60 s per IP).",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/Retry-After"
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Simulation": {
        "type": "object",
        "required": [
          "amount",
          "months",
          "managementFee",
          "interest",
          "totalAmount",
          "monthlyInstallment",
          "tin",
          "tae",
          "currency"
        ],
        "properties": {
          "amount": {
            "type": "number"
          },
          "months": {
            "type": "integer"
          },
          "managementFee": {
            "type": "number",
            "description": "Gastos de gestión (2%) in EUR"
          },
          "interest": {
            "type": "number"
          },
          "totalAmount": {
            "type": "number"
          },
          "monthlyInstallment": {
            "type": "number"
          },
          "tin": {
            "type": "number"
          },
          "tae": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR"
            ]
          },
          "simulatorUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "hint": {
                "type": "string"
              },
              "docs": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "status": {
            "type": "integer"
          }
        }
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Optional client-generated key. Simulations are pure calculations, so repeating a request with the same key and body always returns the same result and never creates side effects.",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      }
    },
    "headers": {
      "RateLimit": {
        "description": "Remaining quota and seconds to reset (IETF RateLimit header).",
        "schema": {
          "type": "string"
        }
      },
      "RateLimit-Policy": {
        "description": "Quota policy: 120 requests per 60 s per IP.",
        "schema": {
          "type": "string"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait after a 429.",
        "schema": {
          "type": "integer"
        }
      }
    }
  }
}