Generate a PDF

Create a new PDF job submission.

HTTP Request



You must send an Authorization header with the value Basic followed by base 64 encoded token_id:token_secret.

For example: Authorization: Basic dG9rZW5faWQ6dG9rZW5fc2VjcmV0Cg==

See the Authentication documentation for more information.


The request body must be a JSON object with the following keys:

  • data (object): Data to fill in the fields. Must match the template schema.
  • metadata (object, optional): Any additional data, such as a user id. metadata will be included in webhook requests.
  • test (boolean): true to generate a test PDF, false for a live PDF. Test PDFs are free, but watermarked. Note: A test API key can only be used to generate test PDFs.
  • editable (boolean, optional): true to generate an editable PDF with fillable form fields. false to generate a static PDF with fixed text. (Note: When no value is provided, we use the default setting from the template.)
  • data_requests (array, optional): Request information or signatures from one or more people. (See the Create Data Request documentation for more info and examples.)

Example Response

  "status": "success",
  "submission": {
    "id": "sub_000000000000000001",
    "state": "pending",
    "test": false,
    "editable": false,
    "expired": false,
    "expires_at": null,
    "metadata": {
      "foo": 123,
      "bar": "baz"
    "processed_at": null,
    "batch_id": null,
    "data_requests": [],
    "download_url": null,
    "permanent_download_url": null

Example Code

// This is a live example that you can run with Node

import FormAPI from "formapi";

const config = new FormAPI.Configuration();
config.apiTokenId = "yRaaR9JmTPtGX7EN";
config.apiTokenSecret = "IB3TRkSdm4f2BdtU_D3YgxjdMB7l-r2fOgvxD1Yzwec";
client = new FormAPI.Client(config);

const templateId = "6zz3dYRYM67fxMXA";
const submissionData = {
  test: true,
  data: {
    first_name: "John",
    last_name: "Smith",
    favorite_color: "Blue"
  metadata: {
    user_id: 123
client.generatePDF(templateId, submissionData, function(error, response) {
  if (error) throw error;
# This is a live example that you can run in IRB.

require 'form_api'

ENV['FORMAPI_TOKEN_SECRET'] = "IB3TRkSdm4f2BdtU_D3YgxjdMB7l-r2fOgvxD1Yzwec"
template_id = "6zz3dYRYM67fxMXA"

FormAPI.configure do |c|
  c.username  = ENV['FORMAPI_TOKEN_ID']
  c.password  = ENV['FORMAPI_TOKEN_SECRET']

formapi =

response = formapi.generate_pdf(
  template_id: template_id,
  test: true,
  data: {
    first_name: 'John',
    last_name: 'Smith',
    favorite_color: 'Blue'
  metadata: {
    user_id: 123

puts "Download your PDF at: #{response.submission.download_url}"
# This is a live example that you can run in the Python interpreter
import form_api

client = form_api.Client()
client.api_client.configuration.username = "yRaaR9JmTPtGX7EN"
client.api_client.configuration.password = "IB3TRkSdm4f2BdtU_D3YgxjdMB7l-r2fOgvxD1Yzwec"

submission = client.generate_pdf(
  "6zz3dYRYM67fxMXA",  # ID of a template that you have configured
    "test": True,                       # test documents are free but watermarked
    "data": {                           # Data to render in the template
      "first_name": "John",
      "last_name": "Smith",
      "favorite_color": "Green",
    "metadata": {                     # Custom data to include in the request, for your own purposes
      "user_id": 123,

print("Download your PDF at: %s" % submission.download_url)
// This is a live example that you can run in the PHP interactive shell (php -a)
$formapi = new FormAPI\Client();

$template_id = '6zz3dYRYM67fxMXA';

$data = new FormAPI\Model\SubmissionData();
  "first_name" => 'John',
  "last_name" => 'Smith',
  "favorite_color" => 'Green'

$submission = $formapi->generatePDF($template_id, $data);

echo "Download your PDF at: " . $submission->getDownloadUrl();
using System;
using System.Diagnostics;
using FormApi.Client.Api;
using FormApi.Client.Client;
using FormApi.Client.Model;

namespace Example
    public class FormAPIExample
        public void main()
          Configuration.Default.Username = "yRaaR9JmTPtGX7EN";
          Configuration.Default.Password = "IB3TRkSdm4f2BdtU_D3YgxjdMB7l-r2fOgvxD1Yzwec";

          var apiInstance = new PDFApi();
          string templateId = "tpl_000000000000000001";
          var createSubmissionData = new CreateSubmissionData(
            false,  // true to generate a test PDF (watermarked)
            new {
              title = "Test PDF",
              description = "This PDF is great!"
          var response = apiInstance.GeneratePDF(templateId, createSubmissionData);

          // The PDF will now be in the "pending" state until it is processed.
          // You may want to call GetSubmission once per second until
          // the state changes to "processed".
          // Alternatively, you can set up a webhook notification.

The following example waits for the PDF to be processed, then prints the download URL.

# This is a live example that you can run in your console.

export API_TOKEN_ID="yRaaR9JmTPtGX7EN"
export API_TOKEN_SECRET="IB3TRkSdm4f2BdtU_D3YgxjdMB7l-r2fOgvxD1Yzwec"
export TEMPLATE_ID="6zz3dYRYM67fxMXA"

generate_pdf() {
  curl -s "$TEMPLATE_ID/submissions" \
    -H "Content-Type: application/json" \
    -X POST \
    -d '{"data":{"first_name": "John", "last_name": "Smith", "favorite_color": "Blue"}, "metadata": { "user_id": 123 }}'

get_submission() {
  curl -s "$1" \

get_json_value() {
  echo "$1" | sed -n 's/.*"'"$2"'":"\([^"]\+\)".*/\1/p'

SUBMISSION_ID=$(get_json_value "$RESPONSE" id)
SUBMISSION_STATE=$(get_json_value "$RESPONSE" state)

echo "Waiting for PDF to be processed..."
while [[ "$SUBMISSION_STATE" = "pending" ]]; do
  sleep 1
  RESPONSE=$(get_submission "$SUBMISSION_ID")
  SUBMISSION_STATE=$(get_json_value "$RESPONSE" state)

echo "Download your PDF at:"
get_json_value "$RESPONSE" download_url

results matching ""

    No results matching ""