Faxing

Table of Contents

Overview

This is where all the functions for dealing with faxing happens.

Controller: /fax
Full Url: https://apiv1.teleapi.net/fax/

Functions

/list

Full Url: https://apiv1.teleapi.net/fax/list

Arguments:

Info: List all the faxes for a given did_id

/get

Full Url: https://apiv1.teleapi.net/fax/get

Arguments:

Info: Get the actual fax data about a given fax_id. The file data itself is in base64 format. The mime type will almost always be application/pdf -- but it's there for you to check just in case

Example Response

{
    "code": 200,
    "status": "success",
    "data": {
        "id": 1,
        "did_id": 1,
        "fax_status": "read",
        "direction": "inbound",
        "source_did": "5555555555",
        "destination_did": "6666666666",
        "recipient": "Bobby Tables",
        "pages": 1,
        "fail_reason": null,
        "create_dt": "2017-05-01 00:00:00",
        "modify_dt": "2017-05-01 23:59:59",
        "data": "YXJlbid0IHlvdSBjbGV2ZXIgOi0p",
        "mime": "text/plain"
    }
}

/send

Full Url: https://apiv1.teleapi.net/fax/send

Arguments:

Info: This is sending a fax. For files itself, you can send more than one file (cover page, content, etc). We will put it all together and send it out. For this, we expect a JSON encoded array of the file data. I'll provide a bit of example PHP...

<?php
//setup token
$token = 'your token';

//setup the path to the files we want to send
$files = array(
    '/path/to/file1',
    '/path/to/file2'
);

//a very simple function you can copy/paste if you want
function send_fax($did_id, $destination, $recipient_name, $files) {
    global $token;
    //get the data and base64 the files
    foreach ($files as $i => $file) {
        $files[$i] = base64_encode(file_get_contents($file));
    }
    $data = array(
        'token' => $token,
        'did_id' => $did_id, //I'll fix this so you can send source, but this is how I use it so it's already written this way
        'destination' => $destination,
        'recipient' => $recipient,
        'files' => json_encode($files)
    );
    $data = http_build_query($data);
    $ch = curl_init('https://apiv1.teleapi.net/fax/send');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $resp = curl_exec($ch);
    return json_decode($resp);
}

//code that actually sends a fax -- provided you pass a real did_id and destination number. and file(s). 
$resp = send_fax(555, 5555555555, 'Bobby Tables', $files);
if ($resp->code == 200) {
    die("Successfully sent fax\n");
}
die("Could not send fax: " . print_r($resp, true));

/remove

Full Url: https://apiv1.teleapi.net/fax/remove

Arguments:

Info: This will permanently delete a fax from our servers

/emails/list

Full Url: https://apiv1.teleapi.net/fax/emails/list

Arguments:

Info: This will list all the email addresses that get the inbound faxes to the associated fax number

/emails/add

Full Url: https://apiv1.teleapi.net/fax/emails/add

Arguments:

Info: Add an additional email address to receive inbound faxes for associated fax number

/emails/remove

Full Url: https://apiv1.teleapi.net/fax/emails/remove

Arguments:

Info: Remove an email address as a recipeient of inbound faxes to a fax number