{
  "openapi": "3.1.0",
  "info": {
    "title": "VPN Dashboard Billing API",
    "version": "1.0.0",
    "description": "Billing endpoints for VPN service changes from WHMCS, Blesta, Paymenter, Clientexec, WISECP, FOSSBilling and WooCommerce. Match this reference to the installed dashboard version. The earlier customer application API is retired."
  },
  "servers": [
    {
      "url": "https://vpn.yourdomain.com/api/v1/billing",
      "description": "Replace the example hostname with the confirmed dashboard address."
    }
  ],
  "security": [
    {
      "BillingBearer": []
    }
  ],
  "x-vpn-dashboard": {
    "provider_scoping": "Omitting provider uses the authenticated token’s connection. An explicit provider must be one of the seven supported keys and match that connection; a cross-provider request is forbidden.",
    "rate_limit": "The billing routes are configured for 90 requests per minute.",
    "request_body_limit_bytes": 65536,
    "idempotency": {
      "header": "Idempotency-Key",
      "replay_behaviour": "A completed matching event returns its stored response with Idempotency-Replayed: true. A changed request with the same key returns HTTP 409. In-progress or dead-letter events also return 409 and require the appropriate retry or operator action."
    },
    "webhook_signing": {
      "timestamp_header": "X-VPN-Dashboard-Timestamp",
      "signature_header": "X-VPN-Dashboard-Signature",
      "format": "sha256=<hmac_sha256(timestamp + \".\" + uppercase_method + \".\" + request_path + \".\" + raw_body)>",
      "tolerance_seconds": 300,
      "requirements": "Mutations require request signing or a configured IP allow-list. When a signing secret is configured, the signature must be supplied even if an allow-list is also present. Signed requests must not contain query parameters."
    },
    "source": {
      "name": "vpn-dashboard-software",
      "version": "1.0.0",
      "commit": "6e742d9cc796eaeb352ba0f13ce755d16f7c7270",
      "status": "development",
      "published": false,
      "date": "2026-10-16"
    },
    "providers": [
      "whmcs",
      "blesta",
      "paymenter",
      "clientexec",
      "wisecp",
      "fossbilling",
      "woocommerce"
    ]
  },
  "paths": {
    "/ping": {
      "get": {
        "summary": "Check the billing connection",
        "description": "Checks the token and whether request signing or an IP allow-list is configured for mutations.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Connection and mutation protection are ready.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionStatus"
                }
              }
            }
          },
          "409": {
            "description": "Token accepted, but mutation protection is not configured.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionStatus"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Check the billing connection with POST",
        "description": "Readiness check used by the FOSSBilling module. It does not change service state. POST requests must satisfy the same signing or source-IP protection and idempotency-key middleware as other billing POST requests. The readiness result is evaluated on every call; no service-event response is stored or replayed.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Connection and mutation protection are ready.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionStatus"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Stable event identifier. Reuse it for a retry of the same request.",
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "Accepted as a header or body idempotency_key. Required by POST middleware unless a valid signature provides a derived fallback key. This readiness check does not store an idempotent service event."
          },
          {
            "name": "X-VPN-Dashboard-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Required when the connection has a webhook signing secret. Unix time within the configured tolerance, normally 300 seconds."
          },
          {
            "name": "X-VPN-Dashboard-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when signing is configured. sha256=<hex HMAC-SHA256 of timestamp.method.path.raw_body>. Use the uppercase HTTP method and exact request path."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LifecycleRequest"
              }
            }
          }
        }
      }
    },
    "/services": {
      "post": {
        "summary": "Create or update a VPN service",
        "description": "Upserts the service by provider and external_service_id. Use stable customer and service identifiers. A configured product plan for this provider is authoritative. Dedicated assignment can be pending independently of active billing status.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Stable event identifier. Reuse it for a retry of the same request.",
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "Send a stable key for every mutation. A body idempotency_key is also accepted. Valid signed requests can derive a fallback key, but an explicit event key preserves identity across newly signed retries."
          },
          {
            "name": "X-VPN-Dashboard-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Required when the connection has a webhook signing secret. Unix time within the configured tolerance, normally 300 seconds."
          },
          {
            "name": "X-VPN-Dashboard-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when signing is configured. sha256=<hex HMAC-SHA256 of timestamp.method.path.raw_body>. Use the uppercase HTTP method and exact request path."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflicting event identity, event still processing, service state conflict or an event requiring operator review.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Service update failed. Inspect the error and recorded event before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "201": {
            "description": "Service created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                }
              }
            }
          }
        }
      }
    },
    "/services/{serviceId}/suspend": {
      "post": {
        "summary": "Suspend dashboard access and profiles",
        "description": "Applies the suspended service state and synchronises dashboard-generated profiles. Repeated requests use the same event key. This does not change accounts managed by a separate provisioning system.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "parameters": [
          {
            "name": "serviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The external_service_id stored for this provider’s service, such as whmcs-8801."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Stable event identifier. Reuse it for a retry of the same request.",
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "Send a stable key for every mutation. A body idempotency_key is also accepted. Valid signed requests can derive a fallback key, but an explicit event key preserves identity across newly signed retries."
          },
          {
            "name": "X-VPN-Dashboard-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Required when the connection has a webhook signing secret. Unix time within the configured tolerance, normally 300 seconds."
          },
          {
            "name": "X-VPN-Dashboard-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when signing is configured. sha256=<hex HMAC-SHA256 of timestamp.method.path.raw_body>. Use the uppercase HTTP method and exact request path."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LifecycleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceStatus"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflicting event identity, event still processing, service state conflict or an event requiring operator review.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Service update failed. Inspect the error and recorded event before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Service not found for the authenticated provider connection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/services/{serviceId}/unsuspend": {
      "post": {
        "summary": "Restore dashboard access and eligible profiles",
        "description": "Applies the active service state and synchronises dashboard-generated profiles. Repeated requests use the same event key. This does not change accounts managed by a separate provisioning system.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "parameters": [
          {
            "name": "serviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The external_service_id stored for this provider’s service, such as whmcs-8801."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Stable event identifier. Reuse it for a retry of the same request.",
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "Send a stable key for every mutation. A body idempotency_key is also accepted. Valid signed requests can derive a fallback key, but an explicit event key preserves identity across newly signed retries."
          },
          {
            "name": "X-VPN-Dashboard-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Required when the connection has a webhook signing secret. Unix time within the configured tolerance, normally 300 seconds."
          },
          {
            "name": "X-VPN-Dashboard-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when signing is configured. sha256=<hex HMAC-SHA256 of timestamp.method.path.raw_body>. Use the uppercase HTTP method and exact request path."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LifecycleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceStatus"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflicting event identity, event still processing, service state conflict or an event requiring operator review.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Service update failed. Inspect the error and recorded event before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Service not found for the authenticated provider connection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/services/{serviceId}/cancel": {
      "post": {
        "summary": "Cancel dashboard access and remove profiles",
        "description": "Applies the cancelled service state and synchronises dashboard-generated profiles. Repeated requests use the same event key. This does not change accounts managed by a separate provisioning system.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "parameters": [
          {
            "name": "serviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The external_service_id stored for this provider’s service, such as whmcs-8801."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Stable event identifier. Reuse it for a retry of the same request.",
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "Send a stable key for every mutation. A body idempotency_key is also accepted. Valid signed requests can derive a fallback key, but an explicit event key preserves identity across newly signed retries."
          },
          {
            "name": "X-VPN-Dashboard-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Required when the connection has a webhook signing secret. Unix time within the configured tolerance, normally 300 seconds."
          },
          {
            "name": "X-VPN-Dashboard-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when signing is configured. sha256=<hex HMAC-SHA256 of timestamp.method.path.raw_body>. Use the uppercase HTTP method and exact request path."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LifecycleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceStatus"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflicting event identity, event still processing, service state conflict or an event requiring operator review.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Service update failed. Inspect the error and recorded event before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Service not found for the authenticated provider connection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/services/{serviceId}/dedicated-servers": {
      "post": {
        "summary": "Assign dedicated servers",
        "description": "Updates eligible dedicated server assignments for an active service. Supply server IDs or a requested count. Capacity and existing profile placement are checked before changes are accepted.",
        "security": [
          {
            "BillingBearer": []
          }
        ],
        "parameters": [
          {
            "name": "serviceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The external_service_id stored for this provider’s service, such as whmcs-8801."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Stable event identifier. Reuse it for a retry of the same request.",
              "maxLength": 160,
              "pattern": "^[A-Za-z0-9._:-]+$"
            },
            "description": "Send a stable key for every mutation. A body idempotency_key is also accepted. Valid signed requests can derive a fallback key, but an explicit event key preserves identity across newly signed retries."
          },
          {
            "name": "X-VPN-Dashboard-Timestamp",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "description": "Required when the connection has a webhook signing secret. Unix time within the configured tolerance, normally 300 seconds."
          },
          {
            "name": "X-VPN-Dashboard-Signature",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required when signing is configured. sha256=<hex HMAC-SHA256 of timestamp.method.path.raw_body>. Use the uppercase HTTP method and exact request path."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DedicatedServerRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Service"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token or request signature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Provider, source IP or mutation protection is not permitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Conflicting event identity, event still processing, service state conflict or an event requiring operator review.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds 65,536 bytes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed, a required event key is missing or the selected product/servers are not eligible.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Service update failed. Inspect the error and recorded event before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Service not found for the authenticated provider connection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BillingBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "API token for one provider connection. Keep it on the billing server; tokens cannot act for another provider."
      }
    },
    "schemas": {
      "ServiceRequest": {
        "type": "object",
        "required": [
          "external_client_id",
          "external_service_id"
        ],
        "anyOf": [
          {
            "required": [
              "profile_limit"
            ]
          },
          {
            "required": [
              "profile_count"
            ]
          },
          {
            "required": [
              "connections"
            ]
          },
          {
            "required": [
              "additional_connections"
            ]
          }
        ],
        "properties": {
          "external_client_id": {
            "type": "string",
            "description": "Stable customer identifier within this provider connection.",
            "maxLength": 120
          },
          "external_service_id": {
            "type": "string",
            "description": "Stable service identifier within this provider connection.",
            "maxLength": 120
          },
          "provider": {
            "type": "string",
            "enum": [
              "whmcs",
              "blesta",
              "paymenter",
              "clientexec",
              "wisecp",
              "fossbilling",
              "woocommerce"
            ],
            "description": "Provider key scoped to the authenticated billing connection. Requests may omit it; an explicit value must match the token’s provider."
          },
          "idempotency_key": {
            "type": "string",
            "description": "Stable event identifier. Reuse it for a retry of the same request.",
            "maxLength": 160,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 255,
            "description": "Required when creating a service for a new customer."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "product_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120,
            "description": "Billing product ID. A configured product mapping for the provider overrides the submitted plan fields."
          },
          "product_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "profile_limit": {
            "type": "integer",
            "description": "Profile allowance. Supply this or one of its aliases.",
            "minimum": 1,
            "maximum": 10000
          },
          "profile_count": {
            "type": "integer",
            "description": "Alias for profile_limit.",
            "minimum": 1,
            "maximum": 10000
          },
          "connections": {
            "type": "integer",
            "description": "Alias for profile_limit.",
            "minimum": 1,
            "maximum": 10000
          },
          "additional_connections": {
            "type": "integer",
            "description": "Legacy alias: allowance is one plus this value.",
            "minimum": 0,
            "maximum": 9999
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "cancelled"
            ]
          },
          "allowed_protocols": {
            "type": "array",
            "maxItems": 2,
            "items": {
              "type": "string",
              "enum": [
                "wireguard",
                "openvpn"
              ]
            }
          },
          "protocols": {
            "type": "array",
            "maxItems": 2,
            "items": {
              "type": "string",
              "enum": [
                "wireguard",
                "openvpn"
              ]
            },
            "description": "Alias for allowed_protocols."
          },
          "monthly_traffic_gb": {
            "type": "integer",
            "description": "Optional monthly traffic allowance in GB. Omitting it preserves an existing allowance; a new service has no monthly cap unless a configured product mapping supplies one. Product mappings take precedence.",
            "minimum": 1,
            "maximum": 1000000
          },
          "traffic_gb": {
            "type": "integer",
            "description": "Alias for monthly_traffic_gb.",
            "minimum": 1,
            "maximum": 1000000
          },
          "profile_rotation_days": {
            "type": "integer",
            "description": "Optional WireGuard key rotation interval. OpenVPN credentials are not rotated by this setting; customers must import updated WireGuard configurations.",
            "minimum": 1,
            "maximum": 3650
          },
          "support_tier": {
            "type": "string",
            "description": "Optional support tier key.",
            "maxLength": 60,
            "pattern": "^[a-z0-9_-]+$"
          },
          "server_access_type": {
            "type": "string",
            "enum": [
              "shared",
              "private",
              "dedicated",
              "dedicated_server"
            ],
            "description": "Shared or private service access; dedicated values are accepted aliases for private."
          },
          "plan_type": {
            "type": "string",
            "enum": [
              "shared",
              "private",
              "dedicated",
              "dedicated_server"
            ],
            "description": "Alias for server_access_type."
          },
          "access_type": {
            "type": "string",
            "enum": [
              "shared",
              "private",
              "dedicated",
              "dedicated_server"
            ],
            "description": "Alias for server_access_type."
          },
          "dedicated_server_id": {
            "type": "integer",
            "description": "One existing eligible server ID."
          },
          "dedicated_server_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "uniqueItems": true,
            "maxItems": 100,
            "description": "Existing server IDs eligible for this dedicated service."
          },
          "private_server_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "uniqueItems": true,
            "maxItems": 100,
            "description": "Alias for dedicated_server_ids."
          },
          "dedicated_server_count": {
            "type": "integer",
            "description": "Requested dedicated server count.",
            "minimum": 1,
            "maximum": 100
          },
          "allow_pending_dedicated_assignment": {
            "type": "boolean",
            "description": "Permit the dedicated allocation to remain pending if ready capacity is unavailable."
          },
          "preserve_dedicated_assignments": {
            "type": "boolean",
            "description": "Retain existing dedicated assignments when updating by server count."
          }
        },
        "description": "Use a stable customer and service identity. A new customer needs an email. Product mappings can override the plan fields."
      },
      "LifecycleRequest": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "whmcs",
              "blesta",
              "paymenter",
              "clientexec",
              "wisecp",
              "fossbilling",
              "woocommerce"
            ],
            "description": "Provider key scoped to the authenticated billing connection. Requests may omit it; an explicit value must match the token’s provider."
          },
          "idempotency_key": {
            "type": "string",
            "description": "Stable event identifier. Reuse it for a retry of the same request.",
            "maxLength": 160,
            "pattern": "^[A-Za-z0-9._:-]+$"
          }
        }
      },
      "DedicatedServerRequest": {
        "type": "object",
        "anyOf": [
          {
            "required": [
              "dedicated_server_id"
            ]
          },
          {
            "required": [
              "dedicated_server_ids"
            ]
          },
          {
            "required": [
              "private_server_ids"
            ]
          },
          {
            "required": [
              "dedicated_server_count"
            ]
          }
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "whmcs",
              "blesta",
              "paymenter",
              "clientexec",
              "wisecp",
              "fossbilling",
              "woocommerce"
            ],
            "description": "Provider key scoped to the authenticated billing connection. Requests may omit it; an explicit value must match the token’s provider."
          },
          "idempotency_key": {
            "type": "string",
            "description": "Stable event identifier. Reuse it for a retry of the same request.",
            "maxLength": 160,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "dedicated_server_id": {
            "type": "integer",
            "description": "One existing eligible server ID."
          },
          "dedicated_server_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "uniqueItems": true,
            "maxItems": 100,
            "description": "Existing server IDs eligible for this dedicated service."
          },
          "private_server_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "uniqueItems": true,
            "maxItems": 100,
            "description": "Alias for dedicated_server_ids."
          },
          "dedicated_server_count": {
            "type": "integer",
            "description": "Requested dedicated server count.",
            "minimum": 1,
            "maximum": 100
          }
        }
      },
      "ConnectionStatus": {
        "type": "object",
        "required": [
          "status",
          "provider",
          "mutations_ready"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "configuration_error"
            ]
          },
          "provider": {
            "type": "string",
            "enum": [
              "whmcs",
              "blesta",
              "paymenter",
              "clientexec",
              "wisecp",
              "fossbilling",
              "woocommerce"
            ],
            "description": "Provider key scoped to the authenticated billing connection. Requests may omit it; an explicit value must match the token’s provider."
          },
          "mutations_ready": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "customer_branding": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ServiceStatus": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "cancelled"
            ]
          }
        }
      },
      "Service": {
        "type": "object",
        "additionalProperties": true,
        "description": "The stored service and its current dedicated assignment/capacity information. An accepted lifecycle request can leave asynchronous profile work outstanding.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "external_service_id": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "whmcs",
              "blesta",
              "paymenter",
              "clientexec",
              "wisecp",
              "fossbilling",
              "woocommerce"
            ],
            "description": "Provider key scoped to the authenticated billing connection. Requests may omit it; an explicit value must match the token’s provider."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "cancelled"
            ]
          },
          "profile_limit": {
            "type": "integer"
          },
          "profile_count": {
            "type": "integer"
          },
          "server_access_type": {
            "type": "string"
          },
          "plan_type": {
            "type": "string"
          },
          "dedicated_server_ids": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "dedicated_server_count": {
            "type": "integer"
          },
          "dedicated_capacity": {
            "type": "integer"
          },
          "dedicated_capacity_gap": {
            "type": "integer"
          }
        }
      },
      "Error": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
