> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spojit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# FTP / SFTP

> Transfer files via FTP, FTPS, or SFTP: browse, upload, download, and manage remote files.

The FTP / SFTP connector lets your workflows transfer files to and from any FTP, FTPS, or SFTP server. Browse directories, upload and download files, and manage remote file systems directly from your workflows.

<Snippet file="connection-note.mdx" />

## Connection setup

<Steps>
  <Step title="Choose your protocol">
    Select **FTP** or **SFTP** depending on your server:

    * **FTP**: Standard file transfer (port 21). Optionally enable FTPS (TLS) for encrypted connections.
    * **SFTP**: SSH-based file transfer (port 22). Supports password or private key authentication.
  </Step>

  <Step title="Add the connection in Spojit">
    Go to **Connections** in Spojit, click **Add Connection**, select **FTP / SFTP**, and enter:

    * **Protocol**: `ftp` or `sftp`
    * **Host**: Your server hostname (e.g., `ftp.example.com`)
    * **Port**: Server port (`21` for FTP, `22` for SFTP)
    * **Username**: Your login username
    * **Password**: Your login password (optional for SFTP with private key)

    **FTP-only options:**

    * **Enable FTPS (TLS)**: Turn on for encrypted FTP connections

    **SFTP-only options:**

    * **SSH Private Key**: Paste your private key for key-based auth (password becomes optional)
  </Step>
</Steps>

<Note>
  **FTP vs SFTP**: Despite similar names, these are different protocols. FTP (and FTPS) uses the FTP protocol on port 21. SFTP uses SSH on port 22. Check with your server administrator which protocol is supported.
</Note>

<Tip>
  **Binary files**: Use `base64` encoding when downloading or uploading binary files (images, PDFs, archives). Text files use `utf8` by default.
</Tip>

<Tip>
  **SFTP private key auth**: Paste your full private key (including `-----BEGIN ... KEY-----` and `-----END ... KEY-----` lines) into the SSH Private Key field. When a private key is provided, the password field is optional.
</Tip>

## Tools

<AccordionGroup>
  <Accordion title="verify-connection: Test connection">
    Verifies that the server is reachable and the credentials are valid. No parameters required.

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "message": "SFTP connection verified successfully"
      }
    }
    ```
  </Accordion>

  <Accordion title="list-directory: List files and directories">
    <ParamField body="path" type="string">
      Remote directory path. Defaults to `/`.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026",
        "entries": [
          {
            "name": "orders.csv",
            "type": "file",
            "size": 24580,
            "modifiedAt": "2026-03-15T10:30:00.000Z"
          },
          {
            "name": "images",
            "type": "directory",
            "size": 0,
            "modifiedAt": "2026-03-10T08:00:00.000Z"
          },
          {
            "name": "report-march.pdf",
            "type": "file",
            "size": 1048576,
            "modifiedAt": "2026-04-01T14:22:00.000Z"
          }
        ]
      }
    }
    ```
  </Accordion>

  <Accordion title="create-directory: Create a directory">
    <ParamField body="path" type="string" required>
      Remote directory path to create. Intermediate directories are created automatically.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026/april"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026/april",
        "message": "Directory created"
      }
    }
    ```
  </Accordion>

  <Accordion title="remove-directory: Remove a directory">
    <ParamField body="path" type="string" required>
      Remote directory path to remove. The directory must be empty.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026/temp"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026/temp",
        "message": "Directory removed"
      }
    }
    ```
  </Accordion>

  <Accordion title="download-file: Download a file">
    <ParamField body="path" type="string" required>
      Remote file path to download.
    </ParamField>

    <ParamField body="encoding" type="string">
      Output encoding: `utf8` (default) for text files, `base64` for binary files.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026/orders.csv",
      "encoding": "utf8"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026/orders.csv",
        "content": "order_id,customer,total\n1001,John Smith,99.95\n1002,Jane Doe,149.50\n",
        "encoding": "utf8",
        "size": 68
      }
    }
    ```
  </Accordion>

  <Accordion title="upload-file: Upload a file">
    <ParamField body="path" type="string" required>
      Remote file path to upload to. Overwrites if the file already exists.
    </ParamField>

    <ParamField body="content" type="string" required>
      File content to upload.
    </ParamField>

    <ParamField body="encoding" type="string">
      Content encoding: `utf8` (default) for text, `base64` for binary.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026/inventory-update.csv",
      "content": "sku,qty\nSKU-001,50\nSKU-002,120\nSKU-003,0\n",
      "encoding": "utf8"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026/inventory-update.csv",
        "size": 42,
        "message": "File uploaded"
      }
    }
    ```
  </Accordion>

  <Accordion title="delete-file: Delete a file">
    <ParamField body="path" type="string" required>
      Remote file path to delete.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026/old-report.pdf"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026/old-report.pdf",
        "message": "File deleted"
      }
    }
    ```
  </Accordion>

  <Accordion title="rename: Rename or move a file/directory">
    <ParamField body="from" type="string" required>
      Current remote path.
    </ParamField>

    <ParamField body="to" type="string" required>
      New remote path.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "from": "/uploads/2026/orders.csv",
      "to": "/archive/2026/orders-march.csv"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "from": "/uploads/2026/orders.csv",
        "to": "/archive/2026/orders-march.csv",
        "message": "Renamed successfully"
      }
    }
    ```
  </Accordion>

  <Accordion title="get-file-info: Get file information">
    <ParamField body="path" type="string" required>
      Remote file path.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "path": "/uploads/2026/orders.csv"
    }
    ```

    **Example response:**

    ```json theme={null}
    {
      "success": true,
      "data": {
        "path": "/uploads/2026/orders.csv",
        "size": 24580,
        "modifiedAt": "2026-03-15T10:30:00Z"
      }
    }
    ```
  </Accordion>
</AccordionGroup>
