Quick guide on how to start the API

We present the API documentation of the File Builder tool where you can see in detail the different endpoints and ways of response.

The main function of the API is to allow you to generate pdf and thumbnail through html code, for this you only have to follow the following steps:

Authentication

Labs

Required: Api key

Prod

Required: Api key

Format

API-rest

Response Codes

For positive responses we have code 200, error responses 400 and 500

EndPoints V1

Post /pdf

This resource allows you to create a pdf from an html code, there is also the option to download the content from a url or directly.

With hmtl

{
   "data":{
      "usuario":"<strong>Cliente Importante</strong>",
      "adjunto":"8275",
      "carta-jefe":"<div>Esto es un pdf.</div>"
   },
   "html":"<div>Esto es un pdf.</div>",
   "password":null,
   "pdfId":"1234567890123456",
   "absolute_path":"/tmp/cosa.pdf",
   "folder":"Prueba",
   "options":{
      "encoding":"UTF-8"
   },
"idClient" : 1,
   "metadata":{
      "emailJobId":"5c1b2fcf0044737efcb29fbc"
   }
}

With url

{
  "data": {
    "usuario": "<strong>Cliente Importante</strong>",
    "adjunto": "8275",
    "carta-jefe": "<div>Esto es {{adjunto}} un pdf.</div>"
  },
"idClient" : 1,
   "url":"<https://masivapp.com/ViewInBrowser/Index?idPackage=9005008&tag=MASIVC89A29293E6C&idSend=2&utm_campaign=website&utm_source=Masiv&utm_medium=Email>",
  "password": "null",
  "options": { "encoding": "UTF-8" },
  "metadata": { "emailJobId": "5c1b2fcf0044737efcb29fbc" }
}

data: (Object type) - (Optional) Refers to the values for the replacement fields within the html url: (String type) Refers to a url that contains the html to render html: (String type) Refers to stringfly of the html to render password: (String or int type) - (Optional) password of the file to generate (Optional) options: (Object type) - (Optional) Refers to the configuration options for rendering

metadata: (Object type) - (Optional) Additional data that you want to send in the request

Generate pdf and send webhook

Currently we send webbook through API, SQS OR RabbitMq

{
    "data": {
      "usuario": "<strong>Cliente Importante</strong>",
      "adjunto": "8275",
      "carta-jefe": "<div>Esto es un pdf.</div>"
    },
    "password" : "1234",
"idClient" : 1,
    "html": "<div>Esto es un pdf.</div>",
    "options": {
      "encoding": "UTF-8",
      "zoom": 1
    },
    "hook": "<https://testpdf.requestcatcher.com/test>",
    "metadata": { "emailJobId": "5c1b2fcf0044737efcb29fbc" }
  }

hook: (String type) - (Required) This field refers to the address where the message will be delivered

note: rabbit url should always be encoded in bs64

token: (String type) - (Optional) In case the API requires a token

When sending through RabbitMQ, the following keys must be added:

queue_name: (String type) - (Required) destination queue name

routing_key: (String type) - (Required)

exchange: (String type) - (Required)

Response:

Status Code: 200

{
    "id": "idPdf",
    "filepath": "filepath"
}

Status Code: 400, 500

{
    "statusCode": statusCode,
    "headers": {
        "Access-Control-Allow-Origin": "*"
    },
    "body": "{\\"status\\": \\"message\\"}"
}

Post /thumbnail

This resource allows you to create thumbnail images

{
   "data":{
      "usuario":"<strong>Cliente Importante</strong>",
      "adjunto":"8275",
      "carta-jefe":"<div>Esto es un pdf.</div>"
   },
"idClient" : 1,
   "url":"<https://masivapp.com/ViewInBrowser/Index?idPackage=9005008&tag=MASIVC89A29293E6C&idSend=2&utm_campaign=website&utm_source=Masiv&utm_medium=Email>",
   "options":{
      "encoding":"UTF-8",
      "zoom":0.2
   }
}

data: Refers to the values for the replacement fields within the html html: Refers to stringfly of the html to render url: Refers to a url that contains the html to render options: Refers to the configuration options for rendering