{
  "openapi": "3.1.0",
  "info": {
    "title": "Initech API",
    "version": "1.0.0",
    "description": "Read-only API for the Initech multi-cloud VPS catalog and your account. Deploy on Vultr, Hetzner, DigitalOcean, AWS, Google Cloud, Alibaba Cloud and our own fleet from one account, paid in crypto. Catalog endpoints are public; account endpoints require an API key created at https://initech.global/ixv2-apikeys.php. Send the key as a bearer token. Rate limits: 30 requests per minute per IP on public endpoints, 120 per minute per key on authenticated endpoints; responses carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers, and 429 responses include Retry-After. All prices are USD. Product names are English in this version; a lang parameter is planned."
  },
  "servers": [{ "url": "https://api.initech.global" }],
  "security": [],
  "paths": {
    "/v1/ping": {
      "get": {
        "summary": "Health check",
        "operationId": "ping",
        "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } } }
      }
    },
    "/v1/providers": {
      "get": {
        "summary": "List cloud providers",
        "operationId": "listProviders",
        "responses": {
          "200": {
            "description": "Visible provider groups with region counts",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": { "providers": { "type": "array", "items": { "$ref": "#/components/schemas/Provider" } } }
            } } }
          }
        }
      }
    },
    "/v1/providers/{providerId}/regions": {
      "get": {
        "summary": "List a provider's regions with starting prices",
        "operationId": "listRegions",
        "parameters": [{ "name": "providerId", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": {
          "200": {
            "description": "Regions (one per city) with monthly from-price",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "provider": { "$ref": "#/components/schemas/ProviderRef" },
                "regions": { "type": "array", "items": { "$ref": "#/components/schemas/Region" } }
              }
            } } }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/regions/{regionId}": {
      "get": {
        "summary": "Full plan, OS and add-on catalog for a region",
        "operationId": "getRegion",
        "parameters": [{ "name": "regionId", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": {
          "200": {
            "description": "Plans, operating systems and add-ons with per-cycle prices",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RegionDetail" } } }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/account": {
      "get": {
        "summary": "Account profile and credit balance",
        "operationId": "getAccount",
        "security": [{ "apiKey": [] }, { "apiKeyHeader": [] }],
        "responses": {
          "200": { "description": "Account", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Account" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/account/credit-history": {
      "get": {
        "summary": "Credit ledger entries, newest first",
        "operationId": "listCreditHistory",
        "security": [{ "apiKey": [] }, { "apiKeyHeader": [] }],
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 25 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "minimum": 0, "default": 0 } }
        ],
        "responses": {
          "200": { "description": "Signed ledger entries (positive = credit added)", "content": { "application/json": { "schema": {
            "type": "object",
            "properties": {
              "entries": { "type": "array", "items": { "$ref": "#/components/schemas/CreditEntry" } },
              "limit": { "type": "integer" },
              "offset": { "type": "integer" }
            }
          } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/services": {
      "get": {
        "summary": "List your servers",
        "operationId": "listServices",
        "security": [{ "apiKey": [] }, { "apiKeyHeader": [] }],
        "parameters": [{ "name": "status", "in": "query", "description": "Pass 'all' to include terminated and cancelled services; default is pending, active and suspended only.", "schema": { "type": "string", "enum": ["all"] } }],
        "responses": {
          "200": { "description": "Services owned by the key's account", "content": { "application/json": { "schema": {
            "type": "object",
            "properties": { "services": { "type": "array", "items": { "$ref": "#/components/schemas/Service" } } }
          } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/services/{serviceId}": {
      "get": {
        "summary": "One server with its configuration",
        "operationId": "getService",
        "security": [{ "apiKey": [] }, { "apiKeyHeader": [] }],
        "parameters": [{ "name": "serviceId", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": {
          "200": { "description": "Service detail", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ServiceDetail" } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": { "type": "http", "scheme": "bearer", "description": "API key (ixk_...) as bearer token" },
      "apiKeyHeader": { "type": "apiKey", "in": "header", "name": "X-Api-Key" }
    },
    "responses": {
      "NotFound": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Unauthorized": { "description": "Missing or invalid API key", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    },
    "schemas": {
      "Error": { "type": "object", "properties": { "error": { "type": "string" } }, "required": ["error"] },
      "Money": { "type": "string", "description": "USD amount as a 2-decimal string", "examples": ["10.00"] },
      "Prices": {
        "type": "object",
        "description": "Recurring price per billing cycle (total per term, not per month)",
        "properties": {
          "monthly": { "$ref": "#/components/schemas/Money" },
          "quarterly": { "$ref": "#/components/schemas/Money" },
          "semiannually": { "$ref": "#/components/schemas/Money" },
          "annually": { "$ref": "#/components/schemas/Money" },
          "biennially": { "$ref": "#/components/schemas/Money" },
          "triennially": { "$ref": "#/components/schemas/Money" }
        }
      },
      "Provider": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "regions": { "type": "integer" }
        }
      },
      "ProviderRef": {
        "type": "object",
        "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "slug": { "type": "string" } }
      },
      "Region": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "slug": { "type": ["string", "null"] },
          "from_price_monthly": { "oneOf": [{ "$ref": "#/components/schemas/Money" }, { "type": "null" }], "description": "Cheapest visible plan per month; null for build-your-own regions" }
        }
      },
      "CatalogEntry": {
        "type": "object",
        "properties": {
          "option_id": { "type": "integer" },
          "sub_id": { "type": "integer" },
          "key": { "type": ["string", "null"], "description": "Provider-native identifier (plan slug, image id, AMI id, ...)" },
          "label": { "type": "string" },
          "prices": { "$ref": "#/components/schemas/Prices" }
        }
      },
      "Addon": {
        "type": "object",
        "properties": {
          "option_id": { "type": "integer" },
          "key": { "type": ["string", "null"] },
          "label": { "type": "string" },
          "type": { "type": "string", "enum": ["toggle", "quantity", "dropdown"] },
          "prices": { "$ref": "#/components/schemas/Prices" },
          "unit": { "type": "string" },
          "qty_min": { "type": "integer" },
          "qty_max": { "type": "integer" },
          "unit_prices": { "$ref": "#/components/schemas/Prices" },
          "entries": { "type": "array", "items": { "$ref": "#/components/schemas/CatalogEntry" } }
        }
      },
      "RegionDetail": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "provider": { "$ref": "#/components/schemas/ProviderRef" },
          "name": { "type": "string" },
          "slug": { "type": ["string", "null"] },
          "currency": { "type": "string", "const": "USD" },
          "plans": { "type": "array", "items": { "$ref": "#/components/schemas/CatalogEntry" } },
          "os": { "type": "array", "items": { "$ref": "#/components/schemas/CatalogEntry" } },
          "addons": { "type": "array", "items": { "$ref": "#/components/schemas/Addon" } }
        }
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "first_name": { "type": "string" },
          "last_name": { "type": "string" },
          "company": { "type": "string" },
          "email": { "type": "string" },
          "country": { "type": "string" },
          "credit": { "$ref": "#/components/schemas/Money" },
          "created_at": { "type": "string", "format": "date" }
        }
      },
      "CreditEntry": {
        "type": "object",
        "properties": {
          "date": { "type": "string", "format": "date" },
          "description": { "type": "string" },
          "amount": { "type": "string", "description": "Signed 2-decimal amount; negative = credit spent" }
        }
      },
      "Service": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "status": { "type": "string", "enum": ["Pending", "Active", "Suspended", "Terminated", "Cancelled", "Fraud", "Completed"] },
          "provider": { "$ref": "#/components/schemas/ProviderRef" },
          "region": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" } } },
          "hostname": { "type": ["string", "null"], "description": "Provider-dependent label; may not be a resolvable FQDN" },
          "ipv4": { "type": ["string", "null"] },
          "ipv6": { "type": ["string", "null"], "description": "IPv6 address or prefix where the provider assigns one" },
          "billing_cycle": { "type": "string" },
          "recurring_amount": { "$ref": "#/components/schemas/Money" },
          "next_due_date": { "type": ["string", "null"], "format": "date" },
          "registration_date": { "type": "string", "format": "date" }
        }
      },
      "ServiceDetail": {
        "allOf": [
          { "$ref": "#/components/schemas/Service" },
          { "type": "object", "properties": { "configuration": { "type": "array", "items": { "$ref": "#/components/schemas/ServiceConfigItem" } } } }
        ]
      },
      "ServiceConfigItem": {
        "type": "object",
        "properties": {
          "option": { "type": "string" },
          "key": { "type": ["string", "null"] },
          "label": { "type": "string" },
          "enabled": { "type": "boolean" },
          "quantity": { "type": "integer" }
        }
      }
    }
  }
}
