send_document_from_template
Send documents for electronic signatures using predefined templates by specifying recipients, form field values, and sending options to streamline the signing process.
Instructions
Initiates the process of sending a document based on a pre-defined template. This tool allows you to specify recipients, form field values, and various sending options to create and send a document for signing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | Optional. The main content and settings for sending the document. | |
| templateId | Yes | Required. The unique identifier (ID) of the template to be used for sending the document. This can be obtained from the list templates tool. |
Implementation Reference
- The primary handler function that executes the tool logic by calling the BoldSign TemplateApi.sendUsingTemplate method with processed input parameters.async function sendDocumentFromTemplateDynamicHandler( payload: SendDocumentFromTemplateSchemaType, ): Promise<McpResponse> { try { const templateApi = new TemplateApi(); templateApi.basePath = configuration.getBasePath(); templateApi.setApiKey(configuration.getApiKey()); const roles = getRolesFromRequestPayload(payload); const documentCreated: DocumentCreated = await templateApi.sendUsingTemplate(payload.templateId, { fileUrls: payload.body.fileUrls, title: payload.body.title ?? undefined, message: payload.body.message ?? undefined, roles: roles, brandId: payload.body.brandId ?? undefined, disableEmails: payload.body.disableEmails ?? undefined, disableSMS: payload.body.disableSMS ?? undefined, hideDocumentId: payload.body.hideDocumentId ?? undefined, reminderSettings: payload.body.reminderSettings ?? undefined, cc: payload.body.cc ?? undefined, expiryDays: payload.body.expiryDays ?? undefined, enablePrintAndSign: payload.body.enablePrintAndSign ?? undefined, enableReassign: payload.body.enableReassign ?? undefined, enableSigningOrder: payload.body.enableSigningOrder ?? undefined, disableExpiryAlert: payload.body.disableExpiryAlert ?? undefined, scheduledSendTime: payload.body.scheduledSendTime ?? undefined, allowScheduledSend: payload.body.allowScheduledSend ?? undefined, } as SendForSignFromTemplateForm); return handleMcpResponse({ data: documentCreated, }); } catch (error: any) { return handleMcpError(error); } }
- Zod schema defining the input structure for the send_document_from_template tool, including templateId, document title, roles, CC recipients, and various sending options.const SendDocumentFromTemplateSchema = z.object({ templateId: commonSchema.InputIdSchema.describe( 'Required. The unique identifier (ID) of the template to be used for sending the document. This can be obtained from the list templates tool.', ), body: z .object({ title: commonSchema.OptionalStringSchema.describe( 'This is the title of the document that will be displayed in the BoldSign user interface as well as in the signature request email.', ), message: commonSchema.OptionalStringSchema.describe( 'A message for all the recipients. You can include the instructions that the signer should know before signing the document.', ), fileUrls: z .array(commonSchema.FileUrlSchema) .max(25) .optional() .nullable() .describe('Optional. An array of URLs pointing to additional files to be attached to the document.'), roles: RolesSchema, cc: z .array( z .object({ emailAddress: z.string().email().describe('Email address of the CC recipient.'), }) .describe('Email address of the CC recipients.'), ) .optional() .nullable() .describe( 'Optional. An array of email addresses to be added as carbon copy (CC) recipients to the document. CC recipients will receive a copy of the completed document.', ), brandId: commonSchema.InputIdSchema.optional() .nullable() .describe( 'The unique identifier (ID) of the brand to be associated with this document. If provided, the document will be branded accordingly.', ), disableEmails: commonSchema.OptionalBooleanSchema.describe( 'Disables the sending of document related emails to all the recipients. The default value is false.', ), disableSMS: commonSchema.OptionalBooleanSchema.describe( 'Disables the sending of document related SMS to all the recipients. The default value is false.', ), hideDocumentId: commonSchema.OptionalBooleanSchema.describe( 'Decides whether the document ID should be hidden or not.', ), reminderSettings: z .object({ enableAutoReminder: commonSchema.OptionalBooleanSchema.describe( 'A flag indicating whether automatic reminders should be enabled for this document.', ), reminderDays: commonSchema.OptionalIntegerSchema.describe( 'The number of days after which a reminder should be sent to the signers.', ), reminderCount: commonSchema.OptionalIntegerSchema.describe( 'The maximum number of reminders to be sent to the signers.', ), }) .optional() .nullable() .describe('Optional. Settings for automated reminders to be sent to the signers.'), expiryDays: commonSchema.OptionalIntegerSchema.default(60).describe( 'The number of days after which the document expires. The default value is 60 days.', ), enablePrintAndSign: commonSchema.OptionalBooleanSchema.describe( 'Allows the signer to print the document, sign, and upload it. The default value is false.', ), enableReassign: commonSchema.OptionalBooleanSchema.describe( 'Allows the signer to reassign the signature request to another person. The default value is true.', ), enableSigningOrder: commonSchema.OptionalBooleanSchema.describe( 'Enables or disables the signing order. If this option is enabled, then the signers can only sign the document in the specified order and cannot sign in parallel. The default value is false.', ), disableExpiryAlert: commonSchema.OptionalBooleanSchema.describe( 'Disables the alert, which was shown one day before the expiry of the document.', ), scheduledSendTime: commonSchema.OptionalIntegerSchema.describe( "This property allows you to specify the date and time in Unix Timestamp format to schedule a document for sending at a future time. The scheduled time must be at least 30 minutes from the current time and must not exceed the document's expiry date.", ), allowScheduledSend: commonSchema.OptionalIntegerSchema.describe( 'Indicates whether scheduled sending is allowed for this document (e.g., 1 for allowed, 0 for not allowed).', ), }) .describe('Optional. The main content and settings for sending the document.'), });
- src/tools/templatesTools/index.ts:6-10 (registration)Registration of the tool definition in the templates API tools array.export const templatesApiToolsDefinitions: BoldSignTool[] = [ sendDocumentFromTemplateDynamicToolDefinition, listTemplatesToolDefinition, getTemplatePropertiesToolDefinition, ];
- Helper function that transforms the input roles schema into BoldSign Role objects used in the API call.function getRolesFromRequestPayload(payload: SendDocumentFromTemplateSchemaType): Array<Role> { const roles = new Array<Role>(); payload?.body.roles?.forEach((requestRole) => { const role = new Role(); role.roleIndex = requestRole.roleIndex ?? undefined; role.signerName = requestRole.signerDetails?.signerName ?? undefined; role.signerOrder = requestRole.signerDetails?.signerOrder ?? undefined; role.signerEmail = requestRole.signerDetails?.signerEmail ?? undefined; role.privateMessage = requestRole.privateMessage ?? undefined; role.authenticationCode = requestRole.authenticationCode ?? undefined; role.enableEmailOTP = requestRole.enableEmailOTP ?? undefined; role.authenticationType = requestRole.authenticationType ? (requestRole.authenticationType as unknown as Role.AuthenticationTypeEnum) : undefined; role.phoneNumber = requestRole.phoneNumber ?? undefined; role.deliveryMode = requestRole.deliveryMode ? (requestRole.deliveryMode as unknown as Role.DeliveryModeEnum) : undefined; role.signerType = requestRole.signerType ? (requestRole.signerType as unknown as Role.SignerTypeEnum) : undefined; role.signerRole = requestRole.signerRole ?? undefined; role.allowFieldConfiguration = requestRole.allowFieldConfiguration ?? undefined; role.existingFormFields = requestRole.existingFormFields ?? undefined; role.enableQes = requestRole.enableQes ?? undefined; roles.push(role); }); return roles; }
- src/tools/templatesTools/sendDocumentFromTemplate.ts:199-208 (registration)The tool definition object that registers the handler, schema, name, and description for the MCP tool.export const sendDocumentFromTemplateDynamicToolDefinition: BoldSignTool = { method: ToolNames.SendDocumentFromTemplate.toString(), name: 'Send document from template', description: 'Initiates the process of sending a document based on a pre-defined template. This tool allows you to specify recipients, form field values, and various sending options to create and send a document for signing.', inputSchema: SendDocumentFromTemplateSchema, async handler(args: unknown): Promise<McpResponse> { return await sendDocumentFromTemplateDynamicHandler(args as SendDocumentFromTemplateSchemaType); }, };