{
    "openapi": "3.1.0",
    "info": {
        "title": "Validakey API",
        "version": "1.0.0",
        "description": "Validakey issues payment-backed access tokens (vKeys).\n\n**Coding agents:** for the sealed token path (`/v1/i/`, `/v1/m/`, `/v1/policy/`, `/v1/v/`, `/v1/r/`, `/v1/t/`, `/v1/p/`), use the official PHP client `validakey/validakey-php`. Do not hand-roll envelope crypto. When mint policy is enabled on an app, query `/v1/policy/` and do not invent prices.\n\nSee https://dev.validakey.com/llms.txt and the Agent Skill at https://dev.validakey.com/ai/skill/.\n\nEndpoints marked `x-validakey-sdk-only` document wire shape only; cleartext fields are under `x-validakey-sealed-parameters`."
    },
    "servers": [
        {
            "url": "https://dev.validakey.com",
            "description": "This Validakey host"
        }
    ],
    "paths": {
        "/v1/i/": {
            "post": {
                "operationId": "handshake",
                "summary": "Handshake",
                "tags": [
                    "token"
                ],
                "description": "Issue an Instance ID. Seal under the User App ID. Payload carries account UUID, fingerprint, and subject. Coding agents: use validakey/validakey-php (`handshake (automatic via createToken)`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "user_app_id",
                "x-validakey-sdk-method": "handshake (automatic via createToken)",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "uuid",
                        "type": "text",
                        "required": true,
                        "in": "sealed",
                        "hint": "Account UUID packed inside the envelope"
                    },
                    {
                        "name": "fingerprint",
                        "type": "text",
                        "required": true,
                        "in": "sealed",
                        "hint": "Client machine fingerprint"
                    },
                    {
                        "name": "subject",
                        "type": "text",
                        "required": true,
                        "in": "sealed",
                        "hint": "End-customer subject id (client generates one if omitted)"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "A sealed handshake payload is required.",
                                    "CODE": "missing_payload"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/r/": {
            "post": {
                "operationId": "rotate",
                "summary": "Rotate instance",
                "tags": [
                    "token"
                ],
                "description": "Retire the current Instance ID and receive a new one. Seal under the instance id you hold. Reply is sealed under the old id. Coding agents: use validakey/validakey-php (`rotateInstance()`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sdk-method": "rotateInstance()",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "note",
                        "type": "text",
                        "required": false,
                        "in": "sealed",
                        "hint": "Optional; payload may be empty beyond envelope nonce/ts"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Invalid request.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/t/": {
            "post": {
                "operationId": "transfer",
                "summary": "Transfer subject",
                "tags": [
                    "token"
                ],
                "description": "Move the Instance Entity to a new subject. Requires an open transfer window (PATCH /v1/instance/ allow_transfer). Coding agents: use validakey/validakey-php (`transferSubject()`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sdk-method": "transferSubject()",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "subject",
                        "type": "text",
                        "required": true,
                        "in": "sealed",
                        "hint": "New end-customer subject id"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Transfer window is not open.",
                                    "CODE": "transfer_not_allowed"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/policy/": {
            "post": {
                "operationId": "mint-policy",
                "summary": "Mint policy",
                "tags": [
                    "token"
                ],
                "description": "Read the User App mint defaults and limits for this instance. Use before minting when the app enforces policy so clients do not invent prices or shapes. Coding agents: use validakey/validakey-php. Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sealed-parameters": [],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Invalid request.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/m/": {
            "post": {
                "operationId": "mint",
                "summary": "Mint token",
                "tags": [
                    "token"
                ],
                "description": "Create a Limited or Transactional vKey under the current instance. Limited may take an expiry (duration/expires_at) and/or a use quota. Priced tokens require an IE card on the instance. When the app has mint policy enabled, omitted fields use server defaults and values outside limits are rejected. Coding agents: use validakey/validakey-php (`createToken()`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sdk-method": "createToken()",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "duration",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "Seconds until expiry. Default 3600 when no uses/expires_at/no_expiry. Use 0 with no_expiry for perpetual."
                    },
                    {
                        "name": "no_expiry",
                        "type": "boolean",
                        "required": false,
                        "in": "sealed",
                        "hint": "Transactional: perpetual until revoked (omit uses). With uses alone, omit this and duration for use-only Limited."
                    },
                    {
                        "name": "expires_at",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "Absolute unix expiry (optional Limited axis; alternative to duration)"
                    },
                    {
                        "name": "uses",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "Optional Limited use quota. Alone (no duration/expires_at) = use-only Limited with no clock limit."
                    },
                    {
                        "name": "auto_renew",
                        "type": "boolean",
                        "required": false,
                        "in": "sealed",
                        "hint": "Top up uses when exhausted (priced)"
                    },
                    {
                        "name": "basis_cents",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "Sale base amount in cents (IE pays)"
                    },
                    {
                        "name": "tax_cents",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "Sales tax in cents"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "The instance entity has no payment method on file.",
                                    "CODE": "ie_card_required"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/v/": {
            "post": {
                "operationId": "validate",
                "summary": "Validate / renew token",
                "tags": [
                    "token"
                ],
                "description": "Validate a vKey (optional consume). action may be validate, revoke, or renew. Prefer DELETE for revoke. Coding agents: use validakey/validakey-php (`verifyToken() / renewToken()`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sdk-method": "verifyToken() / renewToken()",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "token",
                        "type": "text",
                        "required": true,
                        "in": "sealed",
                        "hint": "vKey value to validate"
                    },
                    {
                        "name": "consume",
                        "type": "boolean",
                        "required": false,
                        "in": "sealed",
                        "hint": "Spend one use when valid"
                    },
                    {
                        "name": "action",
                        "type": "select",
                        "required": false,
                        "in": "sealed",
                        "hint": "Default validate; renew adds time/uses"
                    },
                    {
                        "name": "duration",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "For renew: seconds to add"
                    },
                    {
                        "name": "uses",
                        "type": "number",
                        "required": false,
                        "in": "sealed",
                        "hint": "For renew: uses to add"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Token not found.",
                                    "CODE": "token_not_found"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "revoke",
                "summary": "Revoke token",
                "tags": [
                    "token"
                ],
                "description": "Revoke a vKey. Record is kept. Seal under the Instance ID. Coding agents: use validakey/validakey-php (`deleteToken()`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sdk-method": "deleteToken()",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "token",
                        "type": "text",
                        "required": true,
                        "in": "sealed",
                        "hint": "vKey value to revoke"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Token not found.",
                                    "CODE": "token_not_found"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/p/": {
            "post": {
                "operationId": "ie-payment",
                "summary": "Instance Entity payment",
                "tags": [
                    "token"
                ],
                "description": "IE card status, attach, detach, or payment link. Seal under Instance ID. Coding agents: use validakey/validakey-php (`instancePaymentStatus() / attachInstanceCard() / …`). Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "envelope",
                "x-validakey-seal-key": "instance_id",
                "x-validakey-sdk-method": "instancePaymentStatus() / attachInstanceCard() / …",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "action",
                        "type": "select",
                        "required": true,
                        "in": "sealed",
                        "hint": "status (default), attach, detach, or link"
                    },
                    {
                        "name": "source_id",
                        "type": "text",
                        "required": false,
                        "in": "sealed",
                        "hint": "Square source_id when action=attach"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/SealedWireBody"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Sealed success reply (or JSON error body).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "oneOf": [
                                        {
                                            "$ref": "#/components/schemas/SealedWireResponse"
                                        },
                                        {
                                            "$ref": "#/components/schemas/ErrorBody"
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "source_id is required.",
                                    "CODE": "missing_source_id"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/g/{packed}/": {
            "get": {
                "operationId": "dynamic-pass",
                "summary": "Redeem Dynamic Pass",
                "tags": [
                    "pass"
                ],
                "description": "19-character packed token + HMAC. Optional scanner credential. Not a sealed envelope route. Coding agents: use validakey/validakey-php. Do not POST cleartext JSON to this route.",
                "x-validakey-sdk-only": true,
                "x-validakey-auth": "packed",
                "x-validakey-sealed-parameters": [
                    {
                        "name": "packed",
                        "type": "text",
                        "required": true,
                        "in": "path",
                        "hint": "19-char packed Dynamic Pass code"
                    }
                ],
                "parameters": [
                    {
                        "name": "packed",
                        "in": "path",
                        "required": true,
                        "description": "19-char packed Dynamic Pass code",
                        "schema": {
                            "type": "string",
                            "description": "19-char packed Dynamic Pass code"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Pass validation result or error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Invalid pass.",
                                    "CODE": "invalid_pass"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/u/": {
            "get": {
                "operationId": "user-info",
                "summary": "User info",
                "tags": [
                    "account"
                ],
                "description": "Account identity and billing profile. Authorization: Bearer api_pkey plus api_user_id. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "api_user_id",
                        "in": "query",
                        "required": true,
                        "description": "Account UUID (body, query, or X-Validakey-User-Id)",
                        "schema": {
                            "type": "string",
                            "description": "Account UUID (body, query, or X-Validakey-User-Id)"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "api_user_id is required in the request body.",
                                    "CODE": "missing_api_user_id"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/billing/status/": {
            "get": {
                "operationId": "billing-status",
                "summary": "Billing status",
                "tags": [
                    "account"
                ],
                "description": "Account billing profile. Other billing actions: config, ensure_customer, attach, detach. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "api_user_id",
                        "in": "query",
                        "required": true,
                        "description": "Account UUID",
                        "schema": {
                            "type": "string",
                            "description": "Account UUID"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Unauthorized.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/billing/attach/": {
            "post": {
                "operationId": "billing-attach",
                "summary": "Billing attach card",
                "tags": [
                    "account"
                ],
                "description": "Attach account dues card via Square source_id. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "api_user_id": {
                                        "type": "string",
                                        "description": "Account UUID"
                                    },
                                    "source_id": {
                                        "type": "string",
                                        "description": "Square payment source id"
                                    }
                                },
                                "required": [
                                    "api_user_id",
                                    "source_id"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "source_id is required.",
                                    "CODE": "missing_source_id"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/apps/": {
            "get": {
                "operationId": "apps-list",
                "summary": "List apps",
                "tags": [
                    "account"
                ],
                "description": "List User Apps for the account. Full App ID is only returned once at creation. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "api_user_id",
                        "in": "query",
                        "required": true,
                        "description": "Account UUID",
                        "schema": {
                            "type": "string",
                            "description": "Account UUID"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Unauthorized.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "operationId": "apps-create",
                "summary": "Create app",
                "tags": [
                    "account"
                ],
                "description": "Create a User App. Response includes the full App ID once — store it securely. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "api_user_id": {
                                        "type": "string",
                                        "description": "Account UUID"
                                    },
                                    "name": {
                                        "type": "string",
                                        "description": "Display name"
                                    },
                                    "environment": {
                                        "type": "string",
                                        "description": "sandbox or production"
                                    },
                                    "default_machine_lock": {
                                        "type": "boolean",
                                        "description": "New instances inherit machine lock"
                                    }
                                },
                                "required": [
                                    "api_user_id"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Unauthorized.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "apps-patch",
                "summary": "Update app",
                "tags": [
                    "account"
                ],
                "description": "Patch by row id (not App ID). Alias, lock policy, or environment. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "api_user_id": {
                                        "type": "string",
                                        "description": "Account UUID"
                                    },
                                    "id": {
                                        "type": "number",
                                        "description": "App row id from list/create"
                                    },
                                    "environment": {
                                        "type": "string",
                                        "description": "sandbox ↔ production"
                                    }
                                },
                                "required": [
                                    "api_user_id",
                                    "id"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "id is required and must identify one of your apps.",
                                    "CODE": "missing_id"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/instance/": {
            "get": {
                "operationId": "instance-list",
                "summary": "List instances",
                "tags": [
                    "account"
                ],
                "description": "List instances (prefixes only — full Instance ID is never returned). POST returns 405 handshake_required. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "api_user_id",
                        "in": "query",
                        "required": true,
                        "description": "Account UUID",
                        "schema": {
                            "type": "string",
                            "description": "Account UUID"
                        }
                    },
                    {
                        "name": "user_app_id",
                        "in": "query",
                        "required": false,
                        "description": "Optional filter by app id / prefix",
                        "schema": {
                            "type": "string",
                            "description": "Optional filter by app id / prefix"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Unauthorized.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            },
            "patch": {
                "operationId": "instance-patch",
                "summary": "Manage instance",
                "tags": [
                    "account"
                ],
                "description": "Lock, unlock, allow_transfer, or cancel_transfer by row id. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "api_user_id": {
                                        "type": "string",
                                        "description": "Account UUID"
                                    },
                                    "id": {
                                        "type": "number",
                                        "description": "Instance row id"
                                    },
                                    "action": {
                                        "type": "string",
                                        "description": "Account-side instance action"
                                    }
                                },
                                "required": [
                                    "api_user_id",
                                    "id",
                                    "action"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "id is required and must identify one of your instances.",
                                    "CODE": "missing_id"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/usage/": {
            "get": {
                "operationId": "usage",
                "summary": "Usage summary",
                "tags": [
                    "account"
                ],
                "description": "Usage report for the account. Does not reveal credentials. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "api_user_id",
                        "in": "query",
                        "required": true,
                        "description": "Account UUID",
                        "schema": {
                            "type": "string",
                            "description": "Account UUID"
                        }
                    },
                    {
                        "name": "days",
                        "in": "query",
                        "required": false,
                        "description": "Lookback days (default 30)",
                        "schema": {
                            "type": "number",
                            "description": "Lookback days (default 30)"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "description": "Row limit (default 25)",
                        "schema": {
                            "type": "number",
                            "description": "Row limit (default 25)"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Unauthorized.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/v1/payout/status/": {
            "get": {
                "operationId": "payout-status",
                "summary": "Payout status",
                "tags": [
                    "account"
                ],
                "description": "Stripe Connect payout profile. Related: POST link, GET history, POST frequency. Account path: Authorization Bearer private key. Do not put api_pkey in distributed client software.",
                "x-validakey-auth": "bearer",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "api_user_id",
                        "in": "query",
                        "required": true,
                        "description": "Account UUID",
                        "schema": {
                            "type": "string",
                            "description": "Account UUID"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success or structured error.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error example from catalog.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorBody"
                                },
                                "example": {
                                    "ERROR": "Unauthorized.",
                                    "CODE": "unauthorized"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "Account private key (api_pkey). Never ship in distributed end-user software. Not used on the licence/token path.",
                "bearerFormat": "api_pkey"
            }
        },
        "schemas": {
            "SealedWireBody": {
                "type": "object",
                "required": [
                    "q"
                ],
                "additionalProperties": false,
                "properties": {
                    "q": {
                        "type": "string",
                        "description": "Sealed envelope ciphertext. Produced by validakey-php (or equivalent). Cleartext never appears on the wire."
                    }
                }
            },
            "SealedWireResponse": {
                "type": "object",
                "properties": {
                    "out": {
                        "type": "object",
                        "properties": {
                            "q": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "ErrorBody": {
                "type": "object",
                "properties": {
                    "ERROR": {
                        "type": "string"
                    },
                    "CODE": {
                        "type": "string"
                    }
                }
            }
        }
    }
}