API reference
Authorization
The endpoint needs to be authorized with the SECRET-TOKEN
you can get from your MetaTools account. Put it in the header such as:
fetch('https://www.presenta.cc/api/<endpoint>', {
headers:{
Authorization: 'Bearer <SECRET-TOKEN>'
}
})
POST /render
The /render
endpoint requires the following valid configuration in order to work properly:
- The
SECRET-TOKEN
in the header - The
TemplateID
in the URL - The JSON payload in the body
fetch('https://www.presenta.cc/api/render/<TemplateID>', {
headers:{
Authorization: 'Bearer <SECRET-TOKEN>'
},
method: 'POST',
body: JSON.stringify({title: 'Hello'})
})
GET /cached
The /cached
endpoint is alternative to /render
, giving the possibility to retrieve a generated image multiple times, rendering it just once.
You still need to add the SECRET-TOKEN
in the header and the TemplateID
in the URL.
The payload data can be passed as URL parameters, here the equivalent example as above:
fetch('https://www.presenta.cc/api/render/<TemplateID>?title=Hello', {
headers:{
Authorization: 'Bearer <SECRET-TOKEN>'
}
})
Important to know:
- Only image format can be used, thus, no PDF.
- Only a single frame can be used, no multi frames/pages.
- Every cache hit still cost credits, even though way less than a render action.
Payload modes
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
By using a flat object, the document will be exported respecting the template structure, updating only the elements/blocks affected by the parameters in the payload:
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
By using an object with the frames
key, you're able to generate a new document 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'},
]
})
})
Special properties
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.