{
  "openapi": "3.1.0",
  "info": {
    "title": "rel.tax — Multi-Country B2B Tax Calculator",
    "version": "2.0.0",
    "description": "Calculate net income after taxes for self-employed, B2B, and contractor workers across 55 countries. No authentication required. Input gross income and country code, get detailed tax breakdown.",
    "contact": {
      "url": "https://rel.tax"
    },
    "license": {
      "name": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://rel.tax",
      "description": "Production"
    }
  ],
  "paths": {
    "/v1/calculate/{country}": {
      "get": {
        "operationId": "calculate_tax_get",
        "summary": "Calculate taxes for a country (query params)",
        "description": "Pass income and optional country-specific params as query parameters. Use GET /v1/countries/{country} to discover available parameters.",
        "parameters": [
          {
            "name": "country",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "pl",
                "nz",
                "au",
                "gb",
                "us",
                "ca",
                "de",
                "es",
                "rs",
                "jp",
                "ee",
                "ge",
                "am",
                "mx",
                "pt",
                "nl",
                "bg",
                "cz",
                "ro",
                "ae",
                "me",
                "cy",
                "sg",
                "hr",
                "hu",
                "th",
                "my",
                "cr",
                "id",
                "co",
                "be",
                "fr",
                "ph",
                "it",
                "lt",
                "gr",
                "ie",
                "at",
                "se",
                "il",
                "in",
                "dk",
                "fi",
                "no",
                "ch",
                "lv",
                "sk",
                "si",
                "mt",
                "tr",
                "ua",
                "br",
                "vn",
                "za",
                "kr"
              ]
            },
            "description": "ISO 3166-1 alpha-2 country code"
          },
          {
            "name": "income",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            },
            "description": "Annual gross income in local currency"
          }
        ],
        "responses": {
          "200": {
            "description": "Tax calculation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Country not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "calculate_tax_post",
        "summary": "Calculate taxes for a country (JSON body)",
        "description": "Post income and optional country-specific params as JSON. Use GET /v1/countries/{country} to discover available parameters.",
        "parameters": [
          {
            "name": "country",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "pl",
                "nz",
                "au",
                "gb",
                "us",
                "ca",
                "de",
                "es",
                "rs",
                "jp",
                "ee",
                "ge",
                "am",
                "mx",
                "pt",
                "nl",
                "bg",
                "cz",
                "ro",
                "ae",
                "me",
                "cy",
                "sg",
                "hr",
                "hu",
                "th",
                "my",
                "cr",
                "id",
                "co",
                "be",
                "fr",
                "ph",
                "it",
                "lt",
                "gr",
                "ie",
                "at",
                "se",
                "il",
                "in",
                "dk",
                "fi",
                "no",
                "ch",
                "lv",
                "sk",
                "si",
                "mt",
                "tr",
                "ua",
                "br",
                "vn",
                "za",
                "kr"
              ]
            },
            "description": "ISO 3166-1 alpha-2 country code"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "income"
                ],
                "properties": {
                  "income": {
                    "type": "number",
                    "description": "Annual gross income in local currency"
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tax calculation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Country not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/countries": {
      "get": {
        "operationId": "list_countries",
        "summary": "List all supported countries",
        "responses": {
          "200": {
            "description": "List of supported countries with codes, names, currencies, and tax years",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "taxYear": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "code",
                          "name",
                          "currency",
                          "taxYear"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/countries/{countryCode}": {
      "get": {
        "operationId": "get_country_docs",
        "summary": "Get tax parameters and documentation for a specific country",
        "parameters": [
          {
            "name": "countryCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z]{2}$"
            },
            "description": "ISO 3166-1 alpha-2 country code"
          }
        ],
        "responses": {
          "200": {
            "description": "Country documentation with available parameters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Country not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CalculationResponse": {
        "type": "object",
        "required": [
          "country",
          "currency",
          "taxYear",
          "input",
          "monthly",
          "yearly",
          "rates"
        ],
        "properties": {
          "country": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 country code"
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217 currency code (e.g. EUR, USD, GBP)"
          },
          "taxYear": {
            "type": "integer"
          },
          "input": {
            "type": "object",
            "additionalProperties": true
          },
          "monthly": {
            "type": "object",
            "properties": {
              "gross": {
                "type": "number"
              },
              "socialInsurance": {
                "type": "number"
              },
              "healthInsurance": {
                "type": "number"
              },
              "incomeTax": {
                "type": "number"
              },
              "totalDeductions": {
                "type": "number"
              },
              "net": {
                "type": "number"
              }
            }
          },
          "yearly": {
            "type": "object",
            "properties": {
              "gross": {
                "type": "number"
              },
              "socialInsurance": {
                "type": "number"
              },
              "healthInsurance": {
                "type": "number"
              },
              "incomeTax": {
                "type": "number"
              },
              "totalDeductions": {
                "type": "number"
              },
              "net": {
                "type": "number"
              }
            }
          },
          "rates": {
            "type": "object",
            "properties": {
              "effectiveTaxRate": {
                "type": "number",
                "description": "Total deductions as fraction of gross (0-1)"
              },
              "dailyRate": {
                "type": "number"
              },
              "hourlyRate": {
                "type": "number"
              },
              "workingDays": {
                "type": "integer"
              }
            }
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "example": {
          "country": "de",
          "currency": "EUR",
          "taxYear": 2025,
          "input": {
            "income": 60000,
            "incomePeriod": "yearly"
          },
          "monthly": {
            "gross": 5000,
            "vat": 0,
            "grossWithVat": 5000,
            "socialInsurance": 846.89,
            "healthInsurance": 0,
            "incomeTax": 671.83,
            "totalDeductions": 1518.72,
            "net": 3481.28
          },
          "yearly": {
            "gross": 60000,
            "socialInsurance": 10162.68,
            "healthInsurance": 0,
            "incomeTax": 8061.92,
            "totalDeductions": 18224.6,
            "net": 41775.4
          },
          "rates": {
            "effectiveTaxRate": 0.3037,
            "dailyRate": 189.03,
            "hourlyRate": 23.63,
            "workingDays": 221
          },
          "details": {}
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          },
          "docs": {
            "type": "string"
          }
        }
      }
    }
  }
}