Customer Support 1 avatar image
Customer Support 1 asked Phong Vu answered

Fax API - Keeps failing with attachment using Javascript SDK from base64

Hi - I've tried all kinds of ways to get the SDK working. If i use the code in the template with fs.createreadstream - it works fine reading from a file.

i'm trying to upload reading from a base64 string. I've tried converting to a buffer / string - all kinds of things. The API call completes, but the status is failed in the dashboard and I don't know why it failed as there isn't further logging. Beating my head against the wall on this one. Any help would be hugely appreciated.

rest apifax
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered

To send a fax with attachment is a base64 string using the RingCentral Node JS SDK, try this.

async function sendFax() {
    var endpoint = "/restapi/v1.0/account/~/extension/~/fax"
    var FormData = require('form-data');
    formData = new FormData();
    var body = {
      to: [{'phoneNumber': "RECIPIENT-NUMBER"}],
      faxResolution: 'High',

    formData.append('json', new Buffer.from(JSON.stringify(body)), {
        filename: 'test.png',
        contentType: 'application/json'

    var base64Data = "...JsHpb9we8DAfN9fUY+h9OL9b4NKMvqwAAAABJRU5ErkJggg=="
    var bufferValue = Buffer.from(base64Data,"base64");
    formData.append('attachment', bufferValue, 'image.png');
    var resp = await, formData)
    var jsonObj = await resp.json()
    console.log("FAX sent. Current status: " + jsonObj.messageStatus + "/" +

BTW, there is a current issue with receiving fax attachment in the sandbox environment. You will only get the cover page, no attachment pages but the fax status should be "Sent" though.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys