REST API overview
The endpoints your apps call and how to send the token.
On this page
Your apps talk to OpenTemplates over HTTP. The address of every endpoint starts with your OpenTemplates address, for example https://templates.example.com.
Endpoints
| Method and path | What it does |
|---|---|
POST / | Render a template. |
GET /profiles/ | List the profiles and templates. |
GET /download/{id}.{ext} | Open an uploaded file. Public, no token. |
Send the token
Every request to / and /profiles/ needs an API token. Send it in one of two ways:
- in the
x-tokenheader:
curl -H "x-token: YOUR_TOKEN" -H "Content-Type: application/json" -d '{"id":"demo/welcome","data":{"name":"Jane Doe"}}' https://templates.example.com/- or as the
tokenquery argument:
curl -H "Content-Type: application/json" -d '{"id":"demo/welcome","data":{"name":"Jane Doe"}}' "https://templates.example.com/?token=YOUR_TOKEN"The header keeps the token out of server logs, so prefer it when your app can set headers.
The primary access token of the interface does not work here: use an API token.
Too many wrong tokens
When one address sends more than five requests with a wrong token, OpenTemplates refuses every request from that address for a while, even with a correct token. The block ends by itself within 15 minutes. Check the token in your app before you try again. See Errors.