Verdocs Logo
Developer Center
Follow @verdocs
Visit Verdocs.com Open App

Server Example

Verdocs JS SDK functions generally have self-explanatory names. Simply import the functions you need, and call them with the appropriate parameters. The example below authenticates as a server application using the Client Credentials grant type and obtains a list of templates in the related account.

import {VerdocsEndpoint, authenticate, getTemplates} from '@verdocs/js-sdk';

const endpoint = VerdocsEndpoint.getDefault();

const authResult = await authenticate(endpoint, { 
  grant_type: 'client_credentials', 
  client_id: ID, 
  client_secret: SECRET 
});
endpoint.setToken(authResult.access_token);

const templates = await endpoint.getTemplates(endpoint);
templates.forEach(template => {
  console.log('Template: ' + template.id + ' - ' + template.name)
});