Free plan

Fill a Template

Fill the gaps of an Excel, Word or PowerPoint template
POST
/v1/documents/template

About this tool

A template is a file with gaps written like {{name}}. This tool replaces each gap with a value you give it. It works in Excel, Word and PowerPoint files. You decide what happens to a gap that has no value: keep it, leave it blank or stop with an error. Files that contain macros are refused.
For example, you have an offer letter template and fill in the customer name and the price.

How to use it

  1. Choose this tool.
  2. Add your template file with gaps like {{name}}.
  3. Type the values to put in, as a list of names and values.
  4. Choose what to do with gaps that have no value.
  5. Press Generate.

What you get back

You get a new filled-in file to download, and any gaps that stayed empty are listed.
GOOD TO KNOW
A template in, the filled file out (same type). In Excel a cell that holds only a placeholder whose value is a number becomes a real number cell. Counts as one document.
TEST IT LIVE

Try Fill a Template in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
Documents
Plan
Free
Method
POST
Endpoint
/v1/documents/template
Tool ID
documents.template
Authentication
API key
Accepts
Text and settings
Background jobs
Yes
Usage group
Documents
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/documents/template" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'file=@document.pdf' \
  -F 'data={"name":"Ada","total":12.5}' \
  -F 'missing=keep' \
  -F 'response=url'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.documents.template({
    "file": 'document.pdf',
    "data": "{\"name\":\"Ada\",\"total\":12.5}",
    "missing": "keep",
    "response": "url"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->documents()->template([
    'file' => 'document.pdf',
    'data' => '{"name":"Ada","total":12.5}',
    'missing' => 'keep',
    'response' => 'url',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Fill an Excel, PowerPoint or Word template: every {{placeholder}} in it is replaced with a value from a JSON object, including placeholders that Office split across several pieces of text.

Fill a Template works from text and settings, so no file is needed. The required inputs are data.

Fill a Template is included in every plan, including Free. Each run uses credits from your monthly allowance.

Send a POST request to /v1/documents/template with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.