ZapSign API
English
English
  • General Information
  • Getting Started
  • ZapSign Environments
  • Ready-to-use requests!
  • Authentication
    • Static token
    • JWT Authentication
      • Get access token
      • Refresh your access token
  • Types of Tokens
  • API versioning
  • Rate Limit Policies
  • Incident alerts
  • How Payment Works
  • Status Code
  • Account
    • Plan Information
    • List account users
    • Create account users
    • Delete account user
  • Documents
    • Create document via Upload
    • OneClick (ClickWrap)
      • Create document (OneClick)
    • Create document via Template
    • Add attachment (extra document)
    • Add attachment (extra document) via Template
    • Detail document
    • Update document
      • Reorder Documents in an Envelope
    • List documents
    • Delete document
    • Document Audit Trail
    • Optional: Place signatures
    • Reject Documents
  • Signature Validation
  • Signers
    • Detail signer
    • Update signer
    • Add signer
    • Delete signer
    • Reset validation attempts
    • Batch sign via API
    • Reject Documents by User
  • Templates
    • Create template (DOCX)
      • Configure Template Form
    • List templates
    • Get template
    • Update template
    • Delete template
  • Partnerships
    • Update Payment Status
    • Create Account
  • TIMESTAMP
    • Add timestamp
  • Background Check
  • Introduction
  • Understanding the Result
  • Creating a Background Check
    • Person Check
    • Company check
  • Retrieve a Check
  • Check details
  • Webhooks
    • How webhooks works
    • Testing webhooks on ZapSign
    • Create Webhook
    • Webhooks logs
    • Events
      • Document
        • Doc created
        • Doc deleted
        • Created signer
      • Signer
        • Signature request send
        • Document viewed
        • Reading confirmation
        • Doc signed
        • Doc refused
        • Email bounce
        • Failed Validation
      • Background check
        • Background check completed
    • Reprocessing Documents and Webhooks
    • Delete Webhook
  • Widget
    • How widget works
Powered by GitBook
On this page
  • Overview
  • How to use:
  • Example:

Was this helpful?

  1. Facilitators
  2. SDKs
  3. Typescript SDK
  4. Documents requests

createDocFromPdfBase64

Create a document via a base64 PDF

Overview

Parameters:

  • DocFromPdf

Return:

  • DocResponse - In case of success

  • Exception - In case of failure

To create this document we will need:

  • set your apiToken;

  • build your signers;

  • build the document;

  • call the method;

How to use:

Save your apiToken:

const apiToken: string = "YOUR TOKEN";

Set your base64:

const base64: string = "JVBERi0xLjYKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTG..."

Build your signers with the Signer class:

const signer1: Signer = new SignerBuilder()
                .withName("My First Signer")
                .build();

const signer2: Signer = new SignerBuilder()
                .withName("My Second Signer")
                .withEmail("test@test.com")
                .withLockEmail(true)
                .withLockPhone(true)
                .withPhoneCountry("55")
                .withPhoneNumber("99999999999")
                .withAuthMode("assinaturaTela") // draw on screen
                .withSendAutomaticEmail(false)
                .withSendAutomaticWhatsapp(false)
                .build();
                
let signers: Signer[] = [];
                
signers.push(signer1, signer2);

Build your document with the DocFromPdfBase64 class:

const docFromPdfBase64 = DocFromPdfBase64Builder()
    .withSandbox(false)
    .withName("My Contract")
    .withBrandPrimaryColor("#000000")
    .withBase64Pdf(base64)
    .build();

Finally, call the createDocFromPdfBase64 method to get the DocResponse or an error message:

try {
    docResponse = new DocRequests(apiToken).createDocFromPdfBase64(docFromPdfBase64);
    jsonDocResponse: string = new JsonConverter().docResponseToJson(docResponse);
    console.log(jsonDocResponse);
} catch {
     console.log(Err);
}

Example:

import DocRequests from "sdk-node-typescript-zapsign/src/docs/DocRequests";
import { JsonConverter } from "sdk-node-typescript-zapsign/src/services/JsonConverter";

const apiToken: string = "YOUR TOKEN";

const base64: string = "JVBERi0xLjYKJcOkw7zDtsOfCjIgMCBvYmoKP...";

const signer1: Signer = new SignerBuilder()
                .withName("My First Signer")
                .build();

const signer2: Signer = new SignerBuilder()
                .withName("My Second Signer")
                .withEmail("test@test.com")
                .withLockEmail(true)
                .withLockPhone(true)
                .withPhoneCountry("55")
                .withPhoneNumber("99999999999")
                .withAuthMode("assinaturaTela") // draw on screen
                .withSendAutomaticEmail(false)
                .withSendAutomaticWhatsapp(false)
                .build();
                
let signers: Signer[] = [];
                
signers.push(signer1, signer2);

const docFromPdfBase64 = DocFromPdfBase64Builder()
    .withSandbox(false)
    .withName("My Contract")
    .withBrandPrimaryColor("#000000")
    .build();

async function exempleDocFRomPdfBase64() {
    try {
                docResponse: DocResponse = await new DocRequests(apiToken).createDocFromPdfBase64(docFromPdfBase64);
                jsonDocResponse: string = new JsonConverter().docResponseToJson(docResponse);
                console.log(jsonDocResponse);
    } catch(Err) {
                console.log(Err);
    }
  }
}

Last updated 2 years ago

Was this helpful?