Twilio Programmable Fax > Send: Is there a way to validate and get page count before sending fax?

Viewed 79

Looks like the API only allows for sending a fax (https://www.twilio.com/docs/fax/send) - is there any way to validate via the API that the file can be faxed (to a reasonable extent e.g.: valid format/size/etc.) and how many pages it will be charged for BEFORE requesting that it be sent?

Also, are there any validation limitations I can put on the client side (for feedback purposes && disabling front-end form submissions for Files we know will fail)?

1 Answers

Twilio developer evangelist here.

The only format that the Twilio Fax API currently supports is PDF. So you can certainly validate before you try to send that the file must be a PDF.

If you are looking to validate for PDFs in the client side you can add the accept attribute to a file input field and only allow it to accept PDF files:

<input type="file" id="fax-file" accept=".pdf,application/pdf">

Since the files can only be PDFs, you could count the number of pages in the PDF to see how many you expect to be sent through and charged for. Though note that faxes are charged by the time taken to send the fax which depends on the quality as well as the number of pages. We normally estimate about 60 seconds per page though. I'm not an expert on PDFs though, so I'm not sure what else I'd try to do here. Hope this helps though.

Related