Overview
You can use this request to import contacts via an SFTP client.
The Method
Type | Request | Method |
---|---|---|
REST | POST | https://[Your URL]/api/2.0/imports/sftp |
Your URL is the address of your install.
Your method must be structured as follows:
ImportFtpImports(\struct | array $credentials, $mappings, $listIds, $settings) : obj
Parameters
You will need the following parameters before you can use this API request:
Property | Type | Description | Required |
---|---|---|---|
$credentials | string | The credentials required to log into the SFTP server. | yes |
$mappings | array | A list of mappings where the key is the field to map, and the value is the position of the field in the CSV file E.g. Array(‘email’ => 0, ‘name’ => 2) (email will be the first column in the CSV and name will be the third column in the CSV) | yes |
$listIds | array | An array of list IDs to import into. E.g. Array(1, 2) will import into list 1 and 2 provided they exist. | yes |
$settings | array | An array of settings you need for the list. | yes |
Properties
When filling out the $credentials and $settings parameters, you will need the following properties:
$credentials
Property | Type | Description | Default | Required | Read Only |
---|---|---|---|---|---|
Hostname | string | The SFTP hostname to connect to. | empty | yes | yes |
Username | string | The username to use when connecting to the SFTP host. | empty | yes | yes |
Password | string | The password to use when connecting to the SFTP. | empty | yes | yes |
Port | string | The SFTP port | 21 | yes | yes |
File | string | The location of the file on the SFTP server | empty | yes | yes |
$settings
Property | Type | Description | Default | Required |
---|---|---|---|---|
Update_duplicates | string | Yes/No instruction on whether or not to update duplicates. | yes | yes |
Update_using | string | The ID to use when updating. Choose between: none / unique_id / system_id (This field must be used together with custom_key_position) | none | yes |
Custom_key_position | string | Position of custom key in file. | empty | yes |
Delimeter | string | The delimiter used to separate values in the import. You can choose between ‘comma’, ‘semicolon’, ‘pipe’, ‘tab’. | comma | yes |
Progress_email_address | string | Email address to send the import report to. | empty | yes |
Code Samples
<?php $request = new HttpRequest(); $request->setUrl('<URL>/api/2.0/imports/sftp'); $request->setMethod(HTTP_METH_POST); $request->setHeaders(array( 'content-type' => 'application/json', 'authorization' => 'Basic YWRtaW5pc3RyYXRvcjpqSVYxT==' )); $request->setBody('{ "credentials": { "hostname": "127.0.0.1", "username": "vagrant", "password": "vagrant", "post": "22", "file": "ftp_test.txt" }, "mappings": { "email": "1", "lastname": "2" }, "listIds": [1], "settings": { "update_duplicates": "yes", "delimiter": "comma" } } '); try { $response = $request->send(); echo $response->getBody(); } catch (HttpException $ex) { echo $ex; }