{
  "openapi": "3.0.0",
  "info": {
    "title": "Corebanq - Customers API",
    "description": "API endpoints for customer management",
    "version": "1.0.0"
  },
  "paths": {
    "/v1/customers": {
      "post": {
        "summary": "Create customer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomerInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Customer created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResponse"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List all customers",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Get customer by ID",
        "responses": {
          "200": {
            "description": "Customer details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update customer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomerInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Customer updated successfully"
          }
        }
      },
      "delete": {
        "summary": "Delete customer",
        "responses": {
          "200": {
            "description": "Customer deleted successfully"
          }
        }
      }
    },
    "/v1/customers/{id}/avatar": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "summary": "Get customer avatar",
        "responses": {
          "200": {
            "description": "Customer avatar",
            "content": {
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{id}/tariff": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "patch": {
        "summary": "Update customer tariff",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomerTariffInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tariff updated successfully"
          }
        }
      }
    },
    "/v1/customers/{id}/fx": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "patch": {
        "summary": "Update customer FX settings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomerFxInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "FX settings updated successfully"
          }
        }
      }
    },
    "/v1/customers/{id}/teams": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Invite team member",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TeamInviteInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Team member invited successfully"
          }
        }
      }
    },
    "/v1/customers/{id}/teams/{user_id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "user_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "patch": {
        "summary": "Update team member",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTeamMemberInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Team member updated successfully"
          }
        }
      },
      "delete": {
        "summary": "Remove team member",
        "responses": {
          "200": {
            "description": "Team member removed successfully"
          }
        }
      }
    },
    "/v1/customers/{id}/teams/{user_id}/resend": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "user_id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "post": {
        "summary": "Resend team invitation",
        "responses": {
          "200": {
            "description": "Invitation resent successfully"
          }
        }
      }
    },
    "/v1/customers/search": {
      "get": {
        "summary": "Search customers",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["individual", "business"]
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["active", "inactive", "pending", "blocked"]
            }
          },
          {
            "name": "country",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomerResponse"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{id}/kyc": {
      "put": {
        "summary": "Update KYC status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateKYCInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KYC status updated successfully"
          }
        }
      }
    },
    "/v1/customers/{id}/documents": {
      "get": {
        "summary": "Get customer documents",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List of customer documents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DocumentResponse"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateCustomerInput": {
        "type": "object",
        "required": ["type", "first_name", "last_name", "email"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["individual", "business"]
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "date_of_birth": {
            "type": "string",
            "format": "date"
          },
          "nationality": {
            "type": "string"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "metadata": {
            "type": "object"
          }
        }
      },
      "UpdateCustomerInput": {
        "type": "object",
        "properties": {
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "metadata": {
            "type": "object"
          }
        }
      },
      "CustomerResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "date_of_birth": {
            "type": "string"
          },
          "nationality": {
            "type": "string"
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "kyc_status": {
            "type": "string"
          },
          "verification_level": {
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Address": {
        "type": "object",
        "properties": {
          "street": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "postal_code": {
            "type": "string"
          },
          "country": {
            "type": "string"
          }
        }
      },
      "UpdateKYCInput": {
        "type": "object",
        "required": ["status", "verification_level"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["pending", "verified", "rejected"]
          },
          "verification_level": {
            "type": "string",
            "enum": ["basic", "advanced", "full"]
          },
          "verified_at": {
            "type": "string",
            "format": "date-time"
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentInput"
            }
          }
        }
      },
      "DocumentInput": {
        "type": "object",
        "required": ["type", "number", "expiry_date", "country"],
        "properties": {
          "type": {
            "type": "string"
          },
          "number": {
            "type": "string"
          },
          "expiry_date": {
            "type": "string",
            "format": "date"
          },
          "country": {
            "type": "string"
          }
        }
      },
      "DocumentResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string"
          },
          "number": {
            "type": "string"
          },
          "expiry_date": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "uploaded_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UpdateCustomerTariffInput": {
        "type": "object",
        "properties": {
          "tariff": {
            "type": "string"
          }
        }
      },
      "UpdateCustomerFxInput": {
        "type": "object",
        "properties": {
          "fx_settings": {
            "type": "string"
          }
        }
      },
      "TeamInviteInput": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string"
          }
        }
      },
      "UpdateTeamMemberInput": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string"
          }
        }
      }
    }
  }
} 