1.0.0 • Published 2 years ago

yousign-v3-node v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Yousign node.js SDK

Yousign Node.js SDK is the official Node Wrapper around the Yousign API v3.

Installation

Install from npm:

cd your_project
npm install yousign

Install from code:

git clone https://github.com/yousign/yousign-node-sdk.git
cd yousign-node-sdk
npm install

Usage

All Yousign API requests are made using the Client class. This class must be initialized with your API key and by specifying the environment to be used (productionor sandbox). How to create an API Key

In your Node application, require yousign (or the path to the sdk folder if not using npm) and pass authentication information to initialize it:

// Initialize using proper api key for the target enviromnent
const { Client } = require('yousign')
const client = new Client('YOUR_API_KEY', 'production')
// const client = new Client('YOUR_API_KEY', 'sandbox');

Create and send a Signature Request

const sr = await client.createSignatureRequest({
  name: 'A Signature Request Test',
  delivery_mode: 'email',
  reminder_settings: {
    interval_in_days: 7,
    max_occurrences: 5,
  },
  timezone: 'Europe/Paris',
  email_custom_note: 'Please sign this signature request',
})

const pdf = fs.createReadStream('demo.pdf')

const signable_document = await client.createdDocument(sr.id, pdf, 'signable_document')

await client.createSigner(sr.id, {
  info: {
    first_name: 'John',
    last_name: 'Doe',
    email: 'john.doe@acme.com',
    phone_number: '+33700000000',
    locale: 'fr',
  },
  fields: [
    {
      document_id: signable_document.id,
      type: 'signature',
      height: 50,
      width: 120,
      page: signable_document.total_pages,
      x: 10,
      y: 10,
    },
  ],
})

await api.activate_sr(sr.id)