{
  "openapi": "3.0.0",
  "info": {
    "title": "Corebanq - Accounts API",
    "description": "API endpoints for managing bank accounts",
    "version": "1.0.0"
  },
  "paths": {
    "/v1/accounts": {
      "get": {
        "summary": "Get all accounts",
        "responses": {
          "200": {
            "description": "List of accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AccountResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create new account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccountInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}": {
      "get": {
        "summary": "Get account by ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update account",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete account",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Account deleted successfully"
          }
        }
      }
    },
    "/v1/accounts/customer/{id}": {
      "get": {
        "summary": "Get customer accounts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of customer accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AccountResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/balance": {
      "post": {
        "summary": "Get accounts balance",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountsBalanceInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account balance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balance": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/balance/currency": {
      "post": {
        "summary": "Get accounts balance by currency",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountsBalanceInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account balance in specified currency",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balance": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateAccountInput": {
        "type": "object",
        "required": ["customer_id", "currency"],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3
          },
          "description": {
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "active": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "UpdateAccountInput": {
        "type": "object",
        "required": ["customer_id"],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3
          },
          "description": {
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "AccountsBalanceInput": {
        "type": "object",
        "required": ["customer_id", "currency"],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string",
            "minLength": 3,
            "maxLength": 3
          }
        }
      },
      "AccountResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "active": {
            "type": "boolean"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "currency": {
            "type": "string"
          },
          "balance": {
            "type": "number"
          },
          "iban": {
            "type": "string"
          },
          "country_code": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "country_id": {
            "type": "string",
            "format": "uuid"
          },
          "check_digits": {
            "type": "string"
          },
          "bban": {
            "type": "string"
          },
          "bank": {
            "type": "string"
          },
          "bic": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "metadata": {
            "type": "object"
          }
        }
      }
    }
  }
} 