Skip to content

Latest commit

History

History
549 lines (459 loc) · 30.4 KB

File metadata and controls

549 lines (459 loc) · 30.4 KB

pdf-generator-api

Introduction

PDF Generator API allows you easily generate transactional PDF documents and reduce the development and support costs by enabling your users to create and manage their document templates using a browser-based drag-and-drop document editor.

The PDF Generator API features a web API architecture, allowing you to code in the language of your choice. This API supports the JSON media type, and uses UTF-8 character encoding.

Base URL

The base URL for all the API endpoints is https://us1.pdfgeneratorapi.com/api/v4

For example

  • https://us1.pdfgeneratorapi.com/api/v4/templates
  • https://us1.pdfgeneratorapi.com/api/v4/workspaces
  • https://us1.pdfgeneratorapi.com/api/v4/templates/123123

Editor

PDF Generator API comes with a powerful drag & drop editor that allows to create any kind of document templates, from barcode labels to invoices, quotes and reports. You can find tutorials and videos from our Support Portal.

Definitions

Organization

Organization is a group of workspaces owned by your account.

Workspace

Workspace contains templates. Each workspace has access to their own templates and organization default templates.

Master Workspace

Master Workspace is the main/default workspace of your Organization. The Master Workspace identifier is the email you signed up with.

Default Template

Default template is a template that is available for all workspaces by default. You can set the template access type under Page Setup. If template has "Organization" access then your users can use them from the "New" menu in the Editor.

Data Field

Data Field is a placeholder for the specific data in your JSON data set. In this example JSON you can access the buyer name using Data Field {paymentDetails::buyerName}. The separator between depth levels is :: (two colons). When designing the template you don’t have to know every Data Field, our editor automatically extracts all the available fields from your data set and provides an easy way to insert them into the template.

{
"documentNumber": 1,
"paymentDetails": {
"method": "Credit Card",
"buyerName": "John Smith"
},
"items": [
{
"id": 1,
"name": "Item one"
}
]
}

Rate limiting

Our API endpoints use IP-based rate limiting and allow you to make up to 2 requests per second and 60 requests per minute. If you make more requests, you will receive a response with HTTP code 429.

Response headers contain additional values:

HeaderDescription
X-RateLimit-LimitMaximum requests per minute
X-RateLimit-RemainingThe requests remaining in the current minute
Retry-AfterHow many seconds you need to wait until you are allowed to make requests

Libraries and SDKs

Postman Collection

We have created a Postman Collection so you can easily test all the API endpoints without developing and code.

Client Libraries

All our Client Libraries are auto-generated using OpenAPI Generator which uses the OpenAPI v3 specification to automatically generate a client library in specific programming language.

We have validated the generated libraries, but let us know if you find any anomalies in the client code.

Model Context Protocol (MCP) Server

Integrate document generation directly into your AI agents and LLM applications using our official Model Context Protocol (MCP) Server.

The MCP server provides a standardized interface that allows AI assistants (like Claude Desktop and other MCP-compatible clients) to securely interact with the PDF Generator API. With it, your AI applications can automatically fetch workspaces, retrieve templates, merge data, and generate PDF documents on the fly.

Get PDF Generator API MCP Server


Authentication

The PDF Generator API uses JSON Web Tokens (JWT) to authenticate all API requests. These tokens offer a method to establish secure server-to-server authentication by transferring a compact JSON object with a signed payload of your account’s API Key and Secret. When authenticating to the PDF Generator API, a JWT should be generated uniquely by a server-side application and included as a Bearer Token in the header of each request.

Accessing your API Key and Secret

You can find your API Key and API Secret from the Account Settings page after you login to PDF Generator API here.

Creating a JWT

JSON Web Tokens are composed of three sections: a header, a payload (containing a claim set), and a signature. The header and payload are JSON objects, which are serialized to UTF-8 bytes, then encoded using base64url encoding.

The JWT's header, payload, and signature are concatenated with periods (.). As a result, a JWT typically takes the following form:

{Base64url encoded header}.{Base64url encoded payload}.{Base64url encoded signature}

We recommend and support libraries provided on jwt.io. While other libraries can create JWT, these recommended libraries are the most robust.

Header

Property alg defines which signing algorithm is being used. PDF Generator API users HS256. Property typ defines the type of token and it is always JWT.

{
"alg": "HS256",
"typ": "JWT"
}

Payload

The second part of the token is the payload, which contains the claims or the pieces of information being passed about the user and any metadata required. It is mandatory to specify the following claims:

  • issuer (iss): Your API key
  • subject (sub): Workspace identifier
  • expiration time (exp): Timestamp (unix epoch time) until the token is valid. It is highly recommended to set the exp timestamp for a short period, i.e. a matter of seconds. This way, if a token is intercepted or shared, the token will only be valid for a short period of time.
{
"iss": "ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a",
"sub": "demo.example@actualreports.com",
"exp": 1586112639
}

Payload for Partners

Our partners can send their unique identifier (provided by us) in JWT's partner_id claim. If the partner_id value is specified in the JWT, the organization making the request is automatically connected to the partner account.

  • Partner ID (partner_id): Unique identifier provide by PDF Generator API team
{
"iss": "ad54aaff89ffdfeff178bb8a8f359b29fcb20edb56250b9f584aa2cb0162ed4a",
"sub": "demo.example@actualreports.com",
"partner_id": "my-partner-identifier",
"exp": 1586112639
}

Signature

To create the signature part you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that. The signature is used to verify the message wasn't changed along the way, and, in the case of tokens signed with a private key, it can also verify that the sender of the JWT is who it says it is.

HMACSHA256(
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
API_SECRET)

Putting all together

The output is three Base64-URL strings separated by dots. The following shows a JWT that has the previous header and payload encoded, and it is signed with a secret.

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhZDU0YWFmZjg5ZmZkZmVmZjE3OGJiOGE4ZjM1OWIyOWZjYjIwZWRiNTYyNTBiOWY1ODRhYTJjYjAxNjJlZDRhIiwic3ViIjoiZGVtby5leGFtcGxlQGFjdHVhbHJlcG9ydHMuY29tIn0.SxO-H7UYYYsclS8RGWO1qf0z1cB1m73wF9FLl9RCc1Q
// Base64 encoded header: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
// Base64 encoded payload: eyJpc3MiOiJhZDU0YWFmZjg5ZmZkZmVmZjE3OGJiOGE4ZjM1OWIyOWZjYjIwZWRiNTYyNTBiOWY1ODRhYTJjYjAxNjJlZDRhIiwic3ViIjoiZGVtby5leGFtcGxlQGFjdHVhbHJlcG9ydHMuY29tIn0
// Signature: SxO-H7UYYYsclS8RGWO1qf0z1cB1m73wF9FLl9RCc1Q

Temporary JWTs

You can create a temporary token in Account Settings page after you login to PDF Generator API. The generated token uses your email address as the subject (sub) value and is valid for 15 minutes. You can also use jwt.io to generate test tokens for your API calls. These test tokens should never be used in production applications.


Error codes

CodeDescription
401Unauthorized
402Payment Required
403Forbidden
404Not Found
422Unprocessable Entity
429Too Many Requests
500Internal Server Error

401 Unauthorized

Description
Authentication failed: request expired
Authentication failed: workspace missing
Authentication failed: key missing
Authentication failed: property 'iss' (issuer) missing in JWT
Authentication failed: property 'sub' (subject) missing in JWT
Authentication failed: property 'exp' (expiration time) missing in JWT
Authentication failed: incorrect signature

402 Payment Required

Description
Your account is suspended, please upgrade your account

403 Forbidden

Description
Your account has exceeded the monthly document generation limit.
Access not granted: You cannot delete master workspace via API
Access not granted: Template is not accessible by this organization
Your session has expired, please close and reopen the editor.

404 Entity not found

Description
Entity not found
Resource not found
None of the templates is available for the workspace.

422 Unprocessable Entity

Description
Unable to parse JSON, please check formatting
Required parameter missing
Required parameter missing: template definition not defined
Required parameter missing: template not defined

429 Too Many Requests

Description
You can make up to 2 requests per second and 60 requests per minute.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 4.0.28
  • Package version: 8.0.28
  • Generator version: 7.14.0
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://support.pdfgeneratorapi.com

Requirements.

Python 3.9+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/pdfgeneratorapi/python-client.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/pdfgeneratorapi/python-client.git)

Then import the package:

importpdf_generator_api_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

importpdf_generator_api_client

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

importpdf_generator_api_clientfrompdf_generator_api_client.restimportApiExceptionfrompprintimportpprint# Defining the host is optional and defaults to https://us1.pdfgeneratorapi.com/api/v4# See configuration.py for a list of all supported configuration parameters.configuration=pdf_generator_api_client.Configuration(
host="https://us1.pdfgeneratorapi.com/api/v4"
)
# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure Bearer authorization (JWT): JSONWebTokenAuthconfiguration=pdf_generator_api_client.Configuration(
access_token=os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API clientwithpdf_generator_api_client.ApiClient(configuration) asapi_client:
# Create an instance of the API classapi_instance=pdf_generator_api_client.AssetsApi(api_client)
generate_qr_code_request=pdf_generator_api_client.GenerateQRCodeRequest() # GenerateQRCodeRequest | QR Code configurationtry:
# Generate QR Codeapi_response=api_instance.generate_qr_code(generate_qr_code_request)
print("The response of AssetsApi->generate_qr_code:\n")
pprint(api_response)
exceptApiExceptionase:
print("Exception when calling AssetsApi->generate_qr_code: %s\n"%e)

Documentation for API Endpoints

All URIs are relative to https://us1.pdfgeneratorapi.com/api/v4

ClassMethodHTTP requestDescription
AssetsApigenerate_qr_codePOST /assets/qrcodeGenerate QR Code
ConversionApiconvert_html2_pdfPOST /conversion/html2pdfHTML to PDF
ConversionApiconvert_pdf2_imagePOST /conversion/pdf2imagePDF to Image
ConversionApiconvert_url2_pdfPOST /conversion/url2pdfURL to PDF
DocumentsApidelete_documentDELETE /documents/{publicId}Delete document
DocumentsApigenerate_documentPOST /documents/generateGenerate document
DocumentsApigenerate_document_asynchronousPOST /documents/generate/asyncGenerate document (async)
DocumentsApigenerate_document_batchPOST /documents/generate/batchGenerate document (batch)
DocumentsApigenerate_document_batch_asynchronousPOST /documents/generate/batch/asyncGenerate document (batch + async)
DocumentsApigenerate_viewer_urlPOST /documents/{publicId}Get document with prefill
DocumentsApiget_async_job_statusGET /documents/async/{jobId}Get job status
DocumentsApiget_documentGET /documents/{publicId}Get document
DocumentsApiget_document_actionsGET /documents/{publicId}/actionsGet document actions
DocumentsApiget_document_versionsGET /documents/{publicId}/versionsGet document versions
DocumentsApiget_documentsGET /documentsGet documents
DocumentsApistore_documentPOST /documentsStore document
FormsApicreate_formPOST /formsCreate form
FormsApidelete_formDELETE /forms/{formId}Delete form
FormsApiget_formGET /forms/{formId}Get form
FormsApiget_formsGET /formsGet forms
FormsApiimport_formPOST /forms/importImport Form
FormsApiopen_form_builderPOST /forms/openOpen new form builder
FormsApiopen_form_builder_for_existing_formPOST /forms/{formId}/openOpen existing form builder
FormsApishare_formPOST /forms/{formId}/shareShare form
FormsApiupdate_formPUT /forms/{formId}Update form
MiscApiget_statusGET /statusGet Service Status
ServicesApiadd_watermarkPOST /pdfservices/watermarkAdd watermark
ServicesApidecrypt_documentPOST /pdfservices/decryptDecrypt document
ServicesApiencrypt_documentPOST /pdfservices/encryptEncrypt document
ServicesApiextract_form_fieldsPOST /pdfservices/form/fieldsExtract form fields
ServicesApifill_form_fieldsPOST /pdfservices/form/fillFill form fields
ServicesApimake_accessiblePOST /pdfservices/make-accessibleMake accessible
ServicesApioptimize_documentPOST /pdfservices/optimizeOptimize document
TemplateLibraryApiget_template_libraryGET /templates/libraryGet template library
TemplateLibraryApiget_template_library_itemGET /templates/library/{publicId}Open template from the library
TemplateVersionsApidelete_template_versionDELETE /templates/{templateId}/versions/{templateVersion}Delete template version
TemplateVersionsApiget_template_versionGET /templates/{templateId}/versions/{templateVersion}Get template version
TemplateVersionsApilist_template_versionsGET /templates/{templateId}/versionsList template versions
TemplateVersionsApipromote_template_versionPUT /templates/{templateId}/versions/{templateVersion}/promotePromote template version
TemplatesApicopy_templatePOST /templates/{templateId}/copyCopy template
TemplatesApicreate_templatePOST /templatesCreate template
TemplatesApidelete_templateDELETE /templates/{templateId}Delete template
TemplatesApiget_templateGET /templates/{templateId}Get template
TemplatesApiget_template_dataGET /templates/{templateId}/dataGet template data fields
TemplatesApiget_template_schemaGET /templates/schemaGet schema
TemplatesApiget_templatesGET /templatesGet templates
TemplatesApiimport_templatePOST /templates/importImport template
TemplatesApiopen_editorPOST /templates/{templateId}/editorOpen editor
TemplatesApiupdate_templatePUT /templates/{templateId}Update template
TemplatesApivalidate_templatePOST /templates/validateValidate template
WorkspacesApicreate_workspacePOST /workspacesCreate workspace
WorkspacesApidelete_workspaceDELETE /workspaces/{workspaceIdentifier}Delete workspace
WorkspacesApiget_workspaceGET /workspaces/{workspaceIdentifier}Get workspace
WorkspacesApiget_workspacesGET /workspacesGet workspaces
EInvoicesApicreate_e_invoicePOST /einvoiceCreate eInvoice
EInvoicesApicreate_factur_xe_invoicePOST /einvoice/facturxCreate Factur-X eInvoice
EInvoicesApicreate_x_rechnung_e_invoicePOST /einvoice/xrechnungCreate XRechnung eInvoice
EInvoicesApiget_e_invoice_schemaGET /einvoice/schemaGet schema

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

JSONWebTokenAuth

  • Type: Bearer authentication (JWT)

Author

support@pdfgeneratorapi.com