Skip to main content
GET https://api.pdfnoodle.com/v1/integration/templates/:templateId/variables

Request

curl --location 'https://api.pdfnoodle.com/v1/integration/templates/invoice-template-001/variables' \
--header 'Authorization: Bearer pdfnoodle_api_123456789'

Response

{
  "invoice_number": "your invoice_number here",
  "company_info": {
    "name": "your company_info.name here",
    "address_line_1": "your company_info.address_line_1 here",
    "city": "your company_info.city here",
    "email": "your company_info.email here"
  },
  "billing_to": {
    "name": "your billing_to.name here",
    "address_line_1": "your billing_to.address_line_1 here",
    "city": "your billing_to.city here"
  },
  "total_value": "your total_value here",
  "items": [
    {
      "description": "your row.description here",
      "quantity": "your row.quantity here",
      "price": "your row.price here"
    }
  ]
}
This endpoint responds with 200 OK and returns all variables from the template. The response structure matches the variables used in the template, including nested objects and arrays.
The example above shows a variable schema from an invoice template. The actual response will vary depending on the template’s structure and variables.

Path Parameters

templateId
string
required
Template identifier (the name field from the template, same as id from list templates response, or the templateId returned from create template endpoint)

Response Fields

The response contains all variables from the template. The structure will vary depending on the template, but will include all variables, nested objects, and arrays that are used in the template.

Usage

This endpoint is essential for:
  • Understanding what data fields are required to render a template
  • Building dynamic forms for template data input
  • Validating data before rendering
  • Generating API documentation for template-specific data structures
  • Discovering available variables programmatically
The response structure matches the variables used in the template. Use this endpoint to discover what data fields are required when rendering a template with the generate-pdf-from-template endpoint.

Usage Example

Here’s a complete example of fetching template variables and using them to build a data payload:
// Get variables for a specific template
const templateId = "invoice-template-001";
const variablesResponse = await fetch(
  `https://api.pdfnoodle.com/v1/integration/templates/${templateId}/variables`,
  {
    headers: { Authorization: "Bearer pdfnoodle_api_123456789" },
  }
);

const { variables } = await variablesResponse.json();

console.log("Required variables:", variables);

// Use variables to build data payload for rendering
const templateData = {
  companyName: "Acme Corp",
  invoiceNumber: "INV-001",
  lineItems: [
    {
      description: "Product A",
      quantity: 2,
      price: 50.0,
    },
    {
      description: "Product B",
      quantity: 1,
      price: 30.0,
    },
  ],
  totalAmount: 130.0,
};

// Now you can use templateData with the generate-pdf-from-template endpoint

Error Responses

401 Unauthorized

{
  "message": "Unauthorized"
}
Occurs when: The API key is missing or invalid.

404 Not Found

{
  "message": "Couldnt find this template."
}
Occurs when: The requested template doesn’t exist or isn’t fully created yet.

500 Internal Server Error

{
  "message": "Error message describing what went wrong"
}
Occurs when: Variable extraction fails or an internal server error prevents the operation from completing.
The template must be fully created and available before you can fetch its variables. If you try to fetch variables for a template that’s still being created (status ONGOING), you’ll receive a 404 Not Found error.