{
  "openapi": "3.1.0",
  "info": {
    "title": "Runware API - Account Management",
    "version": "1.0.0",
    "description": "Account management operation."
  },
  "servers": [
    {
      "url": "https://api.runware.ai/v1",
      "description": "Runware REST API"
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Runware API Key (e.g., Bearer <your-key>)"
      }
    },
    "schemas": {
      "AuthenticationTask": {
        "title": "Authentication",
        "description": "Authenticates a connection using an API key. Can be sent as the first element of the request array as an alternative to using the Authorization header.",
        "type": "object",
        "x-response-schema": "https://schemas.runware.ai/responses/utilities/authentication.json",
        "properties": {
          "taskType": {
            "const": "authentication",
            "title": "Task Type",
            "description": "The type of task to perform."
          },
          "apiKey": {
            "title": "API Key",
            "description": "Your Runware API key.",
            "type": "string"
          },
          "connectionSessionUUID": {
            "title": "Connection Session UUID",
            "description": "Optional session UUID to resume a previous connection and receive any buffered results.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "taskType",
          "apiKey"
        ],
        "additionalProperties": false
      },
      "RequestBody": {
        "type": "array",
        "items": {
          "title": "Account Management",
          "description": "Account management operation.",
          "type": "object",
          "properties": {
            "taskType": {
              "const": "accountManagement",
              "title": "Task Type",
              "description": "The type of task to perform."
            },
            "taskUUID": {
              "title": "Task UUID",
              "description": "UUID v4 identifier for tracking tasks and matching async responses. Must be unique per task.",
              "type": "string",
              "format": "uuid"
            },
            "operation": {
              "title": "Operation",
              "description": "The specific account management operation to perform.",
              "type": "string",
              "enum": [
                "getDetails"
              ]
            }
          },
          "required": [
            "taskType",
            "taskUUID",
            "operation"
          ],
          "additionalProperties": false
        },
        "description": "You must always POST an array of task objects."
      },
      "ResponseBody": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "title": "Account Management Response",
              "type": "object",
              "properties": {
                "taskType": {
                  "title": "Task Type",
                  "description": "Identifier for the type of task being performed",
                  "type": "string",
                  "const": "accountManagement"
                },
                "taskUUID": {
                  "title": "Task UUID",
                  "description": "UUID v4 identifier for tracking tasks and matching async responses. Must be unique per task.",
                  "type": "string",
                  "format": "uuid"
                },
                "organizationName": {
                  "title": "Organization Name",
                  "description": "The name of the organization.",
                  "type": "string"
                },
                "organizationUUID": {
                  "title": "Organization UUID",
                  "description": "Unique identifier for the organization.",
                  "type": "string",
                  "format": "uuid"
                },
                "balance": {
                  "title": "Balance",
                  "description": "Current account balance and currency.",
                  "type": "object",
                  "properties": {
                    "amount": {
                      "title": "Amount",
                      "description": "Current balance amount.",
                      "type": "number"
                    },
                    "freeBalance": {
                      "title": "Free Balance",
                      "description": "Available free credit balance.",
                      "type": "number"
                    },
                    "currency": {
                      "title": "Currency",
                      "description": "Currency code (e.g., USD).",
                      "type": "string"
                    }
                  },
                  "required": [
                    "amount",
                    "currency"
                  ],
                  "additionalProperties": false
                },
                "team": {
                  "title": "Team",
                  "description": "List of team members.",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "title": "Name",
                        "description": "Full name of the team member.",
                        "type": "string"
                      },
                      "email": {
                        "title": "Email",
                        "description": "Email address of the team member.",
                        "type": "string",
                        "format": "email"
                      },
                      "roles": {
                        "title": "Roles",
                        "description": "Roles assigned to the team member.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "Owner",
                            "Admin",
                            "Developer"
                          ]
                        }
                      },
                      "joinedAt": {
                        "title": "Joined At",
                        "description": "Date and time when the member joined.",
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": [
                      "name",
                      "email",
                      "roles"
                    ],
                    "additionalProperties": false
                  }
                },
                "apiKeys": {
                  "title": "API Keys",
                  "description": "List of API keys associated with the account.",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "apiKey": {
                        "title": "API Key",
                        "description": "The API key string (partially masked).",
                        "type": "string"
                      },
                      "name": {
                        "title": "Name",
                        "description": "Name or label for the API key.",
                        "type": "string"
                      },
                      "description": {
                        "title": "Description",
                        "description": "Description of the API key.",
                        "type": "string"
                      },
                      "enabled": {
                        "title": "Enabled",
                        "description": "Whether the API key is active.",
                        "type": "boolean"
                      },
                      "createdAt": {
                        "title": "Created At",
                        "description": "Date and time when the key was created.",
                        "type": "string",
                        "format": "date-time"
                      },
                      "lastUsedAt": {
                        "title": "Last Used At",
                        "description": "Date and time when the key was last used.",
                        "type": "string",
                        "format": "date-time"
                      },
                      "requests": {
                        "title": "Requests",
                        "description": "Total number of requests made with this key.",
                        "type": "integer"
                      }
                    },
                    "required": [
                      "apiKey",
                      "name",
                      "enabled",
                      "createdAt"
                    ],
                    "additionalProperties": false
                  }
                },
                "usage": {
                  "title": "Usage",
                  "description": "Usage statistics for different time periods.",
                  "type": "object",
                  "properties": {
                    "today": {
                      "title": "Today",
                      "description": "Usage stats for today.",
                      "type": "object",
                      "properties": {
                        "credits": {
                          "type": "number",
                          "description": "Total credits consumed."
                        },
                        "requests": {
                          "type": "integer",
                          "description": "Total API requests made."
                        }
                      },
                      "required": [
                        "credits",
                        "requests"
                      ],
                      "additionalProperties": false
                    },
                    "last7Days": {
                      "title": "Last 7 Days",
                      "description": "Usage stats for the last 7 days.",
                      "type": "object",
                      "properties": {
                        "credits": {
                          "type": "number",
                          "description": "Total credits consumed."
                        },
                        "requests": {
                          "type": "integer",
                          "description": "Total API requests made."
                        }
                      },
                      "required": [
                        "credits",
                        "requests"
                      ],
                      "additionalProperties": false
                    },
                    "last30Days": {
                      "title": "Last 30 Days",
                      "description": "Usage stats for the last 30 days.",
                      "type": "object",
                      "properties": {
                        "credits": {
                          "type": "number",
                          "description": "Total credits consumed."
                        },
                        "requests": {
                          "type": "integer",
                          "description": "Total API requests made."
                        }
                      },
                      "required": [
                        "credits",
                        "requests"
                      ],
                      "additionalProperties": false
                    },
                    "total": {
                      "title": "Total",
                      "description": "Total lifetime usage stats.",
                      "type": "object",
                      "properties": {
                        "credits": {
                          "type": "number",
                          "description": "Total credits consumed."
                        },
                        "requests": {
                          "type": "integer",
                          "description": "Total API requests made."
                        }
                      },
                      "required": [
                        "credits",
                        "requests"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "today",
                    "last7Days",
                    "last30Days",
                    "total"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "taskType",
                "taskUUID",
                "organizationName",
                "organizationUUID",
                "balance",
                "team",
                "apiKeys",
                "usage"
              ],
              "additionalProperties": false
            }
          }
        }
      },
      "ErrorResponse": {
        "title": "Error Response",
        "description": "Standard error response returned by the Runware API.",
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "code",
                "message"
              ],
              "additionalProperties": true,
              "properties": {
                "code": {
                  "type": "string",
                  "description": "A short identifier for the error (e.g., invalidApiKey, timeoutProvider)."
                },
                "message": {
                  "type": "string",
                  "description": "A human-readable explanation of what went wrong."
                },
                "parameter": {
                  "type": "string",
                  "description": "The request parameter related to the error, if applicable."
                },
                "taskType": {
                  "type": "string",
                  "description": "The task type of the request that failed."
                },
                "taskUUID": {
                  "type": "string",
                  "description": "The unique identifier of the failed request."
                },
                "documentation": {
                  "type": "string",
                  "description": "A link to relevant documentation."
                }
              }
            }
          }
        },
        "required": [
          "errors"
        ],
        "additionalProperties": false
      }
    }
  },
  "paths": {
    "/": {
      "post": {
        "summary": "Run Account Management",
        "description": "Account management operation.",
        "operationId": "run_account_management",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseBody"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — Missing or invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — No valid API key provided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required — Insufficient account balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — The API key lacks permissions for this request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests — Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server Error — Something went wrong on Runware's end.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable — Temporarily unavailable (maintenance or capacity).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}