NAV Navbar
javascript
  • Introduction
  • Authentication
  • Envelopes
  • Events
  • Errors
  • Introduction

    Welcome to the Scriptsign API! You can use our API to create envelopes for your users to sign electronically.

    Authentication

    Make sure to replace themajorapikey with your API key.

    Scriptsign uses API keys to allow access to the API. You can register a new Scriptsign API key at our developer portal.

    Scriptsign expects for the API key to be included in all API requests to the server in a header that looks like the following:

    ?api_key=themajorapikey or as a post api_key=themajorapikey

    Envelopes

    Create an Envelope

    const request = require('request');
    const fs = require('fs')
    
    const postData = {
      document_base64: new Buffer(fs.readFileSync('/path/to/file.pdf')).toString('base64'),
      document_name: `Obvious Island Review document`,
      api_key: 'themajorapikey'
    }
    
    postData.recipients = JSON.stringify([
      {
        page_number: 1,
        name: "Capt Obvious",
        email: "very@obvious.com",
        x_axis: 240,
        y_axis: 100
      }
    ])
    
    postData.events = JSON.stringify({
      webhook: `http://obvious.com/captain/webhook`,
      envelope: ['completed'],
      recipient: ['completed']
    })
    
    const options = {
      method: 'POST',
      uri: 'https://scriptsign.co/api/envelope',
      json: true,
      form: postData
    }
    
    request.post(options)
      .then(response => {
        if(!response.data){
          console.log("Error Occurred while processing document.")
        }
    
        console.log(response.data);
      })
    

    The above command returns JSON structured like this:

    {
      "data": {
        "envelope": {
          "created_at": "2017-12-16T08:56:39+00:00",
          "document_name": "Test",
          "uuid": "5e014bd495604b209e30f231cf38c504"
        },
        "recipients": [
          {
            "created_at": "2017-12-16T08:56:39+00:00",
            "email": "very@obvious.com",
            "has_signed": false,
            "name": "Capt Obvious",
            "signing_url": "https://scriptsign.co/697e6bddaf30488fb3505bbcfd9091d2/sign",
            "uuid": "697e6bddaf30488fb3505bbcfd9091d2"
          }
        ]
      },
      "message": "Envelope successfully created",
      "success": true
    }
    

    This endpoint creates a new envelope.

    HTTP Request

    POST https://scriptsign.co/api/envelope

    Query Parameters

    Parameter Default Description
    handle_mail 0 If set to 1, scripsign would handle sending mails to the recipients.
    document_base64 - **Base64 encoded copy of your PDF Document
    document_name - **Name of the document
    recipients - JSON Encoded array of signatories [{"name": "Capt Obvious", "email": "very@obvious.com", "page_number": "1", "x_axis": 240, "y_axis": 100}] x_axis and y_axis are measured in points and start from the bottom left corner
    api_key - ** Your api key
    events - JSON Encoded Object of events ScriptSign should respond to: {"webhook":"http://localhost:9090/document/hook", "envelope": ["completed"], "recipient": ["completed"]}

    Run in Postman

    Run in Postman

    Events

    Tracking events as they happen to your envelope is an integral part of ScriptSign.

    Create Events

    To attach events to an envelope, add the events parameter which contains an object to the POST data sent to the /api/envelope endpoint.

    { 'webhook': 'webhook_url', 'envelope': [array of envelope events], 'recipient': [array of recipient events] }

    Envelope Events

    Envelope events occur on the Envelopes as a self-contained entity. Envelope events include:

    Recipient Events

    Recipient events are events triggered intentionally or otherwise by your envelope recipients. Recipient events include:

    Webhook

    ScriptSign would need a url to send the events.

    You should create an unauthenticated POST endpoint on your application that can recieve JSON data.

    Errors

    The ScriptSign API uses the following error codes:

    Error Code Meaning
    400 Bad Request -- Your request sucks.
    401 Unauthorized -- Your API key is wrong.
    403 Forbidden -- You don't have permission to access resource.
    404 Not Found -- The specified resource could not be found.
    405 Method Not Allowed -- You tried to access a resource with an invalid method.
    406 Not Acceptable -- You requested a format that isn't json.
    500 Internal Server Error -- We had a problem with our server. Try again later.
    503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.