Skip to main content
Newcomer
May 8, 2025
Solved

How to create an envelope from template with prefilled tabs?

  • May 8, 2025
  • 3 replies
  • 250 views

I’m using eSignature client api php sdk, how can I set template prefilled tabs while creating an envelop ? Here is my code 


$invoiceNumberTab = new Text([
'tab_label' => 'InvoiceNumber', // Must match prefill tab label in template
'value' => 'INV-20240508'
]);

$prefillTabs = new PrefillTabs([
'text_tabs' => [$invoiceNumberTab]
]);

$templateRole = new TemplateRole([
'email' => 'signer@example.com',
'name' => 'John Doe',
'role_name' => 'Signer' // Exact match to template role
]);


$envelopeDefinition = new EnvelopeDefinition([
'status' => 'sent',
'template_id' => 'TEMPLATE_ID',
'template_roles' => [$templateRole],
'prefill_tabs' => $prefillTabs
]);


$envelopeSummary = $envelopeApi->createEnvelope($account_id, $envelopeDefinition);
echo "Envelope ID: " . $envelopeSummary->getEnvelopeId();

And tried with this way also not working
 


$templateRole = new TemplateRole([
'email' => 'signer@example.com',
'name' => 'John Doe',
'role_name' => 'Signer'
]);


$envelopeDefinition = new EnvelopeDefinition([
'status' => 'created', // Keep the envelope in draft mode
'template_id' => 'TEMPLATE_ID',
'template_roles' => [$templateRole],
'email_subject' => 'Please sign this document'
]);


$envelopeSummary = $envelopeApi->createEnvelope($account_id, $envelopeDefinition);
$envelopeId = $envelopeSummary->getEnvelopeId();


$tabs = $envelopeApi->getDocumentTabs($account_id, $envelopeId, '1');

$prefillTextTabs = $tabs->getPrefillTabs()->getTextTabs();
foreach ($prefillTextTabs as $tab) {
if ($tab->getTabLabel() === 'InvoiceNumber') {
$tabId = $tab->getTabId();
break;
}
}

$updatedTextTab = new Text([
'tab_id' => $tabId,
'value' => 'INV-20240508'
]);

$prefillTabs = new PrefillTabs([
'text_tabs' => [$updatedTextTab]
]);

$tabsToUpdate = new Tabs([
'prefill_tabs' => $prefillTabs
]);

$envelopeApi->updateDocumentTabs($account_id, $envelopeId, '1', $tabsToUpdate);

$envelope = new Envelope([
'status' => 'sent'
]);

$envelopeApi->update($account_id, $envelopeId, $envelope);

I can’t find proper documentation for this. Thanks

Best answer by Leandro.Reis

Hello ​@Era,

I hope you are well today.

Below you can find links to official Docusign documentation on how to use the pre-filled tabs.

If the documentation above is not sufficient, please contact the Docusign support and it will be a pleasure to assist you.

Kind regards,

Leandro Reis
Developer Support Engineer | Docusign

3 replies

JohnSantos
Guru
Guru
May 8, 2025

@Era 

The reason your “draft then update” approach isn’t working is two-fold:

You’re using updateDocumentTabs, which only updates recipient (role) tabs on the document (i.e. the tabs that live inside a signer’s signing session).

Prefill tabs live at the envelope level, and must be updated with the updatePrefillTabs endpoint (or, even better, set at creation time).

Welcome to the DocuSign Community! Your feedback is highly valued. If you find my response helpful, please give it a "Like" and consider marking it as the "Best Answer" to assist others with similar issues.
EraNewcomerAuthor
Newcomer
May 9, 2025

Hi ​@JohnSantos , Thanks for you answer. Could you help me drop doc or reference links if you don’t mind. I couldn’t find in doc related with this.

Leandro.Reis
Docusign Employee
Docusign Employee
May 9, 2025

Hello ​@Era,

I hope you are well today.

Below you can find links to official Docusign documentation on how to use the pre-filled tabs.

If the documentation above is not sufficient, please contact the Docusign support and it will be a pleasure to assist you.

Kind regards,

Leandro Reis
Developer Support Engineer | Docusign

Leandro Reis | Developer Support at Docusign