Setting up Authentication

Before you can use our API you need credentials, in the form of a key and secret. If you have not done so already, click here to create your ‘free’ account, and request your credentials.

Remember your credentials identify you, so keep them secret and keep them safe 😉. Our examples will assume that you have a secure method to retrieve this information when needed. If you have not worked with credentials before we suggest you read this .

Now that you have your credentials you can authorize your API calls.

We have provided you two examples of Authentication one using an appId, the second using your key and secret.

Both serve the same purpose to identify and authenticate the user making the API request, every TweekIT API call requires authentication.

Use whichever authentication style best fits your needs and environment.


const myApiKey = readKeyFromSecureLocation(); const myApiSecret = readSecretFromSecureLocation(); const req = new XMLHttpRequest(); req.open("POST", "<sitehost>/api/image/doctype"); req.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); req.setRequestHeader("apikey", myApiKey); req.setRequestHeader("apisecret", myApiSecret); req.onload = function () { log(req.status + " " + JSON.parse(req.responseText)); } req.send(JSON.stringify({ Extension: "jpg" }));

Setting up Authentication

This example is written in Javascript and uses the TweekIT API to return the doctype of a filename extension to a logfile. This Javascript needs to run on a firewalled server like Node and should not be used on the client where the key and secret would easily be accessible.

Note Note that the TweekIT API expects the API key header names to be "apikey" and "apisecret" instead of "x-api-key" and "secret-api-key" respectively to allow compatibility with certain Javascript libraries which do not work with header names that contain dashes when doing HTTP requests.