Any endpoints need to be authenticated with the SECRET-TOKEN
you receive by email after your subscription. Put it in the header such as:
fetch('https://www.presenta.cc/api/<endpoint>', {
headers:{
Authentication: 'Bearer <SECRET-TOKEN>'
},
method: 'POST'
})
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:{
Authentication: '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:{
Authentication: '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:{
Authentication: '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'},
]
})
})