Upload an account file
Imports accounts from a CSV file into a campaign, using one of your saved import formats to map the columns.
The file is processed in the background after the upload is accepted.
Parameters
Send as application/x-www-form-urlencoded or, with a file, multipart/form-data.
typestringrequiredSelects the operation. Always
upload_filefor this endpoint.tokenstringrequiredYour API token from Log in. See Authentication.
ID of the campaign.
Example1024ID of the import format (column mapping) to apply.
Example12The CSV file to upload.
File type. Defaults to csv.
One ofcsv
curl https://api.dcdial.com/api/ \ -F type=upload_file \ -F token="$DCDIAL_TOKEN" \ -F campaign_id=1024 \ -F format=12 \<?php$ch = curl_init('https://api.dcdial.com/api/');curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => [ 'type' => 'upload_file', 'token' => getenv('DCDIAL_TOKEN'), 'campaign_id' => 1024, 'format' => '12', 'data' => new CURLFile('accounts.csv'), ],]);$result = json_decode(curl_exec($ch), true);curl_close($ch);
if (($result['response']['success'] ?? 0) != 1) { throw new RuntimeException($result['response']['error'] ?? 'Request failed');}import { readFile } from 'node:fs/promises';
const body = new FormData();body.append('type', "upload_file");body.append('token', process.env.DCDIAL_TOKEN);body.append('campaign_id', "1024");body.append('format', "12");body.append('data', new Blob([await readFile('accounts.csv')]), 'accounts.csv');
const res = await fetch('https://api.dcdial.com/api/', { method: 'POST', body });const { response } = await res.json();if (response.success != 1) throw new Error(response.error);import osimport requests
r = requests.post( "https://api.dcdial.com/api/", data={ "type": "upload_file", "token": os.environ["DCDIAL_TOKEN"], "campaign_id": 1024, "format": "12", }, files={"data": open("accounts.csv", "rb")}, timeout=30,)response = r.json()["response"]if str(response.get("success")) != "1": raise RuntimeError(response.get("error")){ "response": { "success": 1, "error": "", "message": "File uploaded and queued for processing" }}Try it