Customer SFTP imports
Remove one remote import file
/a/ImportCustomersFtp_unlink
Delete a named remote file from an account-owned SFTP source.
When to use this endpoint
This is the worker’s post-import removal step. It is not a source-configuration delete, archive or reversible customer rollback.
Authentication and permissions
Use signed API-key authentication or a logged-in CRM session. API keys act as their owner; session requests use dispatcher CSRF protection when configured.
Requires a valid tenant account and View on pageImportsCustomersFtp plus Edit. Source IDs and counts are restricted to the authenticated account owner; client-supplied ownership cannot expand access.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Positive integer or decimal integer string | Yes | Use the source or tenant row ID returned by its list/table. Fractions, negative numbers, arrays and out-of-range integers are rejected. This is not the import run token. |
fname | Exact remote basename | Yes | Exact visible basename, maximum 255 bytes. Permitted characters are word/space/digit characters and - _ ~ , ; [ ] ( ) .; paths, repeated dots, dot-prefixed names and empty names are rejected. |
Example request
$result = FM_api('ImportCustomersFtp_unlink', ['id'=>'18','fname'=>'customers.csv']);
Example response
{
"ok": 1
}
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error": "permission denied"} | The user lacks the required Imports page action. |
{"error": "missing or invalid parameter: id"} | A required row ID is missing or invalid. |
{"error": "no such entry"} | The requested owned source or tenant row does not exist. |
{"error": "Unable to connect to SFTP server"} | The saved server cannot be connected to. |
{"error": "SSH verification failed"} | Password authentication failed. |
{"error": "Unable to open remote directory"} | The configured directory cannot be opened. |
{"error": "plain FTP not yet handled"} | The source uses the legacy ftp option. |
{"error": "Remote file not found"} | The exact visible regular file is absent. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Uses saved credentials for password-authenticated SFTP on SSH port 22. Plain ftp returns "plain FTP not yet handled". There is no configurable port, private-key authentication or explicit host-key pinning in this implementation.
- Normalizes the configured directory to an absolute SFTP path. Only qualified remote regular files are selected; hidden names, directories and symlinks are excluded. Filenames are sorted bytewise. No extension filter or paging is applied.
- Requires an exact regular-file basename and checks unlink success. Returns only {ok:1}; no source metadata or password. The current shared path rejects files above 32 MiB. Worker cleanup additionally verifies the imported content signature before removing a file.
Side effects
- Removes one remote file after checked SFTP lookup. Does not remove source configuration, mappings, customers or history.
See it in Fieldmotion
CRM1
In CRM1, open Settings > Imports > Customers FTP. No separate literal unlink UI call was found; Run Once performs checked remote cleanup through the worker.
CRM2
In CRM2, open Imports > Customers FTP. No standalone action was found; Run Once invokes the same worker cleanup.
Related endpoints
ImportCustomersFtp_save— Configure an owned source.ImportsCustomersFtp_getDataTable— Discover source rows and IDs.ImportCustomersFtp_getImportMaps— Inspect map choices before running.ImportCustomersFtp_runOnce— Understand import writes and remote cleanup.