Adrian S avatar image
Adrian S asked Phong Vu edited

Sending Faxes API Integration


I am trying to integrate OSCAR EMR (electronic medical records software) with RingCentral Fax API, so that prescriptions/etc can be faxed. The system currently has an existing integration for sending faxes with SRFax (a Canadian eFax provider), but I want to integrate it with RingCentral to send faxes with RingCentral.

Here is the current script that is setup to send faxes with SRFax integration, what would I change for it to work with RingCentral fax?

I would be super grateful if someone could help me with this. Thank you.

Here is the documentation on how this works currently with SRFax (e.g. how the files get picked up to be sent):

# SRFax Gateway cron
# (c) 2020 Peter Hutten-Czapski released on GPL 2+
# Picks up the files dropped by OSCAR
# and POSTs it to the SRFax API
# and it clears the files dropped by OSCAR
# Adjust the constants at the top of the page to match actual

ID=***** # this is your SRfax account number
PWD=****** # Escape any special characters with non quoted \
CID=******** # this is your SRfax fax number, just numbers
EMAIL=******** # use the same email registered with SRfax for access to their web interface
FROM=******* # this one is whatever you like

SCRIPT_FILE=$(basename "$0")
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Calling  ${SCRIPT_FILE} on ${SCRIPT_PATH} with logging on ${FAXLOG}"

# --- select the running Tomcat or the highest installed version
TOMCAT=$(ps aux | grep org.apache.catalina.startup.Bootstrap | grep -v grep | awk '{ print $1 }')
if [ -z "$TOMCAT" ]; then
    #Tomcat is not running, find the highest installed version
    if [ -f /usr/share/tomcat9/bin/ ] ; then
        if [ -f /usr/share/tomcat8/bin/ ] ; then
            if [ -f /usr/share/tomcat7/bin/ ] ; then

echo "Searching ${TMP} for faxes...."
if test -n "$(find ${TMP} -maxdepth 1 -name '*.txt' -print -quit)"; then
        echo "Faxes found to be sent"
        for f in `ls $TMP/*.txt`; do
                faxto=`sed s"/ *//g" $f|tr -d "\n"`
                # allow for a second or so for the pdf to be generated
                sleep 4
                bfile=`echo $f | sed s"/txt/pdf/"`
                openssl base64 -e -A -in $bfile -out temp.b64
                echo -n `date` "fax to 1$faxto " >> $FAXLOG
                json=$(curl \
                -F "action=Queue_Fax" \
                -F "access_id=$ID" \
                -F "access_pwd=$PWD" \
                -F "sCallerID=$CID" \
                -F "sSenderEmail=$EMAIL" \
                -F "sFaxFromHeader=$FROM" \
                -F "sFaxType=SINGLE" \
                -F "sToFaxNumber=1$faxto" \
                -F "sCPSubject=Oscar Fax" \
                -F "sRetries=3" \
                -F "sFileName_x=$bfile" \
                -F "sFileContent_x=<temp.b64" \
                if [ -n "$json" ]; then
                    success=$(echo "${json}" | grep -Po "Success")
                    if [ -z "$success" ]; then
                        echo "#### ERROR: ${json} for ${f} " >> $FAXLOG
                        echo "exiting but renaming source file"
                        cp $f $
                        echo "${json} for" `basename ${f}`  >> $FAXLOG
                        rm $bfile;
                        echo "### ERROR: \$json is empty for ${f} " >> $FAXLOG
                        cp $f $
                rm $f;
                rm temp.b64
        echo "No faxes found"
1 |1500 characters needed characters left characters exceeded

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 Phong Vu edited

I am not familiar with PowerShell script to do such a complicated stuff. Here is what we have for sending Faxes using RingCentral API. The quick start provide sample code in different programming languages, unfortunately, no code for PowerShell.

1 |1500 characters needed characters left characters exceeded

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