Creating a document

To create a document/send a document for signature

Creating documents differs slightly from other mutations because it involves uploading a file. First, we need to write the mutation:

mutation CreateDocumentMutation(
  $document: DocumentInput!, # Definition of the $document variable
  $signers: [SignerInput!]!, # $signers and $file, with its respective
  $file: Upload!             # types. (The "!" indicate that are
) {                          # mandatory parameters)      
  createDocument(
    document: $document,     # Pass the variable values to the mutation parameters
    signers: $signers,       # 
    file: $file,             #
    organization_id: 123,    # OPTIONAL: Creates in other user organizations, otherwise uses the current one
    folder_id: "a1b2c3"      # OPtIONAL: Creates archived in a folder
  ) {
    id
    name
    refusable
    sortable
    created_at
    signatures {
      public_id
      name
      email
      created_at
      action { name }
      link { short_link }
      user { id name email }
    }
  }
}

Next, we need the values of the variables defined in the mutation in a JSON:

Notice that no value has been provided for the $file variable? That's because since the file is being uploaded, the request needs to be sent as multipart/form-data, so the file must be handled a bit differently. You can do this directly in Altair:

Creating documents on Sandbox

Our API also supports sending test documents, which do not consume document credits, making integration easier for those who have not yet acquired a plan with unlimited documents. To learn how to do this, visit our sandbox page.

More options:

Positioning signature fields "positions"

As shown in the example above, to add signature fields when creating the document, you need to include the "positions" attribute.

The “x” value represents the horizontal position, ranging from 0% to 100%. The “y” value represents the vertical position, also ranging from 0% to 100%. The “z” value indicates the page number, starting at 1.

O "element" It's the type of signature "SIGNATURE": Signature "NAME": Signer's name "INITIALS": Initials "DATE": Signature date "CPF": Signer CPF

To know what positions to pass for x and y, you can create a sample document in the Autentique dashboard and retrieve the positions by fetching the document using "positions":

Require SMS verification and/or photo document verification "security_verifications"

To require signers to verify via SMS and/or photo document, you need to add the "security_verifications" attribute to the signer for whom these verifications should be required. Remember to check in the dashboard for the cost of additional verification credits needed.

The "type" is the type of verification:

  • "SMS": SMS validation ("verify_phone" is optional and requires a specified phone number)

  • "MANUAL": Require a photo document (manual approval)

  • "UPLOAD": Require a photo document (photo document)

  • "LIVE": Require a photo document (document, selfie, and proof of life)

  • "PF_FACIAL": Require a photo document (SERPRO biometric verification)

  • "BIOMETRIC_AND_TEXT_EXTRACTION": Require a photo document (photo document and facematch)

While it's possible to have multiple verifications for the same signer, you can only choose one of the following options per signer: MANUAL, UPLOAD, LIVE, and PF_FACIAL.

When the types UPLOAD, LIVE, PF_FACIAL and BIOMETRIC_AND_TEXT_EXTRACTION are used, there is a default behavior where they are changed to MANUAL when the signer exceeds the maximum number of attempts in the document validation process. To disable this behavior, you must use the fallback_behavior parameter, which will flag the document as failed and automatically reject it.

Create a document from a template

There is no way in the API to directly use the panel templates to create documents. However, you can achieve something similar through your code:

  1. Create a fixed HTML template on your machine, marking the places with variables to be replaced by values. (e.g., "I, $NomeSignatario$, accept this contract")

  2. Programmatically duplicate this HTML and in the duplicate, replace the variable fields with the actual values. (e.g., $NomeSignatario$ → Jorge Silva)

  3. Send this HTML file with the replaced values to our API through the createDocument mutation, just like it works for other types of files.

Example of document creation with NodeJS

If you use Postman, you can generate these examples from the Postman collection provided here in the documentation.

For this example, just replace the API token, the signer's email, and the file path.

Example of document creation with PHP

If you use Postman, you can generate these examples from the Postman collection provided here in the documentation documentation.

In this example, you just need to replace the API token, the signer's email, and the file path.

Example of document creation with Python3

If you use Postman, you can generate these examples from the Postman collection provided here in the documentation documentation.

In this example, you just need to replace the API token, the signer's email, and the file path.

Example of document creation with C#

If you use Postman, you can generate these examples from the Postman collection provided here in the documentation documentation.

In this example, you just need to replace the API token, the signer's email, and the file path.

You can check what each of these parameters means directly in the full GraphQL API documentation, in the Docs menu of Altair. If you're not sure how to do that, check out our tutorial on Using Altair.

Para importar e usar no Postman

Last updated

Was this helpful?