How Doc2Doc Builds Biz Ops on Box

The Luddite CTO
Box Developer Blog
Published in
6 min readDec 15, 2023

If there’s one lesson imprinted deeply from time at Kiva, it was that the smaller the footprint of the technical systems the easier everything else would flow in the operations of the business. With that in mind, Doc2Doc’s technical platform was built to be minimal, efficient, and cost effective. Our application operational footprint is low and can be handled by one virtual machine along with creative use of 3rd party SaaS systems, a key one of those systems being Box.

Many of the features of Box were pivotal to the architecture of our system and here’s a bit about how it all works and Box’s role in the process.

First, a bit about Doc2Doc Lending. It’s a boutique lending platform founded and funded by medical doctors focused on financially serving medical students, residents, fellows, and practicing physicians and dentists in their careers. Prior to joining, I had no idea that medical residents had to work years of grueling shifts often 80+ hour weeks covering a wide assortment of general and specialty studies of various human bodily ailments. Kind of like software engineering, but with lives on the line. It’s tough work and done for little pay, at least until one becomes a fully practicing physician. With this in mind, we sought to create an easy flow for applicants to get information on, apply for, and be funded for our most popular product, a personal loan.

The beginning of the process is a short application form is filled out and submitted. Fortunately, Box already has an integration with the form vendor, so the completed form PDF automatically uploads into Box upon completion. From form submission, we can first make a call out to the Box API the /folders endpoint https://api.box.com/2.0/folders/ to create a new subfolder for our applicant. Then we can copy over our PDF into this new folder by retrieving the folder_id from the API response.

However, our first challenge is that we don’t know the file id of the newly created file since it was created by the vendor integration. You might think we could just search for it, but that won’t work in Box’s case because its search relies on rebiulding an index that only rebuilds every 15 minutes or so and our file was just created. We do know what parent folder it was created in though. Thus, we use the https://api.box.com/2.0/folders/:folder_id/items endpoint with the direction DESC parameter to loop through the latest files and match on matching file name to return the file id of the file we are looking for. After that is a simple call to https://api.box.com/2.0/files/:file_id/copy to copy the file over into our new folder we created above for our applicant.

Next up we create a file request for verification documents. We have a few different types of documents we request based on where someone is in their career. Thus, we’ve built out a number of different file request templates ahead of time and then based on the applicant type, we use the https://api.box.com/2.0/file_requests/:file_request_id/copy endpoint to copy one of our existing file requests into a new request within the parent application folder we created earlier. When we email the borrower next steps, we can share that file request with them so that they can get started on securely uploading their documents.

Next, we both pull some external data and fill in some internal files with that data. Once that is done, we put the data into local files, then upload those files to Box. This process uses the file API which is different from the main API endpoint and is located at https://upload.box.com/api/2.0. In this case we POST the file contents to https://upload.box.com/api/2.0/files/content and that places it into our application folder.

Finally, if approved we can create a conditional approval letter and then create a signature request for that letter. We were quite happy when Box rolled out Box Sign as that allowed us to leverage e-signatures directly from within Box. First we build a PDF version of the document specialized to that applicant and upload that to Box. Then we can POST to the https://api.box.com/2.0/sign_requests endpoint to create the sign request. There’s a lot of options to this endpoint, so you want to be sure to set things accordingly. Box, oddly, chose 3, 8, 13 and 18 as the days reminders go out without an option to change them. And of course, if you don’t want to send reminders at all then pass are_reminders_enabled as false. I’d love to know the thought process behind the odd days vs. just passing the days you want or the interval you want. Though, there’s hope because Box just rolled out a similar feature for granular expiration days https://pulse.box.com/forums/909778-help-shape-the-future-of-box/suggestions/45364894-granular-control-over-box-sign-expiration-dates

The whole application to Box integration flow is as such:

Now, there’s quite a bit of things you can do with Box Sign and the features have gotten better over time, even if the stability and availability of the Sign API seems to be in flux. On that note, you’ll want to make sure you have error handling on these calls as they tend to fail more than other API endpoints. In addition, there’s a silent failure, the dreaded “Error on Convert” that will show up in the UI of Box Sign even when the API result was successful. Because of this, you’ll want to regularly poll the List sign requests endpoint https://api.box.com/2.0/sign_requests and look for any oddities.

Occasional errors aside, the functionality is great, especially because of “prefill_tags”. These handy templating tags let you insert dynamic content into a document to be signed. You have to set this up as part of your initial PDF creation process before creating the signature request. Then, when you create the request you pass the values in the prefill_tags field. These can be text, checkboxes, or dates. Thus, you can set up a document template to use to cover needs like conditional approval letters where you just use prefill_tags for the fields you want to be filled by the user as well you can prefill the per-user customization such as name, date, terms, etc.

But not only that, you can capture the values the user enters in those fields and retrieve them again via the API. So, if we have our signature request id from creating it earlier, we can later poll it via the https://api.box.com/2.0/sign_requests/:sign_request_id endpoint and within that we retrieve back the entered information based on the id we set for the field. For instance, the applicant could enter their state of residence, and we could capture that and retrieve it later in the response from the “prefill_tags” array, e.g. state_value = ‘Georgia’.

Box Sign also added webhooks! That means we can know right away when someone has signed and move them along to next steps, all while automatically pulling in and ingesting any entered data. This allows for an automated workflow that servers our applicants and makes the whole process pretty easy and efficient for them. We just listen for the webhook then trigger our resulting actions. Though, a note of caution, Box will retry webhooks many times if you don’t return an immediate 200 response. If you’re using a synchronous programming language and not able to separate out your logic from your response then make sure to put precautions in place. Fortunately, Box sends a unique webhook id with the requests, so you can just check if you’ve already started processing that webhook and if so then can ignore repeat notifications.

For us, Box is an instrumental tool in our workflow and they keep adding great features, such as dropdowns and radio buttons which recently were rolled out https://pulse.box.com/forums/909778-help-shape-the-future-of-box/suggestions/44310621-need-more-input-field-types-and-options-for-box-si If, such as my self, you’d want to see conditional fields added then go upvote that feature request https://pulse.box.com/forums/909778/suggestions/44942140 as well as having a shared team dashboard which would be great https://pulse.box.com/forums/909778-help-shape-the-future-of-box/suggestions/44327376-shared-box-sign-group-status-dashboard-ability-t

There’s a lot more we do with Box at Doc2Doc Lending, but I hope this gives you a good sense of some of the things you could be doing with it and the exciting possibilities ahead.

--

--