{
  "openapi": "3.0.0",
  "info": {
    "title": "x-gateway-external-api",
    "contact": {}
  },
  "servers": [
    {
      "url": "https://api.xgateway.tech/api/v2"
    }
  ],
  "paths": {
    "/customer/{id}/bank-transfer/kyc/document": {
      "put": {
        "operationId": "UploadKycDocument",
        "responses": {
          "204": {
            "description": "No Content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppSuccessResponse_null_"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppValidationErrorResponse"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "errors": [
                        {
                          "code": "db_violation",
                          "message": "The request failed because it violated a database constraint."
                        }
                      ],
                      "success": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppAuthenticationErrorResponse"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "errors": [
                        {
                          "code": "unauthorized",
                          "message": "You do not have permission to access this resource."
                        }
                      ],
                      "success": false
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable content",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppValidationErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppErrorResponse"
                }
              }
            }
          }
        },
        "description": "Uploads a KYC (Know Your Customer) document for a specified customer.\r\n\r\nAccess to this endpoint requires a valid API key. The API key is sent in the `x-api-key` header.\r\n\r\nPreconditions:\r\n- The customer must have a user profile (see POST /customer/{id}/bank-transfer/user).\r\n- The customer must have a KYC applicant (see POST /customer/{id}/bank-transfer/kyc/applicant).\r\n\r\nSupported Document Types:\r\nOne-sided documents (require `documentType`, `content`, `country`):\r\n- PASSPORT\r\n- RESIDENCE_PERMIT.\r\n- UTILITY_BILL\r\n- SELFIE.\r\n\r\nTwo-sided documents (require `documentType`, `documentSubType`, `content`, `country`):\r\n- DRIVERS\r\n- ID_CARD\r\n- RESIDENCE_PERMIT.\r\n\r\nParameters:\r\n- `documentType`: Type of document being uploaded.\r\n- `documentSubType`: \"FRONT_SIDE\" or \"BACK_SIDE\" for two-sided documents.\r\n- `content`: Base64-encoded document image. Must not exceed 500KB.\r\n- `country`: Two-letter ISO 3166-1 alpha-2 country code.",
        "summary": "Uploads a KYC document for a customer.",
        "tags": [
          "Customer"
        ],
        "security": [
          {
            "api_key": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadKycDocumentInput"
              },
              "examples": {
                "Example 1": {
                  "value": {
                    "documentType": "PASSPORT",
                    "content": "iVBORw0KGgoAAAANSUhEUgAA...",
                    "country": "US"
                  }
                },
                "Example 2": {
                  "value": {
                    "documentType": "DRIVERS",
                    "documentSubType": "FRONT_SIDE",
                    "content": "iVBORw0KGgoAAAANSUhEUgAA...",
                    "country": "AU"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AppClientErrorResponseCode": {
        "type": "string",
        "enum": [
          "bad_request",
          "db_violation",
          "unauthorized",
          "payment_required",
          "forbidden",
          "not_found",
          "method_not_allowed",
          "not_acceptable",
          "proxy_authentication_required",
          "request_timeout",
          "conflict",
          "db_unique_violation",
          "gone",
          "length_required",
          "precondition_failed",
          "payload_too_large",
          "uri_too_long",
          "unsupported_media_type",
          "range_not_satisfiable",
          "expectation_failed",
          "misdirected_request",
          "unprocessable_content",
          "db_non_null_violation",
          "locked",
          "failed_dependency",
          "upgrade_required",
          "precondition_required",
          "too_many_requests",
          "request_header_fields_too_large",
          "unavailable_for_legal_reasons"
        ],
        "nullable": false,
        "description": "The AppClientErrorResponseCode object contains all client error response codes."
      },
      "AppServerErrorResponseCode": {
        "type": "string",
        "enum": [
          "internal_server_error",
          "not_implemented",
          "bad_gateway",
          "service_unavailable",
          "gateway_timeout",
          "http_version_not_supported",
          "variant_also_negotiates",
          "insufficient_storage",
          "loop_detected",
          "not_extended",
          "network_authentication_required"
        ],
        "nullable": false,
        "description": "The AppServerErrorResponseCode object contains all server error response codes."
      },
      "IAppError": {
        "description": "The IAppError interface represents an application error message.",
        "properties": {
          "code": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AppClientErrorResponseCode"
              },
              {
                "$ref": "#/components/schemas/AppServerErrorResponseCode"
              }
            ]
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "AppErrorResponse": {
        "description": "The AppErrorResponse object contains general information about the error message.",
        "properties": {
          "success": {
            "type": "boolean",
            "default": false
          },
          "errors": {
            "items": {
              "$ref": "#/components/schemas/IAppError"
            },
            "type": "array"
          }
        },
        "required": [
          "success",
          "errors"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "AppAuthenticationErrorResponse": {
        "description": "The AppAuthenticationErrorResponse object contains general information about the authentication\r\nerror.",
        "properties": {
          "success": {
            "type": "boolean",
            "default": false
          },
          "errors": {
            "items": {
              "$ref": "#/components/schemas/IAppError"
            },
            "type": "array",
            "default": [
              {
                "code": "unauthorized",
                "message": "You do not have permission to access this resource."
              }
            ]
          }
        },
        "required": [
          "success",
          "errors"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "AppValidationErrorResponse": {
        "description": "The AppValidationErrorResponse object contains general information about the validation error.",
        "properties": {
          "success": {
            "type": "boolean",
            "default": false
          },
          "errors": {
            "items": {},
            "type": "array"
          }
        },
        "required": [
          "success",
          "errors"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "UnblockKYCDocType.Selfie": {
        "enum": [
          "SELFIE"
        ],
        "type": "string"
      },
      "UnblockKYCDocType.Passport": {
        "enum": [
          "PASSPORT"
        ],
        "type": "string"
      },
      "UnblockKYCDocType.IdCard": {
        "enum": [
          "ID_CARD"
        ],
        "type": "string"
      },
      "UnblockKYCDocType.Drivers": {
        "enum": [
          "DRIVERS"
        ],
        "type": "string"
      },
      "AppSuccessResponse_null_": {
        "description": "The AppSuccessResponse object contains general information about the success execution.",
        "properties": {
          "success": {
            "type": "boolean",
            "default": true
          },
          "data": {
            "type": "number",
            "enum": [
              null
            ],
            "nullable": true
          }
        },
        "required": [
          "success",
          "data"
        ],
        "type": "object",
        "additionalProperties": false
      },
      "UnblockKYCDocSubtype": {
        "enum": [
          "FRONT_SIDE",
          "BACK_SIDE"
        ],
        "type": "string"
      },
      "UnblockKYCDocType.UtilityBill": {
        "enum": [
          "UTILITY_BILL"
        ],
        "type": "string"
      },
      "UnblockKYCDocType.ResidencePermit": {
        "enum": [
          "RESIDENCE_PERMIT"
        ],
        "type": "string"
      },
      "UploadKycDocumentInput": {
        "anyOf": [
          {
            "properties": {
              "country": {
                "type": "string"
              },
              "content": {
                "type": "string"
              },
              "documentSubType": {
                "$ref": "#/components/schemas/UnblockKYCDocSubtype"
              },
              "documentType": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/UnblockKYCDocType.Drivers"
                  },
                  {
                    "$ref": "#/components/schemas/UnblockKYCDocType.IdCard"
                  }
                ]
              }
            },
            "required": [
              "country",
              "content",
              "documentSubType",
              "documentType"
            ],
            "type": "object"
          },
          {
            "properties": {
              "country": {
                "type": "string"
              },
              "content": {
                "type": "string"
              },
              "documentType": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/UnblockKYCDocType.Passport"
                  },
                  {
                    "$ref": "#/components/schemas/UnblockKYCDocType.Selfie"
                  },
                  {
                    "$ref": "#/components/schemas/UnblockKYCDocType.UtilityBill"
                  }
                ]
              }
            },
            "required": [
              "country",
              "content",
              "documentType"
            ],
            "type": "object"
          },
          {
            "properties": {
              "country": {
                "type": "string"
              },
              "content": {
                "type": "string"
              },
              "documentSubType": {
                "$ref": "#/components/schemas/UnblockKYCDocSubtype"
              },
              "documentType": {
                "$ref": "#/components/schemas/UnblockKYCDocType.ResidencePermit"
              }
            },
            "required": [
              "country",
              "content",
              "documentType"
            ],
            "type": "object"
          }
        ]
      }
    },
    "securitySchemes": {
      "api_key": {
        "in": "header",
        "name": "x-api-key",
        "type": "apiKey"
      }
    }
  }
}