Undersign
v1.1
Create Free Account
API Reference SDKs & Examples · JavaScript
SDKs & Examples

JavaScript Examples

Call the Undersign API from server-side JavaScript with Node.js fetch. Never expose API credentials in browser JavaScript.

Credentials

Keep your token in an environment variable:

Shell
UNDERSIGN_API_TOKEN=<BEARER_TOKEN>

List templates

Node.js
const baseUrl = 'https://toolkit.undersign.app/api/v1.1';
const token = process.env.UNDERSIGN_API_TOKEN;

const response = await fetch(`${baseUrl}/templates`, {
  headers: {
    Authorization: `Bearer ${token}`
  }
});
const data = await response.json();

Create a signature request

Node.js
const baseUrl = 'https://toolkit.undersign.app/api/v1.1';
const token = process.env.UNDERSIGN_API_TOKEN;

const response = await fetch(`${baseUrl}/signature-requests`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID()
  },
  body: JSON.stringify({
    mode: 'email',
    message: 'Please sign the official documents.',
    templates: [
      {
        template_id: '<template-uuid>',
        signers: [
          { name: 'John Doe', email: '<signer-email-1>' }
        ]
      }
    ]
  })
});
const data = await response.json();

Get signature request status

Node.js
const baseUrl = 'https://toolkit.undersign.app/api/v1.1';
const token = process.env.UNDERSIGN_API_TOKEN;

const response = await fetch(`${baseUrl}/signature-requests/<package-guid>`, {
  headers: {
    Authorization: `Bearer ${token}`
  }
});
const data = await response.json();

Never call the API from the browser

Calling the API from browser JavaScript would expose your credentials to anyone who visits your page. Make API calls from your server instead, and call your own backend from the browser.