Referência da API
Modelos de PDF
Os modelos com que os documentos são impressos: listar, exportar, conferir, pré-visualizar, instalar e remover. 10 operações.
Listar modelos
GET /templates
Lista os modelos de PDF. Uma aplicação parceira vê apenas os modelos que instalou; uma chave API vê os modelos da conta.
Parâmetros
| Nome | Em | Tipo | Descrição |
|---|---|---|---|
kind | query | string | Tipo de modelos a listar. Por omissão, os de faturas; TRANSPORT_DOCUMENT lista os de guias. Um de: INVOICE, TRANSPORT_DOCUMENT |
fiscal | query | boolean | Por omissão, os modelos fiscais; false lista os não fiscais (impressões auxiliares). |
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();Resposta 200
Lista de modelos retornada com sucesso
| Campo | Tipo | Descrição |
|---|---|---|
[]. | string | Identificador único do modelo |
[]. | string | Nome do modelo |
[]. | string[] | Códigos CAE a que o modelo se aplica na escolha automática da conta |
[]. | string | Língua do modelo Um de: en, pt |
[]. | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
[]. | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
[]. | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
[]. | number | Versão do contrato de dados de que o modelo precisa |
[]. | string | Última alteração |
Erros
401Não autorizado - Chave API em falta ou inválida429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Importar modelo
POST /templates
Cria um modelo a partir de uma exportação. Criado por uma aplicação parceira, o modelo é dessa aplicação: só ela o vê e o altera, e só imprime os documentos que ela emitiu, indicando templateId no download do PDF. Uma aplicação pode ter até 5 modelos por empresa.
Corpo do pedido
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. |
kind | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. Um de: INVOICE, TRANSPORT_DOCUMENT |
format | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. Um de: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. |
documentTypes | string[] | Na importação de um modelo sem starterId: se incluir CREDIT_NOTE ou DEBIT_NOTE, pede que o modelo imprima notas de crédito e de débito. Concedido só se o modelo imprimir a referência ao documento retificado. Ignorado com starterId e na substituição. |
updatedAt | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. |
name obrigatório | string | Nome do modelo, único entre os modelos do mesmo dono |
data obrigatório | object | O modelo (campo data de GET /templates/{id}, ou escrito segundo a descrição publicada). É validado no servidor; um campo desconhecido ou uma regra fiscal em falta é recusado com 400. |
contractVersion obrigatório | number | Versão do contrato de dados para que o modelo foi feito (contractVersion da exportação). Um modelo que precise de uma versão superior à indicada é recusado. |
cae | string[] | Códigos CAE a que o modelo se aplica na escolha automática da conta |
language | string | Língua do modelo. Por omissão, pt. Um de: en, pt |
starterId | string | Modelo de partida (starterId da exportação). Define o tipo, o papel e o carácter fiscal; sem ele o modelo é um modelo fiscal de faturas em A4. |
# Uma vez por operação. Guarde-a e reutilize-a em cada repetição.
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:?defina primeiro a chave da operação, no passo acima}" \
--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,
]);Resposta 201
Modelo criado
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Identificador único do modelo |
name | string | Nome do modelo |
cae | string[] | Códigos CAE a que o modelo se aplica na escolha automática da conta |
language | string | Língua do modelo Um de: en, pt |
kind | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
format | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
starterId | string | Modelo de partida do editor de que este modelo foi criado. Envie-o de volta ao importar: define o tipo, o papel e o carácter fiscal do modelo. |
contractVersion | number | Versão do contrato de dados de que o modelo precisa. Envie-a de volta ao importar. |
documentTypes | string[] | Tipos de documento que o modelo imprime |
data | object | O modelo desenhado no editor de modelos FIZ (JSON pdfme com os campos FIZ) |
updatedAt | string | Última alteração |
Erros
400Modelo inválido: campo desconhecido, regra fiscal em falta, versão de contrato insuficiente ou limite de modelos atingido401Não autorizado - Chave API em falta ou inválida409Já existe um modelo com este nome422A chave de idempotência já foi usada com um corpo de pedido diferente429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Campos dos modelos
GET /templates/fields
Os caminhos que um modelo pode referir, por conjunto de dados. É a lista que a validação aplica: um caminho fora dela é recusado.
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();Resposta 200
Campos por conjunto de dados
| Campo | Tipo | Descrição |
|---|---|---|
[]. | string | Conjunto de dados: fiscal (faturas e documentos afins), nonFiscal (impressão auxiliar) ou transport (guias) |
[]. | string[] | Caminhos que um campo de texto ou uma célula podem referir, como {invoice.number} |
[]. | string[] | Caminhos que uma linha de uma tabela ligada às linhas do documento pode referir |
[]. | string[] | Famílias referidas por prefixo e uma chave |
[]. | string[] | Fontes de linhas que uma tabela ligada pode indicar |
[]. | number | Versão do contrato de dados que o servidor implementa |
Erros
401Não autorizado - Chave API em falta ou inválida429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Listar modelos de partida
GET /templates/starters
Os modelos de partida do editor FIZ. Use-os como exemplos completos ao escrever um modelo.
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();Resposta 200
Modelos de partida
| Campo | Tipo | Descrição |
|---|---|---|
[]. | string | Identificador do modelo de partida |
[]. | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
[]. | string | Língua do modelo Um de: en, pt |
[]. | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
[]. | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
Erros
401Não autorizado - Chave API em falta ou inválida429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Obter modelo de partida
GET /templates/starters/{starterId}
Um modelo de partida com o respetivo data. Importe-o com POST /templates indicando o mesmo starterId.
Parâmetros
| Nome | Em | Tipo | Descrição |
|---|---|---|---|
starterId obrigatório | path | string | Identificador do modelo de partida |
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');Resposta 200
Modelo de partida
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Identificador do modelo de partida |
format | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
language | string | Língua do modelo Um de: en, pt |
fiscal | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
kind | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
data | object | O modelo de partida (JSON pdfme com os campos FIZ), um exemplo completo e válido |
Erros
400Modelo de partida desconhecido401Não autorizado - Chave API em falta ou inválida429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Validar modelo
POST /templates/validate
Verifica um modelo como uma importação o verificaria, sem o guardar. Uma recusa vem como problema na resposta, não como erro.
Corpo do pedido
| Campo | Tipo | Descrição |
|---|---|---|
data obrigatório | object | O modelo (JSON pdfme com os campos FIZ) |
starterId | string | Modelo de partida; define o tipo, o papel e o carácter fiscal |
contractVersion | number | Versão do contrato de dados para que o modelo foi feito |
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,
]);Resposta 200
Resultado da validação
| Campo | Tipo | Descrição |
|---|---|---|
valid | boolean | true se uma importação aceitaria o modelo |
problems | object[] | O primeiro problema encontrado; a validação para nele. Vazio quando válido. |
problems[]. | string | O código de erro com que uma importação responderia |
problems[]. | string | Descrição técnica da falha (o caminho, campo ou elemento em causa), para quem desenvolve o modelo |
problems[]. | number | Para TEMPLATES_EDITOR_OUTDATED: a versão do contrato de que o modelo precisa |
fiscal | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
format | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
kind | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
contractVersion | number | Versão do contrato de dados de que o modelo precisa |
Erros
401Não autorizado - Chave API em falta ou inválida429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Pré-visualizar modelo
POST /templates/preview
Gera o PDF de um modelo não guardado, com o mesmo motor de PDF da emissão, sobre um documento de exemplo. Cada página leva a marca «DOCUMENTO DE TESTE — SEM VALIDADE FISCAL». Valida como uma importação: um modelo inválido é recusado com 400. Só modelos de faturas. Para ver o modelo num documento real, instale-o e descarregue o PDF desse documento com templateId.
Corpo do pedido
| Campo | Tipo | Descrição |
|---|---|---|
data obrigatório | object | O modelo (JSON pdfme com os campos FIZ) |
starterId | string | Modelo de partida; define o tipo, o papel e o carácter fiscal |
contractVersion | number | Versão do contrato de dados para que o modelo foi feito |
language | string | Língua da pré-visualização. Por omissão, pt. Um de: en, pt |
documentType | string | Tipo do documento de exemplo. Por omissão, INVOICE. Um de: 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,
]);Resposta 200
PDF de pré-visualização
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Identificador do ficheiro |
name | string | Nome do ficheiro |
url | string | URL temporário do PDF de pré-visualização |
Erros
400Modelo inválido ou tipo de documento não suportado401Não autorizado - Chave API em falta ou inválida429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Exportar modelo
GET /templates/{id}
Devolve o modelo completo, incluindo data. A resposta pode ser enviada tal como está para POST /templates noutra empresa ou na sandbox: os campos definidos pelo servidor são ignorados.
Parâmetros
| Nome | Em | Tipo | Descrição |
|---|---|---|---|
id obrigatório | path | string | Identificador único do modelo |
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');Resposta 200
Modelo
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Identificador único do modelo |
name | string | Nome do modelo |
cae | string[] | Códigos CAE a que o modelo se aplica na escolha automática da conta |
language | string | Língua do modelo Um de: en, pt |
kind | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
format | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
starterId | string | Modelo de partida do editor de que este modelo foi criado. Envie-o de volta ao importar: define o tipo, o papel e o carácter fiscal do modelo. |
contractVersion | number | Versão do contrato de dados de que o modelo precisa. Envie-a de volta ao importar. |
documentTypes | string[] | Tipos de documento que o modelo imprime |
data | object | O modelo desenhado no editor de modelos FIZ (JSON pdfme com os campos FIZ) |
updatedAt | string | Última alteração |
Erros
401Não autorizado - Chave API em falta ou inválida403O modelo pertence à conta ou a outra aplicação404Modelo não encontrado429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Substituir modelo
PUT /templates/{id}
Substitui o nome, data, CAE e língua de um modelo. O tipo, o papel e o carácter fiscal não mudam.
Parâmetros
| Nome | Em | Tipo | Descrição |
|---|---|---|---|
id obrigatório | path | string | Identificador único do modelo |
Corpo do pedido
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. |
kind | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. Um de: INVOICE, TRANSPORT_DOCUMENT |
format | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. Um de: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. |
documentTypes | string[] | Na importação de um modelo sem starterId: se incluir CREDIT_NOTE ou DEBIT_NOTE, pede que o modelo imprima notas de crédito e de débito. Concedido só se o modelo imprimir a referência ao documento retificado. Ignorado com starterId e na substituição. |
updatedAt | string | Ignorado na importação: definido pelo servidor. Aceite para que a resposta de GET /templates/{id} possa ser enviada tal como está. |
name obrigatório | string | Nome do modelo, único entre os modelos do mesmo dono |
data obrigatório | object | O modelo (campo data de GET /templates/{id}, ou escrito segundo a descrição publicada). É validado no servidor; um campo desconhecido ou uma regra fiscal em falta é recusado com 400. |
contractVersion obrigatório | number | Versão do contrato de dados para que o modelo foi feito (contractVersion da exportação). Um modelo que precise de uma versão superior à indicada é recusado. |
cae | string[] | Códigos CAE a que o modelo se aplica na escolha automática da conta |
language | string | Língua do modelo. Por omissão, pt. Um de: en, pt |
starterId | string | Ignorado na substituição: a origem de um modelo não muda. Aceite para que uma exportação possa ser enviada tal como está. |
# Uma vez por operação. Guarde-a e reutilize-a em cada repetição.
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:?defina primeiro a chave da operação, no passo acima}" \
--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,
]);Resposta 200
Modelo alterado
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Identificador único do modelo |
name | string | Nome do modelo |
cae | string[] | Códigos CAE a que o modelo se aplica na escolha automática da conta |
language | string | Língua do modelo Um de: en, pt |
kind | string | O que o modelo imprime: faturas e documentos afins, ou guias de transporte Um de: INVOICE, TRANSPORT_DOCUMENT |
format | string | Papel para que o modelo foi desenhado Um de: A4, RECEIPT, RECEIPT_58 |
fiscal | boolean | true se o modelo imprime o próprio documento fiscal; false para uma impressão auxiliar sem valor fiscal |
starterId | string | Modelo de partida do editor de que este modelo foi criado. Envie-o de volta ao importar: define o tipo, o papel e o carácter fiscal do modelo. |
contractVersion | number | Versão do contrato de dados de que o modelo precisa. Envie-a de volta ao importar. |
documentTypes | string[] | Tipos de documento que o modelo imprime |
data | object | O modelo desenhado no editor de modelos FIZ (JSON pdfme com os campos FIZ) |
updatedAt | string | Última alteração |
Erros
400Modelo inválido: campo desconhecido, regra fiscal em falta, versão de contrato insuficiente ou limite de modelos atingido401Não autorizado - Chave API em falta ou inválida403O modelo pertence à conta ou a outra aplicação404Modelo não encontrado409Um pedido com esta chave de idempotência ainda está a ser processado, ou o resultado da primeira tentativa é desconhecido422A chave de idempotência já foi usada com um corpo de pedido diferente429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Eliminar modelo
DELETE /templates/{id}
Elimina um modelo.
Parâmetros
| Nome | Em | Tipo | Descrição |
|---|---|---|---|
id obrigatório | path | string | Identificador único do modelo |
# Uma vez por operação. Guarde-a e reutilize-a em cada repetição.
IDEMPOTENCY_KEY=$(uuidgen)curl --request DELETE 'https://api.fiz.co/templates/ID' \
--header "x-api-key: $FIZ_API_KEY" \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?defina primeiro a chave da operação, no passo acima}"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');Resposta 200
Modelo eliminado
| Campo | Tipo | Descrição |
|---|---|---|
id | string | Identificador do modelo eliminado |
deleted | boolean | true quando o modelo foi eliminado |
Erros
401Não autorizado - Chave API em falta ou inválida403O modelo pertence à conta ou a outra aplicação404Modelo não encontrado409Um pedido com esta chave de idempotência ainda está a ser processado, ou o resultado da primeira tentativa é desconhecido422A chave de idempotência já foi usada com um corpo de pedido diferente429Limite de pedidos da ligação OAuth atingido. Nada foi executado: repita o mesmo pedido depois de Retry-After segundos.
Erros
Os erros têm uma só forma: statusCode, message, code e error, com o id do pedido no cabeçalho X-Request-Id.