{
  "openapi": "3.1.0",
  "info": {
    "title": "IO Intelligence",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.io.solutions"
    }
  ],
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/api-keys/sub-keys/{key_id}": {
      "patch": {
        "tags": [
          "Sub-API Keys"
        ],
        "summary": "Update Sub-API Key",
        "description": "Updates one or more attributes of an existing sub-API key. Only the fields included in the request body are modified \u2014 omitted fields retain their current values. Pass an empty array for `allowed_models` to remove all model restrictions.",
        "operationId": "update_sub_key",
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Key ID"
            },
            "description": "UUID of the sub-key to update."
          },
          {
            "name": "x-api-key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Admin API key (io.net Intelligence)",
              "title": "X-Api-Key"
            },
            "description": "Admin API key that owns the sub-key."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSubKeyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sub-key updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                },
                "example": {
                  "status": "succeeded"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key"
          },
          "404": {
            "description": "Sub-API key not found or not owned by this admin"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "oauth2",
        "flows": {}
      }
    },
    "schemas": {
      "UpdateSubKeyRequest": {
        "type": "object",
        "title": "UpdateSubKeyRequest",
        "description": "All fields are optional. Only provided fields are updated.",
        "properties": {
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "default": null
          },
          "allowed_models": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "New model allow-list. Pass an empty array [] to remove all restrictions."
              },
              {
                "type": "null"
              }
            ],
            "title": "Allowed Models",
            "default": null
          },
          "credit_limit": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0
              },
              {
                "type": "null"
              }
            ],
            "title": "Credit Limit",
            "description": "New per-cycle credit cap. Set to a higher value to unblock a key that has exceeded its limit.",
            "default": null
          },
          "credit_refresh_cycle": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "8h",
                  "daily",
                  "weekly",
                  "monthly"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Credit Refresh Cycle",
            "default": null
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "string",
                "enum": [
                  "never"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires At",
            "default": null
          }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "title": "SuccessResponse",
        "properties": {
          "status": {
            "type": "string",
            "example": "succeeded"
          }
        }
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      }
    }
  }
}