API reference
PDF templates
The layouts documents are printed with: list, export, check, preview, install and remove. 10 operations.
List templates
GET /templates
Lists the PDF templates. A partner application sees only the templates it installed; an API key sees the account's templates.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kind | query | string | Kind of templates to list. Invoice templates by default; TRANSPORT_DOCUMENT lists transport document ones. One of: INVOICE, TRANSPORT_DOCUMENT |
fiscal | query | boolean | Fiscal templates by default; false lists the non-fiscal ones (auxiliary prints). |
curl 'https://api.fiz.co/templates' \
--header "x-api-key: $FIZ_API_KEY"import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.list();from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.list()<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->list();Response 200
List of templates returned successfully
| Field | Type | Description |
|---|---|---|
[]. | string | Unique template identifier |
[]. | string | Template name |
[]. | string[] | CAE codes the template applies to in the account's automatic choice |
[]. | string | Template language One of: en, pt |
[]. | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
[]. | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
[]. | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
[]. | number | Data contract version the template needs |
[]. | string | Last change |
Errors
401Unauthorized - API key missing or invalid429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Import template
POST /templates
Creates a template from an export. Created by a partner application, the template belongs to that application: only it sees and changes it, and it prints only the documents that application issued, when templateId is given on the PDF download. An application can keep up to 5 templates per company.
Request body
| Field | Type | Description |
|---|---|---|
id | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. |
kind | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. One of: INVOICE, TRANSPORT_DOCUMENT |
format | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. One of: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. |
documentTypes | string[] | On import of a template without starterId: if it includes CREDIT_NOTE or DEBIT_NOTE, asks that the template print credit and debit notes. Granted only if the template prints the reference to the rectified document. Ignored with starterId and on replace. |
updatedAt | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. |
name required | string | Template name, unique among the templates of the same owner |
data required | object | The template (the data field of GET /templates/{id}, or written from the published description). Validated on the server; an unknown field or a missing fiscal rule is refused with 400. |
contractVersion required | number | Data contract version the template was made for (contractVersion from the export). A template that needs a higher version than the one given is refused. |
cae | string[] | CAE codes the template applies to in the account's automatic choice |
language | string | Template language. Defaults to pt. One of: en, pt |
starterId | string | Starter (starterId from the export). Sets the kind, the paper and whether the template is fiscal; without it the template is a fiscal A4 invoice template. |
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)curl --request POST 'https://api.fiz.co/templates' \
--header "x-api-key: $FIZ_API_KEY" \
--header 'Content-Type: application/json' \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
--data '{
"name": "Modelo Ginásio",
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12
]
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "number",
"type": "text",
"readOnly": true,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}"
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total"
],
"headWidthPercentages": [
46,
10,
16,
10,
18
],
"showHead": true,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000"
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1
}
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1
}
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right"
}
},
"position": {
"x": 12,
"y": 85
},
"width": 186,
"height": 40
}
]
]
},
"contractVersion": 2
}'import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.create({
name: 'Modelo Ginásio',
data: {
basePdf: {
width: 210,
height: 297,
padding: [
12,
12,
12,
12,
],
},
schemas: [
[
{
name: 'invoice',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'number',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'customer',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'profile',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'number',
type: 'text',
readOnly: true,
content: '{invoice.type} {invoice.number}',
position: {
x: 12,
y: 60,
},
width: 186,
height: 12,
fontName: 'Roboto Bold',
fontSize: 24,
},
{
name: 'items',
type: 'table',
rowSource: 'items',
columns: [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
head: [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
headWidthPercentages: [
46,
10,
16,
10,
18,
],
showHead: true,
tableStyles: {
borderWidth: 0,
borderColor: '#000000',
},
headStyles: {
fontName: 'Roboto Bold',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'top',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 5,
right: 0,
bottom: 5,
left: 1,
},
},
bodyStyles: {
fontName: 'Roboto',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'middle',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
alternateBackgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 3,
right: 0,
bottom: 2,
left: 1,
},
},
columnStyles: {
alignment: {
'0': 'left',
'1': 'left',
'2': 'right',
'3': 'right',
'4': 'right',
},
},
position: {
x: 12,
y: 85,
},
width: 186,
height: 40,
},
],
],
},
contractVersion: 2,
});from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.create({
"name": "Modelo Ginásio",
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12,
],
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "number",
"type": "text",
"readOnly": True,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60,
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24,
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}",
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total",
],
"headWidthPercentages": [
46,
10,
16,
10,
18,
],
"showHead": True,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000",
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1,
},
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1,
},
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right",
},
},
"position": {
"x": 12,
"y": 85,
},
"width": 186,
"height": 40,
},
],
],
},
"contractVersion": 2,
})<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->create([
'name' => 'Modelo Ginásio',
'data' => [
'basePdf' => [
'width' => 210,
'height' => 297,
'padding' => [
12,
12,
12,
12,
],
],
'schemas' => [
[
[
'name' => 'invoice',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'number',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'customer',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'profile',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'number',
'type' => 'text',
'readOnly' => true,
'content' => '{invoice.type} {invoice.number}',
'position' => [
'x' => 12,
'y' => 60,
],
'width' => 186,
'height' => 12,
'fontName' => 'Roboto Bold',
'fontSize' => 24,
],
[
'name' => 'items',
'type' => 'table',
'rowSource' => 'items',
'columns' => [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
'head' => [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
'headWidthPercentages' => [
46,
10,
16,
10,
18,
],
'showHead' => true,
'tableStyles' => [
'borderWidth' => 0,
'borderColor' => '#000000',
],
'headStyles' => [
'fontName' => 'Roboto Bold',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'top',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 5,
'right' => 0,
'bottom' => 5,
'left' => 1,
],
],
'bodyStyles' => [
'fontName' => 'Roboto',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'middle',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'alternateBackgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 3,
'right' => 0,
'bottom' => 2,
'left' => 1,
],
],
'columnStyles' => [
'alignment' => [
'0' => 'left',
'1' => 'left',
'2' => 'right',
'3' => 'right',
'4' => 'right',
],
],
'position' => [
'x' => 12,
'y' => 85,
],
'width' => 186,
'height' => 40,
],
],
],
],
'contractVersion' => 2,
]);Response 201
Template created
| Field | Type | Description |
|---|---|---|
id | string | Unique template identifier |
name | string | Template name |
cae | string[] | CAE codes the template applies to in the account's automatic choice |
language | string | Template language One of: en, pt |
kind | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
format | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
starterId | string | Editor starter this template was created from. Send it back when importing: it sets the template's kind, paper and whether it is fiscal. |
contractVersion | number | Data contract version the template needs. Send it back when importing. |
documentTypes | string[] | Document types the template prints |
data | object | The template designed in the FIZ template editor (pdfme JSON with FIZ fields) |
updatedAt | string | Last change |
Errors
400Invalid template: unknown field, missing fiscal rule, insufficient contract version or template limit reached401Unauthorized - API key missing or invalid409A template with this name already exists422The idempotency key was already used with a different request body429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Template fields
GET /templates/fields
The paths a template may reference, per data set. It is the list validation enforces: a path outside it is refused.
curl 'https://api.fiz.co/templates/fields' \
--header "x-api-key: $FIZ_API_KEY"import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.fields();from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.fields()<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->fields();Response 200
Fields per data set
| Field | Type | Description |
|---|---|---|
[]. | string | Data set: fiscal (invoices and related documents), nonFiscal (auxiliary print) or transport (transport documents) |
[]. | string[] | Paths a text field or a cell may reference, such as {invoice.number} |
[]. | string[] | Paths a row of a table bound to the document lines may reference |
[]. | string[] | Families referenced by a prefix plus a key |
[]. | string[] | Row sources a bound table may name |
[]. | number | Data contract version the server implements |
Errors
401Unauthorized - API key missing or invalid429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
List starters
GET /templates/starters
The FIZ editor's starters. Use them as complete examples when writing a template.
curl 'https://api.fiz.co/templates/starters' \
--header "x-api-key: $FIZ_API_KEY"import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.starters();from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.starters()<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->starters();Response 200
Starters
| Field | Type | Description |
|---|---|---|
[]. | string | Starter identifier |
[]. | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
[]. | string | Template language One of: en, pt |
[]. | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
[]. | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
Errors
401Unauthorized - API key missing or invalid429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Get starter
GET /templates/starters/{starterId}
A starter with its data. Import it with POST /templates giving the same starterId.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
starterId required | path | string | Starter identifier |
curl 'https://api.fiz.co/templates/starters/STARTERID' \
--header "x-api-key: $FIZ_API_KEY"import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.starter('STARTERID');from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.starter("STARTERID")<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->starter('STARTERID');Response 200
Starter
| Field | Type | Description |
|---|---|---|
id | string | Starter identifier |
format | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
language | string | Template language One of: en, pt |
fiscal | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
kind | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
data | object | The starter (pdfme JSON with FIZ fields), a complete and valid example |
Errors
400Unknown starter401Unauthorized - API key missing or invalid429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Validate template
POST /templates/validate
Checks a template as an import would, without storing it. A refusal comes back as a problem in the response, not as an error.
Request body
| Field | Type | Description |
|---|---|---|
data required | object | The template (pdfme JSON with FIZ fields) |
starterId | string | Starter; sets the kind, the paper and whether the template is fiscal |
contractVersion | number | Data contract version the template was made for |
curl --request POST 'https://api.fiz.co/templates/validate' \
--header "x-api-key: $FIZ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12
]
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "number",
"type": "text",
"readOnly": true,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}"
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total"
],
"headWidthPercentages": [
46,
10,
16,
10,
18
],
"showHead": true,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000"
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1
}
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1
}
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right"
}
},
"position": {
"x": 12,
"y": 85
},
"width": 186,
"height": 40
}
]
]
},
"contractVersion": 2
}'import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.validate({
data: {
basePdf: {
width: 210,
height: 297,
padding: [
12,
12,
12,
12,
],
},
schemas: [
[
{
name: 'invoice',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'number',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'customer',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'profile',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'number',
type: 'text',
readOnly: true,
content: '{invoice.type} {invoice.number}',
position: {
x: 12,
y: 60,
},
width: 186,
height: 12,
fontName: 'Roboto Bold',
fontSize: 24,
},
{
name: 'items',
type: 'table',
rowSource: 'items',
columns: [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
head: [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
headWidthPercentages: [
46,
10,
16,
10,
18,
],
showHead: true,
tableStyles: {
borderWidth: 0,
borderColor: '#000000',
},
headStyles: {
fontName: 'Roboto Bold',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'top',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 5,
right: 0,
bottom: 5,
left: 1,
},
},
bodyStyles: {
fontName: 'Roboto',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'middle',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
alternateBackgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 3,
right: 0,
bottom: 2,
left: 1,
},
},
columnStyles: {
alignment: {
'0': 'left',
'1': 'left',
'2': 'right',
'3': 'right',
'4': 'right',
},
},
position: {
x: 12,
y: 85,
},
width: 186,
height: 40,
},
],
],
},
contractVersion: 2,
});from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.validate({
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12,
],
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "number",
"type": "text",
"readOnly": True,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60,
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24,
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}",
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total",
],
"headWidthPercentages": [
46,
10,
16,
10,
18,
],
"showHead": True,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000",
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1,
},
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1,
},
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right",
},
},
"position": {
"x": 12,
"y": 85,
},
"width": 186,
"height": 40,
},
],
],
},
"contractVersion": 2,
})<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->validate([
'data' => [
'basePdf' => [
'width' => 210,
'height' => 297,
'padding' => [
12,
12,
12,
12,
],
],
'schemas' => [
[
[
'name' => 'invoice',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'number',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'customer',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'profile',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'number',
'type' => 'text',
'readOnly' => true,
'content' => '{invoice.type} {invoice.number}',
'position' => [
'x' => 12,
'y' => 60,
],
'width' => 186,
'height' => 12,
'fontName' => 'Roboto Bold',
'fontSize' => 24,
],
[
'name' => 'items',
'type' => 'table',
'rowSource' => 'items',
'columns' => [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
'head' => [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
'headWidthPercentages' => [
46,
10,
16,
10,
18,
],
'showHead' => true,
'tableStyles' => [
'borderWidth' => 0,
'borderColor' => '#000000',
],
'headStyles' => [
'fontName' => 'Roboto Bold',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'top',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 5,
'right' => 0,
'bottom' => 5,
'left' => 1,
],
],
'bodyStyles' => [
'fontName' => 'Roboto',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'middle',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'alternateBackgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 3,
'right' => 0,
'bottom' => 2,
'left' => 1,
],
],
'columnStyles' => [
'alignment' => [
'0' => 'left',
'1' => 'left',
'2' => 'right',
'3' => 'right',
'4' => 'right',
],
],
'position' => [
'x' => 12,
'y' => 85,
],
'width' => 186,
'height' => 40,
],
],
],
],
'contractVersion' => 2,
]);Response 200
Validation result
| Field | Type | Description |
|---|---|---|
valid | boolean | true if an import would accept the template |
problems | object[] | The first problem found; validation stops at it. Empty when valid. |
problems[]. | string | The error code an import would answer with |
problems[]. | string | Technical description of the fault (the path, field or element at fault), for the template's developer |
problems[]. | number | For TEMPLATES_EDITOR_OUTDATED: the contract version the template needs |
fiscal | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
format | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
kind | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
contractVersion | number | Data contract version the template needs |
Errors
401Unauthorized - API key missing or invalid429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Preview template
POST /templates/preview
Renders an unsaved template with the same PDF engine as issued documents, on a sample document. Every page carries «DOCUMENTO DE TESTE — SEM VALIDADE FISCAL». Validated like an import: an invalid template is refused with 400. Invoice templates only. To see the template on a real document, install it and download that document's PDF with templateId.
Request body
| Field | Type | Description |
|---|---|---|
data required | object | The template (pdfme JSON with FIZ fields) |
starterId | string | Starter; sets the kind, the paper and whether the template is fiscal |
contractVersion | number | Data contract version the template was made for |
language | string | Preview language. Defaults to pt. One of: en, pt |
documentType | string | Sample document type. Defaults to INVOICE. One of: INVOICE, INVOICE_RECEIPT, SIMPLIFIED_INVOICE |
curl --request POST 'https://api.fiz.co/templates/preview' \
--header "x-api-key: $FIZ_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12
]
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "number",
"type": "text",
"readOnly": true,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}"
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total"
],
"headWidthPercentages": [
46,
10,
16,
10,
18
],
"showHead": true,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000"
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1
}
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1
}
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right"
}
},
"position": {
"x": 12,
"y": 85
},
"width": 186,
"height": 40
}
]
]
},
"contractVersion": 2
}'import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.preview({
data: {
basePdf: {
width: 210,
height: 297,
padding: [
12,
12,
12,
12,
],
},
schemas: [
[
{
name: 'invoice',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'number',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'customer',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'profile',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'number',
type: 'text',
readOnly: true,
content: '{invoice.type} {invoice.number}',
position: {
x: 12,
y: 60,
},
width: 186,
height: 12,
fontName: 'Roboto Bold',
fontSize: 24,
},
{
name: 'items',
type: 'table',
rowSource: 'items',
columns: [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
head: [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
headWidthPercentages: [
46,
10,
16,
10,
18,
],
showHead: true,
tableStyles: {
borderWidth: 0,
borderColor: '#000000',
},
headStyles: {
fontName: 'Roboto Bold',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'top',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 5,
right: 0,
bottom: 5,
left: 1,
},
},
bodyStyles: {
fontName: 'Roboto',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'middle',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
alternateBackgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 3,
right: 0,
bottom: 2,
left: 1,
},
},
columnStyles: {
alignment: {
'0': 'left',
'1': 'left',
'2': 'right',
'3': 'right',
'4': 'right',
},
},
position: {
x: 12,
y: 85,
},
width: 186,
height: 40,
},
],
],
},
contractVersion: 2,
});from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.preview({
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12,
],
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "number",
"type": "text",
"readOnly": True,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60,
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24,
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}",
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total",
],
"headWidthPercentages": [
46,
10,
16,
10,
18,
],
"showHead": True,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000",
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1,
},
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1,
},
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right",
},
},
"position": {
"x": 12,
"y": 85,
},
"width": 186,
"height": 40,
},
],
],
},
"contractVersion": 2,
})<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->preview([
'data' => [
'basePdf' => [
'width' => 210,
'height' => 297,
'padding' => [
12,
12,
12,
12,
],
],
'schemas' => [
[
[
'name' => 'invoice',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'number',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'customer',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'profile',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'number',
'type' => 'text',
'readOnly' => true,
'content' => '{invoice.type} {invoice.number}',
'position' => [
'x' => 12,
'y' => 60,
],
'width' => 186,
'height' => 12,
'fontName' => 'Roboto Bold',
'fontSize' => 24,
],
[
'name' => 'items',
'type' => 'table',
'rowSource' => 'items',
'columns' => [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
'head' => [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
'headWidthPercentages' => [
46,
10,
16,
10,
18,
],
'showHead' => true,
'tableStyles' => [
'borderWidth' => 0,
'borderColor' => '#000000',
],
'headStyles' => [
'fontName' => 'Roboto Bold',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'top',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 5,
'right' => 0,
'bottom' => 5,
'left' => 1,
],
],
'bodyStyles' => [
'fontName' => 'Roboto',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'middle',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'alternateBackgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 3,
'right' => 0,
'bottom' => 2,
'left' => 1,
],
],
'columnStyles' => [
'alignment' => [
'0' => 'left',
'1' => 'left',
'2' => 'right',
'3' => 'right',
'4' => 'right',
],
],
'position' => [
'x' => 12,
'y' => 85,
],
'width' => 186,
'height' => 40,
],
],
],
],
'contractVersion' => 2,
]);Response 200
Preview PDF
| Field | Type | Description |
|---|---|---|
id | string | File identifier |
name | string | File name |
url | string | Temporary URL of the preview PDF |
Errors
400Invalid template or unsupported document type401Unauthorized - API key missing or invalid429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Export template
GET /templates/{id}
Returns the full template, including data. The response can be sent as is to POST /templates in another company or the sandbox: the server-owned fields are ignored.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | Unique template identifier |
curl 'https://api.fiz.co/templates/ID' \
--header "x-api-key: $FIZ_API_KEY"import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.retrieve('ID');from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.retrieve("ID")<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->retrieve('ID');Response 200
Template
| Field | Type | Description |
|---|---|---|
id | string | Unique template identifier |
name | string | Template name |
cae | string[] | CAE codes the template applies to in the account's automatic choice |
language | string | Template language One of: en, pt |
kind | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
format | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
starterId | string | Editor starter this template was created from. Send it back when importing: it sets the template's kind, paper and whether it is fiscal. |
contractVersion | number | Data contract version the template needs. Send it back when importing. |
documentTypes | string[] | Document types the template prints |
data | object | The template designed in the FIZ template editor (pdfme JSON with FIZ fields) |
updatedAt | string | Last change |
Errors
401Unauthorized - API key missing or invalid403The template belongs to the account or to another application404Template not found429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Replace template
PUT /templates/{id}
Replaces a template's name, data, CAE and language. The kind, paper and fiscal character do not change.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | Unique template identifier |
Request body
| Field | Type | Description |
|---|---|---|
id | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. |
kind | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. One of: INVOICE, TRANSPORT_DOCUMENT |
format | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. One of: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. |
documentTypes | string[] | On import of a template without starterId: if it includes CREDIT_NOTE or DEBIT_NOTE, asks that the template print credit and debit notes. Granted only if the template prints the reference to the rectified document. Ignored with starterId and on replace. |
updatedAt | string | Ignored on import: set by the server. Accepted so the response of GET /templates/{id} can be sent as is. |
name required | string | Template name, unique among the templates of the same owner |
data required | object | The template (the data field of GET /templates/{id}, or written from the published description). Validated on the server; an unknown field or a missing fiscal rule is refused with 400. |
contractVersion required | number | Data contract version the template was made for (contractVersion from the export). A template that needs a higher version than the one given is refused. |
cae | string[] | CAE codes the template applies to in the account's automatic choice |
language | string | Template language. Defaults to pt. One of: en, pt |
starterId | string | Ignored on replace: a template's origin does not change. Accepted so an export can be sent as is. |
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)curl --request PUT 'https://api.fiz.co/templates/ID' \
--header "x-api-key: $FIZ_API_KEY" \
--header 'Content-Type: application/json' \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
--data '{
"name": "Modelo Ginásio",
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12
]
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name"
],
"position": {
"x": 12,
"y": 12
},
"width": 4,
"height": 4
},
{
"name": "number",
"type": "text",
"readOnly": true,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}"
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total"
],
"headWidthPercentages": [
46,
10,
16,
10,
18
],
"showHead": true,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000"
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1
}
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1
}
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right"
}
},
"position": {
"x": 12,
"y": 85
},
"width": 186,
"height": 40
}
]
]
},
"contractVersion": 2
}'import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.update('ID', {
name: 'Modelo Ginásio',
data: {
basePdf: {
width: 210,
height: 297,
padding: [
12,
12,
12,
12,
],
},
schemas: [
[
{
name: 'invoice',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'number',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'customer',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'profile',
type: 'multiVariableText',
content: '{}',
text: '',
variables: [
'name',
],
position: {
x: 12,
y: 12,
},
width: 4,
height: 4,
},
{
name: 'number',
type: 'text',
readOnly: true,
content: '{invoice.type} {invoice.number}',
position: {
x: 12,
y: 60,
},
width: 186,
height: 12,
fontName: 'Roboto Bold',
fontSize: 24,
},
{
name: 'items',
type: 'table',
rowSource: 'items',
columns: [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
head: [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
headWidthPercentages: [
46,
10,
16,
10,
18,
],
showHead: true,
tableStyles: {
borderWidth: 0,
borderColor: '#000000',
},
headStyles: {
fontName: 'Roboto Bold',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'top',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 5,
right: 0,
bottom: 5,
left: 1,
},
},
bodyStyles: {
fontName: 'Roboto',
fontSize: 10,
characterSpacing: 0,
alignment: 'left',
verticalAlignment: 'middle',
lineHeight: 1,
fontColor: '#000000',
borderColor: '#000000',
backgroundColor: '',
alternateBackgroundColor: '',
borderWidth: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
padding: {
top: 3,
right: 0,
bottom: 2,
left: 1,
},
},
columnStyles: {
alignment: {
'0': 'left',
'1': 'left',
'2': 'right',
'3': 'right',
'4': 'right',
},
},
position: {
x: 12,
y: 85,
},
width: 186,
height: 40,
},
],
],
},
contractVersion: 2,
});from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.update("ID", {
"name": "Modelo Ginásio",
"data": {
"basePdf": {
"width": 210,
"height": 297,
"padding": [
12,
12,
12,
12,
],
},
"schemas": [
[
{
"name": "invoice",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"number",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "customer",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "profile",
"type": "multiVariableText",
"content": "{}",
"text": "",
"variables": [
"name",
],
"position": {
"x": 12,
"y": 12,
},
"width": 4,
"height": 4,
},
{
"name": "number",
"type": "text",
"readOnly": True,
"content": "{invoice.type} {invoice.number}",
"position": {
"x": 12,
"y": 60,
},
"width": 186,
"height": 12,
"fontName": "Roboto Bold",
"fontSize": 24,
},
{
"name": "items",
"type": "table",
"rowSource": "items",
"columns": [
"{item.nameWithDescription}",
"{item.quantity}",
"{item.unitPrice}",
"{item.taxRate}",
"{item.lineTotal}",
],
"head": [
"Descrição",
"Qtd.",
"Preço",
"IVA",
"Total",
],
"headWidthPercentages": [
46,
10,
16,
10,
18,
],
"showHead": True,
"tableStyles": {
"borderWidth": 0,
"borderColor": "#000000",
},
"headStyles": {
"fontName": "Roboto Bold",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "top",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 5,
"right": 0,
"bottom": 5,
"left": 1,
},
},
"bodyStyles": {
"fontName": "Roboto",
"fontSize": 10,
"characterSpacing": 0,
"alignment": "left",
"verticalAlignment": "middle",
"lineHeight": 1,
"fontColor": "#000000",
"borderColor": "#000000",
"backgroundColor": "",
"alternateBackgroundColor": "",
"borderWidth": {
"top": 0,
"right": 0,
"bottom": 0,
"left": 0,
},
"padding": {
"top": 3,
"right": 0,
"bottom": 2,
"left": 1,
},
},
"columnStyles": {
"alignment": {
"0": "left",
"1": "left",
"2": "right",
"3": "right",
"4": "right",
},
},
"position": {
"x": 12,
"y": 85,
},
"width": 186,
"height": 40,
},
],
],
},
"contractVersion": 2,
})<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->update('ID', [
'name' => 'Modelo Ginásio',
'data' => [
'basePdf' => [
'width' => 210,
'height' => 297,
'padding' => [
12,
12,
12,
12,
],
],
'schemas' => [
[
[
'name' => 'invoice',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'number',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'customer',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'profile',
'type' => 'multiVariableText',
'content' => '{}',
'text' => '',
'variables' => [
'name',
],
'position' => [
'x' => 12,
'y' => 12,
],
'width' => 4,
'height' => 4,
],
[
'name' => 'number',
'type' => 'text',
'readOnly' => true,
'content' => '{invoice.type} {invoice.number}',
'position' => [
'x' => 12,
'y' => 60,
],
'width' => 186,
'height' => 12,
'fontName' => 'Roboto Bold',
'fontSize' => 24,
],
[
'name' => 'items',
'type' => 'table',
'rowSource' => 'items',
'columns' => [
'{item.nameWithDescription}',
'{item.quantity}',
'{item.unitPrice}',
'{item.taxRate}',
'{item.lineTotal}',
],
'head' => [
'Descrição',
'Qtd.',
'Preço',
'IVA',
'Total',
],
'headWidthPercentages' => [
46,
10,
16,
10,
18,
],
'showHead' => true,
'tableStyles' => [
'borderWidth' => 0,
'borderColor' => '#000000',
],
'headStyles' => [
'fontName' => 'Roboto Bold',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'top',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 5,
'right' => 0,
'bottom' => 5,
'left' => 1,
],
],
'bodyStyles' => [
'fontName' => 'Roboto',
'fontSize' => 10,
'characterSpacing' => 0,
'alignment' => 'left',
'verticalAlignment' => 'middle',
'lineHeight' => 1,
'fontColor' => '#000000',
'borderColor' => '#000000',
'backgroundColor' => '',
'alternateBackgroundColor' => '',
'borderWidth' => [
'top' => 0,
'right' => 0,
'bottom' => 0,
'left' => 0,
],
'padding' => [
'top' => 3,
'right' => 0,
'bottom' => 2,
'left' => 1,
],
],
'columnStyles' => [
'alignment' => [
'0' => 'left',
'1' => 'left',
'2' => 'right',
'3' => 'right',
'4' => 'right',
],
],
'position' => [
'x' => 12,
'y' => 85,
],
'width' => 186,
'height' => 40,
],
],
],
],
'contractVersion' => 2,
]);Response 200
Template updated
| Field | Type | Description |
|---|---|---|
id | string | Unique template identifier |
name | string | Template name |
cae | string[] | CAE codes the template applies to in the account's automatic choice |
language | string | Template language One of: en, pt |
kind | string | What the template prints: invoices and related documents, or transport documents One of: INVOICE, TRANSPORT_DOCUMENT |
format | string | Paper the template is laid out for One of: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | true if the template prints the fiscal document itself; false for an auxiliary print without fiscal value |
starterId | string | Editor starter this template was created from. Send it back when importing: it sets the template's kind, paper and whether it is fiscal. |
contractVersion | number | Data contract version the template needs. Send it back when importing. |
documentTypes | string[] | Document types the template prints |
data | object | The template designed in the FIZ template editor (pdfme JSON with FIZ fields) |
updatedAt | string | Last change |
Errors
400Invalid template: unknown field, missing fiscal rule, insufficient contract version or template limit reached401Unauthorized - API key missing or invalid403The template belongs to the account or to another application404Template not found409A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown422The idempotency key was already used with a different request body429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Delete template
DELETE /templates/{id}
Deletes a template.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | Unique template identifier |
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)curl --request DELETE 'https://api.fiz.co/templates/ID' \
--header "x-api-key: $FIZ_API_KEY" \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}"import { Fiz } from '@fiz-co/sdk';
const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.templates.delete('ID');from fiz_sdk import Fiz
fiz = Fiz() # reads FIZ_API_KEY
result = fiz.templates.delete("ID")<?php
require 'vendor/autoload.php';
$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->templates->delete('ID');Response 200
Template deleted
| Field | Type | Description |
|---|---|---|
id | string | Identifier of the deleted template |
deleted | boolean | true when the template was deleted |
Errors
401Unauthorized - API key missing or invalid403The template belongs to the account or to another application404Template not found409A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown422The idempotency key was already used with a different request body429The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.
Errors
Errors share one shape: statusCode, message, code and error, with the request id in the X-Request-Id header.