The endpoint needs to be authorized with the SECRET-TOKEN
you’ve received by email after your subscription. Put it in the header such as:
fetch('https://www.presenta.cc/api/<endpoint>', {
headers:{
Authorization: 'Bearer <SECRET-TOKEN>'
}
})
The render endpoint requires the following valid configuration in order to work properly:
SECRET-TOKEN
in the headerTemplateID
in the URLfetch('https://www.presenta.cc/api/render/<TemplateID>', {
headers:{
Authorization: 'Bearer <SECRET-TOKEN>'
},
method: 'POST',
body: JSON.stringify({title: 'Hello'})
})
There are two different structures of the payload that can be used, depending of the template and the way you want to interact with it.
Simple mode: pass a flat object, the document will be exported as the project already is, with the elements modified according to the passed object:
fetch('https://www.presenta.cc/api/render/<TemplateID>', {
headers:{
Authorization: 'Bearer <YOUR-SECRET-TOKEN>'
},
method: 'POST',
body: JSON.stringify({
title: 'Hello',
footer: 'Common String present in all frames'
})
})
Structured mode: pass an object with the frames
key to generate a new structure following the frames list:
fetch('https://www.presenta.cc/api/render/<TemplateID>', {
headers:{
Authorization: 'Bearer <YOUR-SECRET-TOKEN>'
},
method: 'POST',
body: JSON.stringify({
footer: 'Common String present in all frames',
title: 'This is default title',
frames:[
{frameID: 'First-Page', title: 'Hello, new title'},
{frameID: 'Second-Page', title: 'Other, new title'},
{frameID: 'Product-Page'}, // default title
{frameID: 'Product-Page', text: 'Other Text'},
]
})
})
There are some additional properties to configure some settings of the service, to be included in the payload, here the parameters with their default value:
JSON.stringify({
title: 'This is default title',
...
f2a_exportFileFormat: 'pdf', // available values: pdf, png, jpeg, webp
f2a_exportPurePDF: false, // set to true to not rasterize the PDF
f2a_deviceScaleFactor: 2 // the resolution of the image rende
})
When using f2a_exportFileFormat
set as image format, all the frames will be rendered in a vertical strip format. Usually, image format is good for templates made by one single page.
If you set f2a_exportPurePDF
to true
, be aware that, depending of the complexity of the template as well as the number of pages, the service might fail or produce artefacts. Leave it false
to have better results. In some case you’d need to preserve vector elements, for simple templates it might work.
The f2a_deviceScaleFactor
is correlated to the rendering settings. By default is set to 2
that guarantee high quality. There might be case for huge templates or documents to reduce quality in order to be able to render the PDF.
You can test the API with this Retool app you can install on your Retool account: PRESENTA Test