Ever need to download all HelloSign documents with Laravel without the SDK? It can be done by basic HTTP requests with an API key generated by HelloSign.

Jobs to avoid HelloSign API rate limits

Create hellosign.php in the config folder ]; Create a migration create_signature_requests_table for the HelloSign document ids and add the following columns $table->string('signature_request_id'); $table->boolean('downloaded'); Create a model SignatureRequest and add the following $table->string('signature_request_id'); $table->boolean('downloaded'); Go to routes/web.php and add the following use App\Jobs\DownloadJob; Route::get('/', function () { $api_key = config('hellosign.api_key'); $page = 1; $total_pages = 99; // just a temporary high number while($page object(); // set the number of total pages of documents if($page == 1) { $total_pages = $object->list_info->num_pages; } // loop through each result and get the signature_request_id if it exists foreach($object->signature_requests as $sig) { if(!isset($sig->signature_request_id)){ SignatureRequest::create(['signature_request_id' => $sig->signature_request_id]); }} // increase the page $page++; }}); Route::get('download', function() { // get all signature ids that are not downloaded yet $sigs = SignatureRequest::where('downloaded', false)->get(); // chunk it into 20, HelloSign API limits 25 requests per minute $chunks = $sigs->chunk(20); $chunks->all(); // wait in minutes $wait = 0; foreach($chunks->all() as $chunk) { foreach($chunk as $sig) { // dispatch the download job and delay it by now + minutes dispatch(new DownloadJob($sig))->delay(now()->addMinutes($wait)); } // increase wait time $wait++; }}); Create a job DownloadJob and update with the following namespace App\Jobs; ... use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Storage; use App\Models\SignatureRequest; ... public $sig; public function __construct(SignatureRequest $sig) { $this->sig = $sig; } public function handle() { $api_key = config('hellosign.api_key'); // request the document $response = Http::get("https://{$api_key}:@api.hellosign.com/v3/signature_request/files/{$this->sig->signature_request_id}"); // only download if response code is 200 if($response->status() == 200) { // save the document into a `documents` folder in storage with the document id as it's file name Storage::put("documents/{$this->sig->signature_request_id}.pdf", $response->body()); // update db to downloaded $this->sig->downloaded = true; $this->sig->save(); }}

Once #10 is finished, in the browser go to localhost/download to add put the download into the queue
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners