{
  "swagger": "2.0",
  "info": {
    "title": "Zetaleap SFTP Gateway",
    "description": "Connect Power Automate to SFTP and FTP servers using SSH Private Keys (PEM) or passwords without 504 timeouts, list remote folders, download files, and sync with Cloud Vault.",
    "version": "1.0.0",
    "contact": {
      "name": "Zetaleap Support Team",
      "url": "https://zetaleap.com/#contact",
      "email": "support_team@zetaleap.com"
    }
  },
  "x-ms-connector-metadata": [
    {
      "propertyName": "Website",
      "propertyValue": "https://zetaleap.com"
    },
    {
      "propertyName": "Privacy policy",
      "propertyValue": "https://zetaleap.com/privacy"
    },
    {
      "propertyName": "Categories",
      "propertyValue": "IT Operations;Data"
    }
  ],
  "host": "test.zetaleap.com",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "api_key": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Enter your Zetaleap Personal Access Token prefixed with Bearer (example: Bearer zl_your_api_token). Generate tokens free at https://zetaleap.com/profile."
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "paths": {
    "/api/sftp/companies": {
      "get": {
        "tags": [
          "SFTP Gateway"
        ],
        "operationId": "ListSftpProfiles",
        "summary": "List saved SFTP and FTP connection profiles",
        "description": "Returns all saved SFTP/FTP server connection profiles accessible by the authenticated token.",
        "x-ms-visibility": "important",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "List of saved SFTP connection profiles",
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean",
                  "x-ms-summary": "Success"
                },
                "companies": {
                  "type": "array",
                  "x-ms-summary": "Connection Profiles",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "x-ms-summary": "Connection ID"
                      },
                      "display_name": {
                        "type": "string",
                        "x-ms-summary": "Display Name"
                      },
                      "protocol": {
                        "type": "string",
                        "x-ms-summary": "Protocol (sftp/ftp)"
                      },
                      "host": {
                        "type": "string",
                        "x-ms-summary": "Server Hostname"
                      },
                      "port": {
                        "type": "integer",
                        "format": "int32",
                        "x-ms-summary": "Port"
                      },
                      "username": {
                        "type": "string",
                        "x-ms-summary": "SSH/FTP Username"
                      },
                      "root_path": {
                        "type": "string",
                        "x-ms-summary": "Default Root Path"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/sftp/{companyId}": {
      "get": {
        "tags": [
          "SFTP Gateway"
        ],
        "operationId": "ListSftpDirectory",
        "summary": "List files in remote SFTP or FTP folder",
        "description": "Connects over SSH Private Key (PEM) or password via Zetaleap Gateway and lists files and folders in the target remote directory without Power Automate timeout errors.",
        "x-ms-visibility": "important",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "type": "string",
            "required": true,
            "x-ms-summary": "Connection Profile ID",
            "description": "Saved connection slug (e.g. rebex or erp-prod)."
          },
          {
            "name": "path",
            "in": "query",
            "type": "string",
            "required": false,
            "default": "/",
            "x-ms-summary": "Remote Directory Path",
            "description": "Remote SFTP folder path to list (default: /)."
          }
        ],
        "responses": {
          "200": {
            "description": "Remote directory contents",
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean",
                  "x-ms-summary": "Success"
                },
                "target_path": {
                  "type": "string",
                  "x-ms-summary": "Resolved Remote Path"
                },
                "target_dir_files": {
                  "type": "array",
                  "x-ms-summary": "Remote Files and Folders",
                  "items": {
                    "type": "object",
                    "properties": {
                      "filename": {
                        "type": "string",
                        "x-ms-summary": "File or Folder Name"
                      },
                      "is_directory": {
                        "type": "boolean",
                        "x-ms-summary": "Is Directory"
                      },
                      "size": {
                        "type": "integer",
                        "format": "int64",
                        "x-ms-summary": "Size in Bytes"
                      },
                      "modified_time": {
                        "type": "string",
                        "x-ms-summary": "Last Modified ISO Date"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/sftp/{companyId}/download": {
      "get": {
        "tags": [
          "SFTP Gateway"
        ],
        "operationId": "DownloadSftpFile",
        "summary": "Download file from remote SFTP or FTP server",
        "description": "Streams a binary or text file directly from the remote SFTP/FTP server into Power Automate.",
        "x-ms-visibility": "important",
        "produces": [
          "application/octet-stream"
        ],
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "type": "string",
            "required": true,
            "x-ms-summary": "Connection Profile ID",
            "description": "Saved connection slug (e.g. rebex or erp-prod)."
          },
          {
            "name": "file",
            "in": "query",
            "type": "string",
            "required": true,
            "x-ms-summary": "Remote File Path",
            "description": "Full remote file path to download (e.g. /outbound/readme.txt)."
          }
        ],
        "responses": {
          "200": {
            "description": "File binary stream",
            "schema": {
              "type": "string",
              "format": "binary"
            }
          }
        }
      }
    },
    "/api/sftp/r2/files": {
      "get": {
        "tags": [
          "SFTP Gateway"
        ],
        "operationId": "ListSftpVaultFiles",
        "summary": "List synced SFTP files in Cloud Vault",
        "description": "Lists files archived into Zetaleap R2 Storage Vault by automated SFTP sync schedules.",
        "x-ms-visibility": "advanced",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Archived vault files",
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean",
                  "x-ms-summary": "Success"
                },
                "files": {
                  "type": "array",
                  "x-ms-summary": "Vault Files",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string",
                        "x-ms-summary": "Storage Object Key"
                      },
                      "filename": {
                        "type": "string",
                        "x-ms-summary": "File Name"
                      },
                      "connection_id": {
                        "type": "string",
                        "x-ms-summary": "Source Connection ID"
                      },
                      "size": {
                        "type": "integer",
                        "format": "int64",
                        "x-ms-summary": "File Size (Bytes)"
                      },
                      "uploaded": {
                        "type": "string",
                        "x-ms-summary": "Uploaded Timestamp"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}