const axios = require('axios');
const fs = require('fs');
const FilesApiFp = require('@alohi/faxplus-api').FilesApiFp;
const Configuration = require('@alohi/faxplus-api').Configuration;
const config = new Configuration({
accessToken: accessToken,
basePath: 'https://restapi.fax.plus/v3',
// Header required only when using the OAuth2 token scheme
baseOptions: {
headers: {
"x-fax-clientid": clientId,
}
}
});
async function uploadFile() {
// IMPORTANT: fs.createReadStream() requires a local file system path.
// It does NOT support URLs or remote streams.
//
// If your file is stored remotely (e.g., AWS S3, Google Cloud Storage, or HTTP URL),
// you must first download it to a local path or load it into memory as a Blob.
const reqParams = {
"userId": '13d8z73c',
"faxFile": fs.createReadStream(FILE_PATH) // FILE_PATH must be a local file path
}
const req = await FilesApiFp(config).uploadFile(reqParams);
const resp = await req(axios);
}
uploadFile()
from faxplus import ApiClient, FilesApi
from faxplus.configuration import Configuration
conf = Configuration()
conf.access_token = access_token
# header_name and header_value required only when using the OAuth2 token scheme
api_client = ApiClient(header_name='x-fax-clientid', header_value=client_id, configuration=conf)
api = FilesApi(api_client)
resp = api.upload_file(
user_id='13d8z73c',
fax_file='/path/to/file.pdf'
)
/**
* Example below uses Apache HTTP Client 4 with Fluent API
**/
Map<String, String> pathParams = new HashMap<>();
pathParams.put("user_id", "'13d8z73c'");
StrSubstitutor sub = new StrSubstitutor(values, "{", "}");
String url = sub.replace("https://restapi.fax.plus/v3/accounts/{user_id}/files");
HttpEntity entity = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.setCharset(Charset.forName(CHARSET))
.addBinaryBody("fax_file", bytes, ContentType.MULTIPART_FORM_DATA, "fax.pdf")
.build();
String result = Request
.Post(url)
// The x-fax-clientid header is required only when using the OAuth2 token scheme
.addHeader("x-fax-clientid", "YOUR CLIENT_ID")
.addHeader("Content-Type", "'multipart/form-data'")
.addHeader("Accept", "'application/json'")
.addHeader("Authorization", "'Bearer {access-token}'")
.body(entity)
.execute()
.returnContent().asString();
System.out.println(result.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
// The x-fax-clientid header is required only when using the OAuth2 token scheme
"Content-Type": []string{"multipart/form-data"},
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
"x-fax-clientid": []string{"YOUR CLIENT_ID"}
}
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
fax_file_part, err := writer.CreateFormFile('fax_file', filepath.Base('fax.pdf'))
_, err = io.Copy(part, file)
req, err := http.NewRequest("POST", "https://restapi.fax.plus/v3/accounts/{user_id}/files", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}',
// The x-fax-clientid header is required only when using the OAuth2 token scheme
'x-fax-clientid' => '{client ID}',
);
$client = new GuzzleHttp\Client();
try {
$response = $client->request('POST','https://restapi.fax.plus/v3/accounts/{user_id}/files', array(
'headers' => $headers,
'multipart' => [
[
'name' => 'fax_file',
'contents' => fopen('fax.pdf', 'r')
],
],)
);
print_r($response->getBody()->getContents());
}
catch (GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
# You can also use wget
curl -X POST https://restapi.fax.plus/v3/accounts/{user_id}/files \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}' \
# The x-fax-clientid header is required only when using the OAuth2 token scheme
-H 'x-fax-clientid: "YOUR CLIENT_ID"' \
-F 'fax_file=@fax.pdf'
{
"path": "/storage/2937237320213-213-21323"
}{
"error": "invalid_user_id",
"description": "Invalid user id given"
}{
"error": "internal_server_error",
"description": "An unexpected error happened, please contact support"
}Files
Upload a file
Before sending a fax you need to upload your files using this API. In order to upload your fax file, you have to send a multipart/form-data request with your file. Set the name to fax_file, filename to your file’s name with extension, and the Content-Type to the file’s MIME type. In most cases, the filename directive will be automatically added by your library of choice. If the upload was successful you would receive a file_path which you can use to send your fax. (Permitted scopes: fax:all:edit, fax:file:edit)
POST
/
accounts
/
{user_id}
/
files
const axios = require('axios');
const fs = require('fs');
const FilesApiFp = require('@alohi/faxplus-api').FilesApiFp;
const Configuration = require('@alohi/faxplus-api').Configuration;
const config = new Configuration({
accessToken: accessToken,
basePath: 'https://restapi.fax.plus/v3',
// Header required only when using the OAuth2 token scheme
baseOptions: {
headers: {
"x-fax-clientid": clientId,
}
}
});
async function uploadFile() {
// IMPORTANT: fs.createReadStream() requires a local file system path.
// It does NOT support URLs or remote streams.
//
// If your file is stored remotely (e.g., AWS S3, Google Cloud Storage, or HTTP URL),
// you must first download it to a local path or load it into memory as a Blob.
const reqParams = {
"userId": '13d8z73c',
"faxFile": fs.createReadStream(FILE_PATH) // FILE_PATH must be a local file path
}
const req = await FilesApiFp(config).uploadFile(reqParams);
const resp = await req(axios);
}
uploadFile()
from faxplus import ApiClient, FilesApi
from faxplus.configuration import Configuration
conf = Configuration()
conf.access_token = access_token
# header_name and header_value required only when using the OAuth2 token scheme
api_client = ApiClient(header_name='x-fax-clientid', header_value=client_id, configuration=conf)
api = FilesApi(api_client)
resp = api.upload_file(
user_id='13d8z73c',
fax_file='/path/to/file.pdf'
)
/**
* Example below uses Apache HTTP Client 4 with Fluent API
**/
Map<String, String> pathParams = new HashMap<>();
pathParams.put("user_id", "'13d8z73c'");
StrSubstitutor sub = new StrSubstitutor(values, "{", "}");
String url = sub.replace("https://restapi.fax.plus/v3/accounts/{user_id}/files");
HttpEntity entity = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.setCharset(Charset.forName(CHARSET))
.addBinaryBody("fax_file", bytes, ContentType.MULTIPART_FORM_DATA, "fax.pdf")
.build();
String result = Request
.Post(url)
// The x-fax-clientid header is required only when using the OAuth2 token scheme
.addHeader("x-fax-clientid", "YOUR CLIENT_ID")
.addHeader("Content-Type", "'multipart/form-data'")
.addHeader("Accept", "'application/json'")
.addHeader("Authorization", "'Bearer {access-token}'")
.body(entity)
.execute()
.returnContent().asString();
System.out.println(result.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
// The x-fax-clientid header is required only when using the OAuth2 token scheme
"Content-Type": []string{"multipart/form-data"},
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
"x-fax-clientid": []string{"YOUR CLIENT_ID"}
}
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
fax_file_part, err := writer.CreateFormFile('fax_file', filepath.Base('fax.pdf'))
_, err = io.Copy(part, file)
req, err := http.NewRequest("POST", "https://restapi.fax.plus/v3/accounts/{user_id}/files", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}',
// The x-fax-clientid header is required only when using the OAuth2 token scheme
'x-fax-clientid' => '{client ID}',
);
$client = new GuzzleHttp\Client();
try {
$response = $client->request('POST','https://restapi.fax.plus/v3/accounts/{user_id}/files', array(
'headers' => $headers,
'multipart' => [
[
'name' => 'fax_file',
'contents' => fopen('fax.pdf', 'r')
],
],)
);
print_r($response->getBody()->getContents());
}
catch (GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
# You can also use wget
curl -X POST https://restapi.fax.plus/v3/accounts/{user_id}/files \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}' \
# The x-fax-clientid header is required only when using the OAuth2 token scheme
-H 'x-fax-clientid: "YOUR CLIENT_ID"' \
-F 'fax_file=@fax.pdf'
{
"path": "/storage/2937237320213-213-21323"
}{
"error": "invalid_user_id",
"description": "Invalid user id given"
}{
"error": "internal_server_error",
"description": "An unexpected error happened, please contact support"
}const axios = require('axios');
const fs = require('fs');
const FilesApiFp = require('@alohi/faxplus-api').FilesApiFp;
const Configuration = require('@alohi/faxplus-api').Configuration;
const config = new Configuration({
accessToken: accessToken,
basePath: 'https://restapi.fax.plus/v3',
// Header required only when using the OAuth2 token scheme
baseOptions: {
headers: {
"x-fax-clientid": clientId,
}
}
});
async function uploadFile() {
// IMPORTANT: fs.createReadStream() requires a local file system path.
// It does NOT support URLs or remote streams.
//
// If your file is stored remotely (e.g., AWS S3, Google Cloud Storage, or HTTP URL),
// you must first download it to a local path or load it into memory as a Blob.
const reqParams = {
"userId": '13d8z73c',
"faxFile": fs.createReadStream(FILE_PATH) // FILE_PATH must be a local file path
}
const req = await FilesApiFp(config).uploadFile(reqParams);
const resp = await req(axios);
}
uploadFile()
from faxplus import ApiClient, FilesApi
from faxplus.configuration import Configuration
conf = Configuration()
conf.access_token = access_token
# header_name and header_value required only when using the OAuth2 token scheme
api_client = ApiClient(header_name='x-fax-clientid', header_value=client_id, configuration=conf)
api = FilesApi(api_client)
resp = api.upload_file(
user_id='13d8z73c',
fax_file='/path/to/file.pdf'
)
/**
* Example below uses Apache HTTP Client 4 with Fluent API
**/
Map<String, String> pathParams = new HashMap<>();
pathParams.put("user_id", "'13d8z73c'");
StrSubstitutor sub = new StrSubstitutor(values, "{", "}");
String url = sub.replace("https://restapi.fax.plus/v3/accounts/{user_id}/files");
HttpEntity entity = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.setCharset(Charset.forName(CHARSET))
.addBinaryBody("fax_file", bytes, ContentType.MULTIPART_FORM_DATA, "fax.pdf")
.build();
String result = Request
.Post(url)
// The x-fax-clientid header is required only when using the OAuth2 token scheme
.addHeader("x-fax-clientid", "YOUR CLIENT_ID")
.addHeader("Content-Type", "'multipart/form-data'")
.addHeader("Accept", "'application/json'")
.addHeader("Authorization", "'Bearer {access-token}'")
.body(entity)
.execute()
.returnContent().asString();
System.out.println(result.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
// The x-fax-clientid header is required only when using the OAuth2 token scheme
"Content-Type": []string{"multipart/form-data"},
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
"x-fax-clientid": []string{"YOUR CLIENT_ID"}
}
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
fax_file_part, err := writer.CreateFormFile('fax_file', filepath.Base('fax.pdf'))
_, err = io.Copy(part, file)
req, err := http.NewRequest("POST", "https://restapi.fax.plus/v3/accounts/{user_id}/files", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}',
// The x-fax-clientid header is required only when using the OAuth2 token scheme
'x-fax-clientid' => '{client ID}',
);
$client = new GuzzleHttp\Client();
try {
$response = $client->request('POST','https://restapi.fax.plus/v3/accounts/{user_id}/files', array(
'headers' => $headers,
'multipart' => [
[
'name' => 'fax_file',
'contents' => fopen('fax.pdf', 'r')
],
],)
);
print_r($response->getBody()->getContents());
}
catch (GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
# You can also use wget
curl -X POST https://restapi.fax.plus/v3/accounts/{user_id}/files \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}' \
# The x-fax-clientid header is required only when using the OAuth2 token scheme
-H 'x-fax-clientid: "YOUR CLIENT_ID"' \
-F 'fax_file=@fax.pdf'
Authorizations
oauth2personal_access_token
Scopes
Path Parameters
Body
multipart/form-data
A file to be uploaded. The file can be in PDF, TIFF, Word, Excel, RTF or image format.