openapi: "3.0.0"
info:
  description: |
    # Introduction

    Welcome to the CraftMyPDF API!

    This page contains the documentation on how to use CraftMyPDF through API calls.
    You can use the CraftMyPDF API to create PDF documents and manage your templates

    The CraftMyPDF API is built on RESTful HTTP. You can use your favorite HTTP/REST library for your programming language to use CraftMyPDF's API.

    # Request Content-Type
    The Content-Type for POST and GET requests is set to application/json.

    # Cross-Origin Resource Sharing
    This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with  [W3C spec](https://www.w3.org/TR/cors/).
    And that allows cross-domain communication from the browser.
    All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.

    # Authentication
    When you sign up for an account, an API key is generated, you can reset the API key in the web console(Under API Integration).

    In order to integrate with our services, you need to authenticate to the CraftMyPDF API by providing your secret key in the request header X-API-KEY.


    # Regional API endpoints
    A regional API endpoint is intended for customers in the same region. The data for the request and generated PDFs are processed and stored within the region.

    The regions are:

    | Region               | Endpoint                            | Max Timeout           | Max Payload Size**      |
    |----------------------|-------------------------------------|-----------------------|-------------------------|
    | Default (Singapore)  | https://api.craftmypdf.com/         | 100 seconds           | 4   MB                  |
    | Europe (Frankfurt)   | https://api-de.craftmypdf.com/      | 100 seconds           | 4   MB                  |
    | US East (N. Virginia)| https://api-us.craftmypdf.com/      | 100 seconds           | 4   MB                  |
    | Australia (Sydney)   | https://api-au.craftmypdf.com/      | 30  seconds           | 6 MB                    |

    Alternative Regions:
    | Region               | Endpoint                            | Max Timeout          | Max Payload Size**      |
    |----------------------|-------------------------------------|----------------------|-------------------------|
    | Default (Singapore)  | https://api-alt.craftmypdf.com/     | 30 seconds           | 6 MB                    |
    | Europe (Frankfurt)   | https://api-alt-de.craftmypdf.com/  | 30 seconds           | 6 MB                    |
    | US East (N. Virginia)| https://api-alt-us.craftmypdf.com/  | 30 seconds           | 6 MB                    |


    ** Note:
    - The payload size applies to request and response
    - If "export_type" is set to `json` which output file that on AWS S3 doesn't have the limitation
    - If the "export_type" is set to `file` which returns binary data of the generated PDF, the file size of the generated PDF is limited to either 6MB or 1MB based on the region





    **Other regions are available on request, contact us at hello@craftmypdf.com for more information**




    # IP Whitelisting
    If you need to access the content of certain URLs from our services, you may need to whitelist the following IP addresses based on your region:

    | Region               | IP Address        |
    |----------------------|-------------------|
    | Singapore (SG)       | 54.169.31.181/32  |
    | Australia (AU)       | 3.105.245.173/32  |
    | Europe (DE)          | 35.159.181.52/32  |
    | US East (N. Virginia)| 52.21.225.83/32   |

    **Note:** These IP addresses are used by our services when making outbound requests to external URLs. If you have firewall rules or security groups that restrict access, you'll need to whitelist the appropriate IP address for your region to ensure our services can access your content.




    # How to receive generated PDFs
    There are three ways to get the generated PDFs/images:

    **1. Use the API `/v1/create` and `/v1/create-image` for PDF/image generation**
    - Option `export_type=json`: The generated PDFs are uploaded to our cloud CDN and the PDF URLs are returned in the JSON response immediately.
    - Option `export_type=file`: The generated PDFs are returned in binary in the response immediately and we do not store the PDFs.

    **2. Use the API `/v1/create-async` for async PDF/image generation** :

    An aysnc call returns immediately and you receive the generated PDFs via webhook callback.



    **3. Bring Your Own Storage (BYOS)** :

    The most secure way is to configure uploading the PDFs/images directly to your AWS S3 and we never store the PDFs.
    To configure, click on the **API Integration** tab. Then, select **Post Actions** and enter your S3 settings.

    # Rate limiting
      Our API enforces IP-based rate limits to ensure fair usage and maintain optimal performance:
      - 100 requests per 10 seconds per IP address
      - 100 concurrent synchronous PDF-generation requests per user account

      If you exceed these limits, you’ll receive an HTTP 429 response, indicating that you’ve hit the rate cap and should pause before retrying.

      ** For high-volume PDF generation, consider our asynchronous endpoint (POST /v1/create-async). Requests are queued and processed in turn, and you’ll receive a webhook callback once your PDF is ready.

  version: 1.0.0
  title: CraftMyPDF API Reference
  termsOfService: 'https://craftmypdf.com/privacy-policy/'
  contact:
    email: hello@craftmypdf.com
    url: https://craftmypdf.com
  x-logo:
    url: 'images/icon-docs.svg'
    altText: CraftMyPDF logo
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
servers:
  - url: https://api.craftmypdf.com/v1
  - url: https://api-de.craftmypdf.com/v1
  - url: https://api-us.craftmypdf.com/v1
  - url: https://api-au.craftmypdf.com/v1
  - url: https://api-alt.craftmypdf.com/v1
  - url: https://api-alt-de.craftmypdf.com/v1
  - url: https://api-alt-us.craftmypdf.com/v1
  - url: https://api-alt-au.craftmypdf.com/v1
security:
  - ApiKeyAuth: []

paths:
  /create:
    post:
      summary: Create a PDF
      operationId: create
      description: 'This endpoint creates a PDF file with JSON data and your template'
      tags:
        - PDF Generation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_id:
                  type: string
                  description: |
                    - Template ID. 
                    - You can specify a single template ID or multiple template IDs separated by commas.
                    - If you specify multiple template IDs(e.g `05f77b2b18ad809a,81f338abcdd83d`). The PDFs will be generated from multiple templates and the paging mode will be set to `continuous`.
                  example: '05f77b2b18ad809a'                
                data:
                  type: string
                  description: JSON data, it supports stringified JSON string or an JSON object
                  example:
                    {
                      "invoice_number": "INV38379",
                      "date": "2021-09-30",
                      "currency": "USD",
                      "total_amount": 82542.56
                    }
                load_data_from:
                  type: string
                  description: Load data from an external URL. If this is specified, it will overwrite the `data`` property.
                  example:


                version:
                  type: string
                  description: To generate a PDF using a specific version of the template. We use the latest template version unless you specify otherwise.
                  example: 8
                export_type:
                  type: string
                  description: |
                    Either `file` or `json`.
                    - The option `json` returns a JSON object, and the output PDF is stored on a CDN(until expiration).
                    - The option `file` returns binary data of the generated PDF(More secure and completely private) and the response HTTP header Content-Disposition is set to attachment.
                  example: 'json'
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.pdf'
                  example: 'output.pdf'
                image_resample_res:
                  type: integer
                  description: Optimize/downsample images of current PDF to a resolution(in DPI). This helps to reduce the PDF file size. Suggested values are 1200, 600, 300, 150 or 72.
                  example: 600
                direct_download:
                  type: integer
                  description: |
                    Default to 0. Set to 1 to indicate the generated PDF should be downloaded (Content-Disposition: attachment)
                  example: 0
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN(Except export_type=file), default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1
                password_protected:
                  type: boolean
                  description: |
                    Enable password protection
                password:
                  type: string
                  description: |
                    if password_protected is enabled, please specify a password

                postaction_s3_filekey:
                  type: string
                  description: |
                    This is to specify the file name for `Post Action(S3 Storage)`.
                    - Please do not specify the file extension
                    - Please make sure the file name is unique
                    - You might use slash (/) as the folder delimiter

                postaction_s3_bucket:
                  type: string
                  description: |
                    - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.

                resize_images:
                  type: boolean
                  description: |
                    - Resize all the images in the PDF to help reduce its size, especially if the template contains multiple or large images. 
                    - Either `1`=`true` or `0`=`false`. Default to '0'
                    - If `resize_images` is set to `1`, specify the `resize_max_width`, `resize_max_height` in pixels.
                    - Images to be resized need to satisfy the following conditions:
                      - The images with the content-type `image/jpeg`, `image/jpg` or `image/png`
                      - The image URLs with the extension `.jpg`, `.jpeg` or `.png`
                  example: '0'

                resize_max_width:
                  type: integer
                  description: |
                    - If `resize_images` is set to `1`, specify the maximum width in pixels for the images. Default to '1000'
                  example: '1000'                

                resize_max_height:
                  type: integer
                  description: |
                    - If `resize_images` is set to `1`, specify the maximum height in pixels for the images . Default to '1000'
                  example: '1000'

                resize_format:
                  type: string
                  description: |
                    - (Optional) If `resize_images` is set to `1`, specify the format of the image. Either `jpeg` or `png`
                  example: 'jpeg'
                paging:
                  type: string
                  description: |
                    This is for multiple templates. If multiple template ids are specified, this detemines the paging for the next PDF, either is 'continuous' or 'reset' . Default to 'continuous'
                    - continuous : The expression {{sys.totalPages}} is the sum of the merged PDF and the {{sys.pageNumber}} continue from the last PDF page number.
                    - reset: The expression {{sys.totalPages}} is the total pages of current PDF and the {{sys.pageNumber}} auto-reset to zero in the next PDF.
                pdf_version:
                  type: string
                  description: |
                    - (Experimental) PDF version to generate. Supported versions are '1.4' and '1.7'. Defaults to 'Auto' which generates PDF 1.7.
                  example: '1.7'
                  enum: ['1.4', '1.7', 'Auto']                    
              required:
                - data
                - template_id
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessSingleFile'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "export_type":"json", "expiration": 10, "output_file":"my_new.pdf", "data":  "{ \"invoice_number\": \"INV38379\", \"date\": \"2021-09-30\",  \"currency\": \"USD\", \"total_amount\": 82542.56   }"}' \
              "https://api.craftmypdf.com/v1/create"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="
                data = {
                  'invoice_number': 'INV38379',
                  'date': '2021-09-30',
                  'currency': 'USD',
                  'total_amount': 82542.56
                }

                json_payload = {
                  "data": json.dumps(data) ,
                  "output_file": "output.pdf",
                  "export_type": "json",
                  "expiration": 10,
                  "template_id": "05f77b2b18ad809a"
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/create",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /create-async:
    post:
      summary: Create a PDF asynchronously
      operationId: create-async
      description: |
        This endpoint creates a PDF file asynchronously with JSON data and your template.
        The API returns immediately and once the PDF document is generated, it will make a HTTP/HTTPS GET to your URL(will retry for 3 times before giving up)



      tags:
        - PDF Generation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: string
                  description: JSON data, it supports stringified JSON string or an JSON object
                  example:
                    {
                      "invoice_number": "INV38379",
                      "date": "2021-09-30",
                      "currency": "USD",
                      "total_amount": 82542.56
                    }
                template_id:
                  type: string
                  description: Template ID
                  example: '05f77b2b18ad809a'
                version:
                  type: string
                  description: To generate a PDF using a specific version of the template. We use the latest template version unless you specify otherwise.
                  example: 8
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                webhook_url:
                  type: string
                  description: |
                    Callback URL to your server. It starts with http:// or https:// and has to be urlencoded
                    example: https://myserver.com/pdfhandler

                    Once the PDF is generated, our services will make a HTTP/HTTPS GET call to the following URL

                    https://[myserver.com/pdfhandler]?file=[file]&transaction_ref=[transaction_ref]&status=[status]&message=[message]&details=[details]
                    - [myserver.com/pdfhandler] is your web services to handle the callback
                    - [file] is the URL to the file
                    - [transaction_ref] is the transaction reference number
                    - [status] is the status of the request
                    - [message] is the message of the status
                    - [details] is the details


                    The following is a sample Webhook URL
                    - https://myserver.com/pdfhandler?&file=https%3A%2F%2Fpub-cdn.craftmypdf.com%2F2021%2F06%2Fb692183d-46d7-3213-891a-460a5814ad3f.pdf&transaction_ref=b692183d-46d7-3213-891a-460a5814ad3f
                  example: https://myserver.com/pdfhandler
                image_resample_res:
                  type: integer
                  description: Optimize/downsample images of current PDF to a resolution(in DPI). This helps to reduce the PDF file size. Suggested values are 1200, 600, 300, 150 or 72.
                  example: 600
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1

                postaction_s3_filekey:
                  type: string
                  description: |
                    - This is to specify the file name for `Post Action(S3 Storage)`.
                    - Please do not specify the file extension
                    - Please make sure the file name is unique
                    - You might use slash (/) as the folder delimiter

                postaction_s3_bucket:
                  type: string
                  description: |
                    - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.

                resize_images:
                  type: boolean
                  description: |
                    - Resize all the images in the PDF to help reduce its size, especially if the template contains multiple or large images. 
                    - Either `1`=`true` or `0`=`false`. Default to '0'
                    - If `resize_images` is set to `1`, specify the `resize_max_width`, `resize_max_height` in pixels.
                    - Images to be resized need to satisfy the following conditions:
                      - The images with the content-type `image/jpeg`, `image/jpg` or `image/png`
                      - The image URLs with the extension `.jpg`, `.jpeg` or `.png`
                  example: '0'

                resize_max_width:
                  type: integer
                  description: |
                    - If `resize_images` is set to `1`, specify the maximum width in pixels for the images. Default to '1000'
                  example: '1000'                

                resize_max_height:
                  type: integer
                  description: |
                    - If `resize_images` is set to `1`, specify the maximum height in pixels for the images . Default to '1000'
                  example: '1000'

                resize_format:
                  type: string
                  description: |
                    - (Optional) If `resize_images` is set to `1`, specify the format of the image. Either `jpeg` or `png`
                  example: 'jpeg'            

              required:
                - data
                - template_id
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseAsyncCreate'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "expiration": 10, "webhook_url":"https://myserver.com/pdfhandler", "data":  "{ \"invoice_number\": \"INV38379\", \"date\": \"2021-09-30\",  \"currency\": \"USD\", \"total_amount\": 82542.56   }", "output_file": "output.pdf"}' \
              "https://api.craftmypdf.com/v1/create-async"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="
                data = {
                  'invoice_number': 'INV38379',
                  'date': '2021-09-30',
                  'currency': 'USD',
                  'total_amount': 82542.56
                }

                json_payload = {
                  "data": json.dumps(data) ,
                  "webhook_url":"https://myserver.com/pdfhandler",
                  "expiration": 10,
                  "template_id": "05f77b2b18ad809a"
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/create-async",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /create-merge:
    post:
      summary: Create PDF from templates
      operationId: create-merge
      description: 'This endpoint creates a PDF file from multiple templates and it only returns one PDF.(* this does not support version parameter)'
      tags:
        - PDF Generation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                templates:
                  type: object
                  description: Array of template ids and JSON data
                  example: 
                    - template_id: "96177b2b1ac483b0"
                      data:
                        invoice_number: "INV0001"
                        date: "2021-09-30"
                        currency: "USD"
                        total_amount: 82542.56
                    - template_id: "f9e77b2b1acbe28c"
                      data:
                        invoice_number: "INV0002"
                        date: "2021-09-30"
                        currency: "USD"
                        total_amount: 82542.56
                    - template_id: "8c277b2b1ac3579a"
                      data:
                        invoice_number: "INV0003"
                        date: "2021-09-30"
                        currency: "USD"
                        total_amount: 82542.56

                #template_ids:
                #  type: string
                #  description: |
                #    (Optional) List of template ids. 
                #    - You can either use 'templates' field or this to provide the template ids.
                #    - The template_ids is separated by comma. Example: '96177b2b1ac483b0,f9e77b2b1acbe28c,8c277b2b1ac3579a'
                #    - Please use 'data' field to provide the JSON data for the templates.

                data:
                  type: string
                  description: |
                    (Optional) JSON data . If the `data` field is missing in the templates array, the JSON data provided here will be used. This supports either a stringified JSON string or a JSON object.
                  example:
                    {
                      "invoice_number": "INV38379",
                      "date": "2021-09-30",
                      "currency": "USD",
                      "total_amount": 82542.56
                    }                       
                export_type:
                  type: string
                  description: Either `file` or `json`. The option `json` returns a JSON object, and the output PDF is stored on a CDN(until expiration). The option `file` returns binary data of the generated PDF(More secure and completely private) and the response HTTP header Content-Disposition is set to attachment.
                  example: 'json'
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.pdf'
                  example: 'output.pdf'
                paging:
                  type: string
                  description: |
                    It detemines the paging for the next PDF, either is 'continuous' or 'reset' . Default to 'reset'
                    - continuous : The expression {{sys.totalPages}} is the sum of the merged PDF and the {{sys.pageNumber}} continue from the last PDF page number.
                    - reset: The expression {{sys.totalPages}} is the total pages of current PDF and the {{sys.pageNumber}} auto-reset to zero in the next PDF.
                  example: reset
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1
                postaction_s3_filekey:
                  type: string
                  description: |
                    - This is to specify the file name for `Post Action(S3 Storage)`.
                    - Please do not specify the file extension
                    - Please make sure the file name is unique
                    - You might use slash (/) as the folder delimiter

                postaction_s3_bucket:
                  type: string
                  description: |
                    - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.

                resize_images:
                  type: boolean
                  description: |
                    - Resize all the images in the PDF to help reduce its size, especially if the template contains multiple or large images. 
                    - Either `1`=`true` or `0`=`false`. Default to '0'
                    - If `resize_images` is set to `1`, specify the `resize_max_width`, `resize_max_height` in pixels.
                    - Images to be resized need to satisfy the following conditions:
                      - The images with the content-type `image/jpeg`, `image/jpg` or `image/png`
                      - The image URLs with the extension `.jpg`, `.jpeg` or `.png`
                  example: '0'

                resize_max_width:
                  type: integer
                  description: |
                    - If `resize_images` is set to `1`, specify the maximum width in pixels for the images. Default to '1000'
                  example: '1000'                

                resize_max_height:
                  type: integer
                  description: |
                    - If `resize_images` is set to `1`, specify the maximum height in pixels for the images . Default to '1000'
                  example: '1000'

                resize_format:
                  type: string
                  description: |
                    - (Optional) If `resize_images` is set to `1`, specify the format of the image. Either `jpeg` or `png`
                  example: 'jpeg'             

              required:
                - templates

      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessSingleFile'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            # Using templates
            curl -X POST \
              --header "Content-Type: application/json" \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{ "templates":[ { "template_id":"96177b2b1ac483b0", "data":"{ \"invoice_number\": \"INV0001\", \"date\": \"2021-09-30\", \"currency\": \"USD\", \"total_amount\": 82542.56 }" }, { "template_id":"f9e77b2b1acbe28c", "data":"{ \"invoice_number\": \"INV0002\", \"date\": \"2021-09-30\", \"currency\": \"USD\", \"total_amount\": 82542.56 }" }, { "template_id":"8c277b2b1ac3579a", "data":"{ \"invoice_number\": \"INV0003\", \"date\": \"2021-09-30\", \"currency\": \"USD\", \"total_amount\": 82542.56 }" } ], "export_type":"json", "expiration":60, "output_file":"output.pdf", "paging": "continuous" }' \
              "https://api.craftmypdf.com/v1/create-merge"

            # Using template_ids
            curl -X POST \
              --header "Content-Type: application/json" \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{ "template_ids":"96177b2b1ac483b0,f9e77b2b1acbe28c,8c277b2b1ac3579a", "data":"{ \"invoice_number\": \"INV0001\", \"date\": \"2021-09-30\", \"currency\": \"USD\", \"total_amount\": 82542.56 }", "export_type":"json", "expiration":60, "output_file":"output.pdf", "paging": "continuous" }' \
              "https://api.craftmypdf.com/v1/create-merge"



  /create-parallel:
    post:
      summary: Create PDFs parallelly
      operationId: create-parallel
      description: 'This endpoint creates PDF files with JSON data and your templates'
      tags:
        - PDF Generation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                requests:
                  type: object
                  description: Array of requests, please look at /v1/create for the detailed parameters
                  example: [ { "data": { "title": "Welcome to CraftMyPDF1!", "report_date": "2021-12-13 12:30" }, "template_id": "be277b2b12cebfa0", "meta": "yourrefernce0001" }, { "data": { "title": "Welcome to CraftMyPDF2!", "report_date": "2021-12-13 12:30" }, "template_id": "4a377b2b12ccbc54", "meta": "yourrefernce0002" } ]

              required:
                - requests

      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseCreateParallel'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"



  /create-image:
    post:
      summary: Create an image
      operationId: create-image
      description: 'This endpoint creates an image file with JSON data and your template'
      tags:
        - Image Generation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: string
                  description: JSON data, it supports stringified JSON string or an JSON object
                  example:
                    {
                      "invoice_number": "INV38379",
                      "date": "2021-09-30",
                      "currency": "USD",
                      "total_amount": 82542.56
                    }
                load_data_from:
                  type: string
                  description: Load data from an external URL. If this is specified, it will overwrite the `data`` property.
                  example:

                template_id:
                  type: string
                  description: Template ID
                  example: '05f77b2b18ad809a'
                version:
                  type: string
                  description: To generate an image using a specific version of the template. We use the latest template version unless you specify otherwise.
                  example: 8
                export_type:
                  type: string
                  description: |
                    Either `file` or `json`.
                    - The option `json` returns a JSON object, and the output PDF is stored on a CDN(until expiration).
                    - The option `file` returns binary data of the generated PDF(More secure and completely private) and the response HTTP header Content-Disposition is set to attachment.
                  example: 'json'
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.jpg'
                  example: 'output.jpg'
                output_type:
                  type: string
                  description: image output file type, default to 'jpeg'. Options are 'jpeg' or 'png'
                  example: jpeg
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN(Except export_type=file), default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1
                postaction_s3_filekey:
                  type: string
                  description: |
                    - This is to specify the file name for `Post Action(S3 Storage)`.
                    - Please do not specify the file extension
                    - Please make sure the file name is unique
                    - You might use slash (/) as the folder delimiter

                postaction_s3_bucket:
                  type: string
                  description: |
                    - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.

              required:
                - data
                - template_id
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessSingleFileJPEG'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "export_type":"json", "expiration": 10, "output_file":"my_new.pdf", "output_type":"jpeg", "data":  "{ \"invoice_number\": \"INV38379\", \"date\": \"2021-09-30\",  \"currency\": \"USD\", \"total_amount\": 82542.56   }"}' \
              "https://api.craftmypdf.com/v1/create-image"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="
                data = {
                  'invoice_number': 'INV38379',
                  'date': '2021-09-30',
                  'currency': 'USD',
                  'total_amount': 82542.56
                }

                json_payload = {
                  "data": json.dumps(data) ,
                  "output_file": "output.jpg",
                  "export_type": "json",
                  "expiration": 10,
                  "template_id": "05f77b2b18ad809a"
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/create-image",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()







  /list-templates:
    get:
      summary: List templates
      operationId: list-templates
      description: This endpoint lists all your PDF templates
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
          required: false
          description: Retrieve only the number of records specified. Default to 300
          example: 300
        - in: query
          name: offset
          schema:
            type: integer
          required: false
          description: Offset is used to skip the number of records from the results. Default to 0
          example: 0
        - in: query
          name: group_name
          schema:
            type: integer
          required: false
          description: Filter templates in the same group(group_name)
          example: 'Customer_009'

      responses:
        '200':
          description: Returns status and templates
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseListTemplate'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl --header "Content-Type: application/json"  \
                  --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
                  "https://api.craftmypdf.com/v1/list-templates?limit=300&offset=0"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/list-templates?limit=300&offset=0",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()



  /list-template-versions:
    get:
      summary: List template versions
      operationId: list-template-versions
      description: This endpoint lists all versions of a template
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: template_id
          schema:
            type: string
          required: false
          description: Template ID
          example: '5ef77b2b187c968c'

      responses:
        '200':
          description: Returns status and versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseListVersions'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl --header "Content-Type: application/json"  \
                  --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
                  "https://api.craftmypdf.com/v1/list-template-versions?template_id=5ef77b2b187c968c"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/list-template-versions?template_id=5ef77b2b187c968c",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()

  /retain-template-versions:
    post:
      summary: Retain template versions
      operationId: retain-template-versions
      description: This endpoint allows you to mark specific template versions as retained or not retained. Retained versions are protected from automatic cleanup.
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_id:
                  type: string
                  description: Template ID
                  example: 'c2d77b234151b7c4'
                versions:
                  type: array
                  items:
                    type: integer
                  description: Array of version numbers to retain or not retain
                  example: [1, 4]
                keep:
                  type: boolean
                  description: Whether to keep (true) or not keep (false) the specified versions
                  example: true
              required:
                - template_id
                - versions
                - keep
      responses:
        '200':
          description: Returns status and updated versions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseRetainTemplateVersions'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json" \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{
                "template_id": "c2d77b234151b7c4",
                "versions": [1, 4],
                "keep": true
              }' \
              "https://api.craftmypdf.com/v1/retain-template-versions"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "template_id": "c2d77b234151b7c4",
                  "versions": [1, 4],
                  "keep": True
                }

                response = requests.post(
                    "https://api.craftmypdf.com/v1/retain-template-versions",
                    headers = {"X-API-KEY": api_key},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()




  /new-template-from:
    post:
      summary: Create a new template
      operationId: new-template-from
      description: This endpoint creates a new template from a template ID
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_id:
                  type: string
                  description: |
                    Template ID

                    Note: When using a team API Key to clone a template from another team, make sure that:
                      - The creator of the template and the owner of the team API Key are the same person.
                      - The owner of the team where the template belongs and the owner of the team API Key are the same.
                  example: '5ef88b2b237c968c'
                name:
                  type: string
                  description: Name of the new template
                  example: 'My Invoice'
                version:
                  type: string
                  description: Version of the template. Leave it empty to use the latest version.
                  example: 8
                group_name:
                  type: string
                  description: Group name of the tempate, default to `null`. It's used for grouping templates of the same category(or customer) and it can be used with `list-templates` API to retrieve templates in the same group.
                  example: 'Customer_009'
              required:
                - template_id
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessCreateNewTemplate'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "name": "My Invoice"}' \
              "https://api.craftmypdf.com/v1/new-template-from"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "name": "New invoice" ,
                  "template_id": "5ef77b2b187c968c"
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/new-template-from",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()

  /transfer-template-to:
    post:
      summary: Transfer a template
      operationId: transfer-template-to
      description: This endpoint transfers a template to another team
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_id:
                  type: string
                  description: |
                    Template ID
                  example: '5ef88b2b237c968c'
                team_id:
                  type: string
                  description: The team id
                  example: 'haag3ce4'

              required:
                - template_id
                - team_id
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessTransferTemplateTo'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "team_id": "haag3ce4"}' \
              "https://api.craftmypdf.com/v1/transfer-template-to"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "team_id": "haag3ce4" ,
                  "template_id": "5ef77b2b187c968c"
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/transfer-template-to",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /update-template:
    post:
      summary: Update template
      operationId: update-template
      description: 'This endpoint updates the specified PDF template'
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_id:
                  type: string
                  description: Template ID
                  example: '05f77b2b18ad809a'
                name:
                  type: string
                  description: Optional, name of the template
                  example: 'My Template'
                json:
                  type: string
                  description: Optional, sample JSON data for the template
                  example: '{"first_name": "Jack","last_name": "Smith"}'
                body:
                  type: string
                  description: |
                    Optional, the template body.
                    *Warning:* do not update the body, unless you are certain what you are doing.
                  example: '{...}'
              required:
                - template_id
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseUpdateTemplate'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "name":"My Template", "json": "{\"first_name\": \"Jack\",\"last_name\": \"Smith\"}"}' \
              "https://api.craftmypdf.com/v1/update-template"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="
                sample_json = {"first_name": "Jack","last_name": "Smith"}
                response = requests.post(
                    F"https://api.craftmypdf.com/v1/update-template",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = {
                      "name": "My Template",
                      "json": json.dumps(sample_json)
                    }
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /get-template:
    get:
      summary: Get template
      operationId: get-template
      description: This endpoint returns the content of the template
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: template_id
          schema:
            type: string
          required: false
          description: Template id
          example: ad577b2b22d4e612

        - in: query
          name: version
          schema:
            type: string
          required: false
          description: Version of the template. Leave it empty to use the latest version.
          example: 0

      responses:
        '200':
          description: Returns status and template
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseGetTemplate'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl --header "Content-Type: application/json"  \
                  --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
                  "https://api.craftmypdf.com/v1/get-template?template_id=ad577b2b22d4e612"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/get-template?template_id=ad577b2b22d4e612",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()



  /delete-template:
    get:
      summary: Delete template
      operationId: delete-template
      description: This endpoint deletes a template
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: template_id
          schema:
            type: string
          required: true
          description: Template ID
          example: '5ef88b2b237c968c'

      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessDeleteTemplate'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              "https://api.craftmypdf.com/v1/delete-template?template_id=06977b2b18ace42a"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/delete-template?template_id=06977b2b18ace42a",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()

  /query-template-usage:
    get:
      summary: Query template usage
      description: Retrieve usage statistics for specified template IDs within a given date range.
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      parameters:
        - name: template_ids
          in: query
          required: true
          description: Comma-separated list of template IDs.
          schema:
            type: string
          example: "bba77b234e84443e,02077b2b1aa8b938"
        - name: start_date
          in: query
          description: Start date in ISO 8601 format (UTC time).
          schema:
            type: string
            format: date-time
          example: "2025-01-30T00:00:00Z"
        - name: end_date
          in: query
          description: End date in ISO 8601 format (UTC time).
          schema:
            type: string
            format: date-time
          example: "2025-01-30T11:59:59Z"

      responses:
        '200':
          description: Successful response with template usage data.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  template_ids:
                    type: array
                    items:
                      type: string
                  start_date:
                    type: string
                    format: date-time
                  end_date:
                    type: string
                    format: date-time
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        template_id:
                          type: string
                        total_credit:
                          type: string
                        total_count:
                          type: string
              example:
                status: success
                template_ids: ["bba77b234e84443e", "02077b2b1aa8b938"]
                start_date: "2025-01-30T00:00:00Z"
                end_date: "2025-01-30T11:59:59Z"
                results:
                  - template_id: "02077b2b1aa8b938"
                    total_credit: "8.0000"
                    total_count: "8"
                  - template_id: "bba77b234e84443e"
                    total_credit: "2.0000"
                    total_count: "2"

      x-code-samples:
        - lang: cURL
          source: |
            curl --location --request GET 'https://api.craftmypdf.com/v1/query-template-usage?template_ids=bba77b234e84443e%2C02077b2b1aa8b938&start_date=2025-01-30T00%3A00%3A00Z&end_date=2025-01-30T11%3A59%3A59Z' \
            --header 'X-API-KEY: YOUR_API_KEY' \
            --header 'Content-Type: application/json' \
        - lang: Python
          source: |
            import requests
            import json
            
            url = "https://api.craftmypdf.com/v1/query-template-usage"
            headers = {
                "X-API-KEY": "YOUR_API_KEY",
                "Content-Type": "application/json"
            }
            params = {
                "template_ids": "bba77b234e84443e,02077b2b1aa8b938",
                "start_date": "2025-01-30T00:00:00Z",
                "end_date": "2025-01-30T11:59:59Z"
            }
            
            response = requests.get(url, headers=headers, params=params)
            print(response.json())


  /create-editor-session:
    post:
      summary: Create editor session
      operationId: create-editor-session
      description: This endpoint creates a new PDF editor session. The PDF editor url can be embedded into an IFrame.
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                template_id:
                  type: string
                  description: Template ID
                  example: '5ef88b2b237c968c'
                expiration:
                  type: integer
                  description: Expiration of the editor session in minutes. e.g. 1440=24 hours
                  example: 1440
                canSave:
                  type: boolean
                  description: Can save the template. Default to `true`
                  example: true
                canCreatePDF:
                  type: boolean
                  description: Can Generate PDF. Default to `true`
                  example: true
                canViewSettings:
                  type: boolean
                  description: Can view settings. Default to `true`
                  example: true
                canPreview:
                  type: boolean
                  description: Can preview. Default to `true`
                  example: true
                canEditJSON:
                  type: boolean
                  description: Can edit JSON. Default to `true`
                  example: true
                canShowHeader:
                  type: boolean
                  description: Show CraftMyPDF header. Default to `true`
                  example: true
                canShowLayers:
                  type: boolean
                  description: Show layer dialogue. Default to `true`
                  example: true
                canShowPropertyPanel:
                  type: boolean
                  description: Show property panel. Default to `true`
                  example: true
                canShowHelp:
                  type: boolean
                  description: Show `Help`` tab. Default to `true`
                  example: true
                canShowData:
                  type: boolean
                  description: Show `Data`  tab . Default to `true`
                  example: true
                canShowExpressionDoc:
                  type: boolean
                  description: Show `Expression Doc` tab. Default to `true`
                  example: true
                canShowPropertyBinding:
                  type: boolean
                  description: Show `Property Bind` tab for element. Default to `true`
                  example: true
                canShowBackURL:
                  type: boolean
                  description: Show `Back` button. Default to `true`
                  example: true

                jsonMode:
                  type: integer
                  description: JSON editor - `1`, JSON viewer - `2`. Default to `1`
                  example: 1
                backURL:
                  type: string
                  description: The URL for the back button
                  example: https://yoururl.com


              required:
                - template_id
                - expiration
      responses:
        '200':
          description: Returns status and editor url
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessCreateNewEditorSession'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"template_id": "05f77b2b18ad809a", "expiration": 1440, "canSave": true,"canCreatePDF": true,"canViewSettings": true,"canPreview": true,"canEditJSON": true, "canShowHeader": true, "backURL": "https://yoururl.com"}' \
              "https://api.craftmypdf.com/v1/create-editor-session"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "expiration": 1440 ,
                  "template_id": "5ef77b2b187c968c",
                  "canSave": true,
                  "canCreatePDF": true,
                  "canViewSettings": true,
                  "canPreview": true,
                  "canEditJSON": true,
                  "canShowHeader": true,
                  "backURL": "https://yoururl.com"
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/create-editor-session",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()



  /deactivate-editor-session:
    post:
      summary: Deactivate editor session
      operationId: deactivate-editor-session
      description: This endpoint deactivates a new PDF editor session. 
      tags:
        - Template Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                token_uuid:
                  type: string
                  description: Token UUID
                  example: 'a1263472b-e5e3-4568-8654-ec49f48392'
                
              required:
                - token_uuid

      responses:
        '200':
          description: Returns status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessDeactivateEditorSession'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{"token_uuid": "a1263472b-e5e3-4568-8654-ec49f48392"}' \
              "https://api.craftmypdf.com/v1/deactivate-editor-session"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "token_uuid": "a1263472b-e5e3-4568-8654-ec49f48392" ,
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/deactivate-editor-session",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()



  /list-transactions:
    get:
      summary: List transactions
      operationId: list-transactions
      description: This endpoint lists all the transactions
      tags:
        - Account Management API
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
          required: false
          description: Retrieve only the number of records specified. Default to 300
          example: 300
        - in: query
          name: offset
          schema:
            type: integer
          required: false
          description: Offset is used to skip the number of records from the results. Default to 0
          example: 0


      responses:
        '200':
          description: Returns status and transactions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseListTransactions'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl --header "Content-Type: application/json"  \
                --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
                "https://api.craftmypdf.com/v1/list-transactions?limit=300&offset=0"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/list-transactions?limit=300&offset=0",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /get-account-info:
    get:
      summary: Get account information
      operationId: get-account-info
      description: This endpoint returns the account information
      tags:
        - Account Management API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object


      responses:
        '200':
          description: Returns status and account information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseAccountInformation'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              "https://api.craftmypdf.com/v1/get-account-info"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/get-account-info",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /merge-pdfs:
    post:
      summary: Merge PDF URLs
      operationId: merge-pdfs
      description: 'This endpoint merges multiple PDF URLs'
      tags:
        - PDF Manipulation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                urls:
                  type: array
                  description: URL array
                  example: ['https://fileserver.com/a1.pdf', 'https://fileserver.com/b2.pdf']
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.pdf'
                  example: 'output.pdf'
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1
                postaction_s3_filekey:
                  type: string
                  description: |
                    - This is to specify the file name for `Post Action(S3 Storage)`.
                    - Please do not specify the file extension
                    - Please make sure the file name is unique
                    - You might use slash (/) as the folder delimiter

                postaction_s3_bucket:
                  type: string
                  description: |
                    - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.
              required:
                - urls
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessSingleFile'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{ "urls": ["https://fileserver.com/a1.pdf","https://fileserver.com/b2.pdf"] }' \
              "https://api.craftmypdf.com/v1/merge-pdfs"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "urls": ["https://fileserver.com/a1.pdf","https://fileserver.com/b2.pdf"] ,
                  "output_file": "output.pdf",
                }

                response = requests.post(
                    F"https://api.craftmypdf.com/v1/merge-pdfs",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()


  /add-text-to-pdf:
    post:
      summary: Add text to a PDF
      operationId: add-text-to-pdf
      description: This endpoint add text to a PDF, you can add page numbers, watermark, and text to a PDF
      tags:
        - PDF Manipulation API
      security:
        - ApiKeyAuth: []      
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  format: uri
                  description: The URL of the PDF file to be annotated.
                textSettings:
                  type: array
                  items:
                    type: object
                    properties:
                      page_selector:
                        type: string
                        description: |
                          The page or range of pages to apply the annotation (e.g., "1", "2", "10-*").
                          You can use comma to specify multiple pages or ranges of pages.
                          For example, a PDF with 9 pages:
                          | page_selector | Page                  |
                          |--------------|----------------------|
                          | 1,4,6        | Page 1, 4, 6         |
                          | 1,3,5-8      | Page 1, 3, 5, 6, 7, 8 |
                          | 1,3-*        | Page 1, 3, 4, 5, 6, 7, 8, 9 |
                        example: '1,2-*,5-8'
                      text:
                        type: string
                        description: |
                          The text to be annotated on the page. The following are the supported dynamic variables:
                          | Placeholder         | Description                                      |
                          |---------------------|--------------------------------------------------|
                          | `{{pageNumber}}`   | Gets the current page number.                    |
                          | `{{totalPages}}`   | Gets the total number of pages.                   |
                          | `{{currentIndex}}` | Gets the current index of the item.               |

                        example: 'Page {{pageNumber}} of {{totalPages}}'
                      position:
                        type: string
                        enum: [top-left, top-center, top-right, middle-left, center, middle-right, bottom-left, bottom-center, bottom-right]
                        description: The position on the page where the text will be placed.
                        example: 'top-left'
                      offset_x:
                        type: number
                        description: The horizontal offset from the position.
                        example: 10
                      offset_y:
                        type: number
                        description: The vertical offset from the position.
                        example: 10
                      font_size:
                        type: number
                        description: The font size of the annotated text.
                        example: 12
                      hex_color:
                        type: string
                        format: hex-color
                        description: The color of the text in hexadecimal format (e.g., "#FF0000").
                        example: '#FF0000'
                      font_family:
                        type: string
                        description: |
                          The font family of the annotated text (e.g., "Helvetica"). Available fonts are: Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique, Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Symbol, ZapfDingbats.
                        example: 'Helvetica'
                      opacity:
                        type: number
                        format: float
                        minimum: 0.0
                        maximum: 1.0
                        description: The opacity of the text (1.0 is fully opaque, 0.0 is fully transparent).
                        example: 0.5
                      rotation:
                        type: number
                        description: The rotation angle of the text in degrees.
                        example: 45
                    required:
                      - page_selector
                      - text
                      - position
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.pdf'
                  example: 'output.pdf'
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1                     
              required:
                - url
                - textSettings
      responses:
        '200':
          description: Successfully PDF
          content:
            application/json:
              schema:
                type: object
                properties:
                  file:
                    type: string
                    format: uri
                    description: The URL of the annotated PDF file.
                    example: "https://craftmypdf.s3.ap-southeast-1.amazonaws.com/test/output2025-01-24T170834.623_annotated.pdf"
                  transaction_ref:
                    type: string
                    format: uuid
                    description: A unique reference ID for the transaction.
                    example: "123e4567-e89b-12d3-a456-426614174000"
                  status:
                    type: string
                    enum: [success, error]
                    description: The status of the operation.
                    example: "success"
                required:
                  - file
                  - transaction_ref
                  - status

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"


      x-code-samples:
        - lang: curl
          source: |
            curl -X POST "https://api.example.com/add-text-to-pdf" \
                -H "Authorization: Bearer YOUR_API_KEY" \
                -H "Content-Type: application/json" \
                -d '{
                      "url": "https://example.com/sample.pdf",
                      "textSettings": [
                        {
                          "page_selector": "1-*",
                          "text": "Page {{pageNumber}} of {{totalPages}}",
                          "position": "bottom-center",
                          "offset_x": 0,
                          "offset_y": 10,
                          "font_size": 12,
                          "hex_color": "#000000",
                          "font_family": "Helvetica",
                          "opacity": 1.0,
                          "rotation": 0
                        },
                        {
                          "page_selector": "2-*",
                          "text": "Confidential",
                          "position": "center",
                          "offset_x": 0,
                          "offset_y": 0,
                          "font_size": 24,
                          "hex_color": "#FF0000",
                          "font_family": "Arial",
                          "opacity": 0.5,
                          "rotation": 45
                        }
                      ]
                    }'
        - lang: Python
          source: |
            import requests

            url = "https://api.example.com/add-text-to-pdf"
            headers = {
                "Authorization": "Bearer YOUR_API_KEY",
                "Content-Type": "application/json"
            }
            data = {
                "url": "https://example.com/sample.pdf",
                "textSettings": [
                    {
                        "page_selector": "1-*",
                        "text": "Page {{pageNumber}} of {{totalPages}}",
                        "position": "bottom-center",
                        "offset_x": 0,
                        "offset_y": 10,
                        "font_size": 12,
                        "hex_color": "#000000",
                        "font_family": "Helvetica",
                        "opacity": 1.0,
                        "rotation": 0
                    },
                    {
                        "page_selector": "2-*",
                        "text": "Confidential",
                        "position": "center",
                        "offset_x": 0,
                        "offset_y": 0,
                        "font_size": 24,
                        "hex_color": "#FF0000",
                        "font_family": "Arial",
                        "opacity": 0.5,
                        "rotation": 45
                    }
                ]
            }

            response = requests.post(url, headers=headers, json=data)
            print(response.json())



  /update-pdf-fields:
    post:
      summary: Update fillable fields
      description: Updates the fillable fields(such as text fields, checkboxes, dropdowns, etc) in a PDF document with the provided values. Use https://craftmypdf.com/tools/pdf-fillable-field-reader/ to identify the fillable field ids.
      operationId: update-pdf-fields
      tags:
        - PDF Manipulation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  description: The URL of the PDF file to update.
                  example: "https://craftmypdf.s3.ap-southeast-1.amazonaws.com/test/output+-+2025-01-24T170834.623.pdf"
                fields:
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                        description: The ID of the field to update. Use https://craftmypdf.com/tools/pdf-fillable-field-reader/ to find out the field ids.
                        example: "last_name"
                      value:
                        type: string
                        description: The value to set for the field.
                        example: "Smith"
                      readOnly:
                        type: boolean
                        description: Whether the field should be read-only after updating.
                        example: false
                      fontSize:
                        type: integer
                        description: The font size of the textfield.
                        example: 15                        
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.pdf'
                  example: 'output.pdf'
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1
              required:
                - url
                - fields
      responses:
        '200':
          description: PDF fields updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: "PDF fields updated successfully"
                  file:
                    type: string
                    example: "https://craftmypdf.s3.ap-southeast-1.amazonaws.com/test/output2025-01-24T170834.623_updated.pdf"
                  status:
                    type: string
                    enum: [success, error]
                    example: success
                  field_statuses:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: The ID of the field.
                          example: "last_name"
                        status:
                          type: string
                          enum: [success, error]
                          example: "success"
                        message:
                          type: string
                    
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"


      x-code-samples:
        - lang: curl
          source: |
            curl --location 'https://api-staging.craftmypdf.com/v1/update-pdf-fields' \
            --header 'x-api-key: xxxxx' \
            --data-raw '{
                "url": "https://craftmypdf.s3.ap-southeast-1.amazonaws.com/test/output2025-01-24T170834.623.pdf",
                "fields": [
                  {
                    "id": "optionlist_1",
                    "value": "Gaming",
                    "readOnly": false
                  },
                  {
                    "id": "email",
                    "value": "willxxxx@craftmypdf.com",
                    "readOnly": true
                  },
                  {
                    "id": "checkbox_1",
                    "value": false,
                    "readOnly": false
                  },
                  {
                    "id": "last_name",
                    "value": "Smith",
                    "readOnly": false
                  },
                  {
                    "id": "first_name",
                    "value": "Will",
                    "readOnly": false
                  },
                  {
                    "id": "dropdown_1",
                    "value": "v1",
                    "readOnly": false
                  },
                  {
                    "id": "group_1",
                    "value": "50",
                    "readOnly": false
                  }
                ]
            }'
        - lang: python
          source: |
            import requests

            url = "https://api-staging.craftmypdf.com/v1/update-pdf-fields"
            headers = {
                "x-api-key": "xxxxx",
                "Content-Type": "application/json"
            }
            payload = {
                "url": "https://craftmypdf.s3.ap-southeast-1.amazonaws.com/test/output+-+2025-01-24T170834.623.pdf",
                "fields": [
                    {"id": "optionlist_1", "value": "Gaming", "readOnly": False},
                    {"id": "email", "value": "willxxxx@craftmypdf.com", "readOnly": True},
                    {"id": "checkbox_1", "value": False, "readOnly": False},
                    {"id": "last_name", "value": "Smith", "readOnly": False},
                    {"id": "first_name", "value": "Will", "readOnly": False},
                    {"id": "dropdown_1", "value": "v1", "readOnly": False},
                    {"id": "group_1", "value": "50", "readOnly": False}
                ]
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())




  /get-pdf-info:
    get:
      summary: Get PDF Information
      operationId: get-pdf-info
      description: This endpoint is to get the information of a PDF file
      tags:
        - PDF Manipulation API
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: url
          schema:
            type: string
          required: true
          description: URL to a PDF file
          example: 'https://example.com/sample.pdf'

      responses:
        '200':
          description: Returns the information of the PDF file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessPDFInfo'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              F"https://api.craftmypdf.com/v1/get-pdf-info?url=https://example.com/sample.pdf",

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                response = requests.get(
                    F"https://api.craftmypdf.com/v1/get-pdf-info?url=https://example.com/sample.pdf",
                    headers = {"X-API-KEY": F"{api_key}"}
                )

                print(response.content)

            if __name__ == "__main__":
                main()





  /add-watermark:
    post:
      summary: Add watermark to a PDF
      operationId: add-watermark
      description: 'This endpoint add watermark to a PDF (Please consider using the `add-text-to-pdf` endpoint instead)' 
      tags:
        - PDF Manipulation API
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  description: URL of the source PDF
                  example: 'https://fileserver.com/sample.pdf'
                text:
                  type: string
                  description: Watermark text
                  example: 'Confidential'
                font_size:
                  type: integer
                  description: Font size of the watermark, default to 40
                  example: 40
                opacity:
                  type: integer
                  description: Opacity of the watermark, default to 0.5
                  example: 0.5
                rotation:
                  type: integer
                  description: Rotation of the watermark, default to 45
                  example: 45
                hex_color:
                  type: string
                  description: Color of the watermark, it has to be a hex color and starts with '#', default to '#c7c7c7'
                  example: '#c7c7c7'
                font_family:
                  type: string
                  description: |
                    Font family of the watermark. Default to Helvetica. Available fonts are:
                    Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique, Times-Roman,
                    Times-Bold, Times-Italic, Times-BoldItalic, Symbol, ZapfDingbats,
                  example: 'Helvetica'
                expiration:
                  type: integer
                  description: Expiration of the generated PDF in minutes. default to 5 minutes, range between 1 minute and 10080 minutes(7 days)
                  example: 60
                output_file:
                  type: string
                  description: output file, default to 'output.pdf'
                  example: 'output.pdf'
                cloud_storage:
                  type: integer
                  description: Upload the generated PDFs/images to our storage CDN, default to `1`. If you have configured `Post Actions` to upload the PDFs/Images to your own S3, please set it to `0`.
                  example: 1
                postaction_s3_filekey:
                  type: string
                  description: |
                    - This is to specify the file name for `Post Action(S3 Storage)`.
                    - Please do not specify the file extension
                    - Please make sure the file name is unique
                    - You might use slash (/) as the folder delimiter

                postaction_s3_bucket:
                  type: string
                  description: |
                    - This is to overwrite the AWS Bucket for `Post Action(S3 Storage)`.

              required:
                - url
                - text
      responses:
        '200':
          description: Returns status and output file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccessSingleFile'

        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

      x-code-samples:
        - lang: cURL
          source: |
            curl -X POST \
              --header "Content-Type: application/json"  \
              --header 'X-API-KEY: 7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=' \
              --data '{ "text": "Confidential", "font_size": 60, "opacity": 0.5, "rotation": 45, "hex_color": "#c7c7c7", "font_family": "Helvetica", "expiration": 60, "output_file": "output.pdf" }' \
              "https://api.craftmypdf.com/v1/add-watermark"

        - lang: 'Python'
          source: |
            import requests, json

            def main():
                api_key = "7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ="

                json_payload = {
                  "text": "Confidential",
                  "font_size": 60,
                  "opacity": 0.5,
                  "rotation": 45,
                  "hex_color": "#c7c7c7",
                  "font_family": "Helvetica",
                  "expiration": 60,
                  "output_file": "output.pdf"
                }
                response = requests.post(
                    F"https://api.craftmypdf.com/v1/add-watermark",
                    headers = {"X-API-KEY": F"{api_key}"},
                    json = json_payload
                )

                print(response.content)

            if __name__ == "__main__":
                main()












components:
  securitySchemes:
    ApiKeyAuth:        # arbitrary name for the security scheme
      type: apiKey
      in: header       # can be "header", "query" or "cookie"
      name: X-API-KEY  # name of the header, query parameter or cookie
      description: |
        An API key is needed to be set in the Authorization header of every API call.
        For additional support you can contact us.

        **Note: You must replace the API KEY(7832MjA6MTE6UjlkM3h4emxpTExzeFR0aQ=) with your API key in the request samples.**
  schemas:
    Error:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          description: 'Value of the status: error'
          example: 'error'
        message:
          type: string
          description: 'Error message'
          example: 'This is an error message'

    ResponseSuccessSingleFile:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        file:
          type: string
          description: 'Generated PDF document'
          example: 'https://craftmypdf.com/output.pdf'
        transaction_ref:
          type: string
          description: Transaction reference
          example: a0430897-2c94-40e1-a09b-57403d811ceb
        anchors:
          type: array
          description: 'These are the anchor components and their corresponding page numbers. The results can be used to build a table of contents.'
          example:
            [
                {
                    "page": 1,
                    "text": "",
                    "level": "0",
                    "description": "Welcome to CraftMyPDF!"
                },
                {
                    "page": 2,
                    "text": "page 2",
                    "level": "0",
                    "description": ""
                }
            ]

    ResponseSuccessSingleFileJPEG:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        file:
          type: string
          description: 'Generated JPEG image'
          example: 'https://craftmypdf.com/output.jpg'
        transaction_ref:
          type: string
          description: Transaction reference
          example: a0430897-2c94-40e1-a09b-57403d811ceb

    ResponseAsyncCreate:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        transaction_ref:
          type: string
          description: Transaction reference
          example: a0430897-2c94-40e1-a09b-57403d811ceb
        is_async:
          type: boolean
          description: It always returns `true`
          example: true


    ResponseListTemplate:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        templates:
          type: array
          description: 'Array of templates'
          example:
            [
              {
                "template_id": "5ef77b2b187c968c",
                "name": "Invoice Template",
                "status": "ACTIVE",
                "created_at": "2021-07-31T16:00:00.000Z",
                "updated_at": "2021-08-27T13:07:45.968Z",
                "group_name": ""
              },
              {
                "template_id": "19d77b2b187554e0",
                "name": "PDF Template",
                "status": "ACTIVE",
                "created_at": "2020-06-31T16:00:00.000Z",
                "updated_at": "2021-08-27T13:07:45.968Z",
                "group_name": ""
              },
            ]

    ResponseListVersions:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        template_id:
          type: string
          description: 'Template ID'
          example: '5ef77b2b187c968c'
        versions:
          type: array
          description: 'Array of versions'
          example:
            [
                {
                    "version": 0,
                    "description": "Latest",
                    "updated_at": ""
                },
                {
                    "version": 42,
                    "keep": false,
                    "description": "",
                    "updated_at": "2022-12-22T13:04:48.355Z"
                },
                {
                    "version": 41,
                    "keep": false,
                    "description": "",
                    "updated_at": "2022-12-22T05:56:33.779Z"
                }
              ]

    ResponseRetainTemplateVersions:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        template_id:
          type: string
          description: 'Template ID'
          example: 'c2d77b234151b7c4'
        versions:
          type: array
          description: 'Array of updated versions'
          example:
            [
                {
                    "version": 1,
                    "keep": true,
                    "description": "",
                    "updated_at": "2024-10-26T06:06:44.399Z"
                },
                {
                    "version": 4,
                    "keep": true,
                    "description": "",
                    "updated_at": "2024-10-26T19:31:50.500Z"
                }
            ]

    ResponseGetTemplate:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        name:
          type: string
          description: Name of the template
          example: 'Test Template'
        body:
          type: string
          description: Body of the template
          example: '{...}'
        json:
          type: string
          description: Sample JSON of the template
          example: '{...}'

    ResponseSuccessCreateNewTemplate:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        template_id:
          type: string
          description: 'New template ID'
          example: 05f77b2b18ad809a
        from_template_id:
          type: string
          description: 'Orignial template ID'
          example: 23f4218dc352
        from_template_version:
          type: string
          description: 'Orignial template version'
          example: 8

    ResponseSuccessTransferTemplateTo:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'


    ResponseSuccessDeleteTemplate:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'

    ResponseSuccessPDFInfo:
      type: object
      properties:
        status:
          type: string
          example: "success"
        totalPages:
          type: integer
          example: 19
        url:
          type: string
          example: "https://example.com/sample.pdf"
        title:
          type: string
          example: ""
        author:
          type: string
          example: "CraftMyPDF"
        subject:
          type: string
          example: ""
        creator:
          type: string
          example: "Microsoft Excel 365"
        keywords:
          type: string
          example: ""
        producer:
          type: string
          example: "pdf-lib"
        creationDate:
          type: string
          format: date-time
          example: "2024-03-30T16:13:55.000Z"
        modificationDate:
          type: string
          format: date-time
          example: "2024-04-09T09:00:56.000Z"

    ResponseListTransactions:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        transactions:
          type: array
          description: 'Array of transactions'
          example:
            [
              {
                "transaction_ref":"f1d3a8dc-c7ce-4ea4-b3f4-db9e71ea620b",
                "transaction_type":"PDFGEN",
                "exec_tm":2997,
                "credit":"1.0000",
                "created_at":"2021-08-28T03:10:36.855Z"
              },
              {
                "transaction_ref":"031d7d44-091b-4ffe-bbbe-728772a6493e",
                "transaction_type":"PDFGEN",
                "exec_tm":5182,
                "credit":"1.0000",
                "created_at":"2021-08-28T03:07:36.856Z"
              },
              {
                "transaction_ref":"33c442e2-07cf-4168-9f29-7df926336869",
                "transaction_type":"PDFPREVIEW",
                "exec_tm":5689,
                "credit":"0.5000",
                "created_at":"2021-08-27T14:00:13.426Z"
              },
              {
                "transaction_ref":"8183b4c6-da14-4317-aa93-553cbc1fa2a5",
                "transaction_type":"PDFPREVIEW",
                "exec_tm":5849,
                "credit":"0.5000",
                "created_at":"2021-08-27T13:18:34.051Z"
              },
              {
                "transaction_ref":"15cefe88-35c5-46a9-ab77-ac05dc6a29c3",
                "transaction_type":"PDFPREVIEW",
                "exec_tm":5601,
                "credit":"0.5000",
                "created_at":"2021-08-27T11:35:37.498Z"
              }
          ]


    ResponseAccountInformation:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        username:
          type: string
          description: 'username'
          example: 'hello@craftmypdf.com'
        quota_counter:
          type: float
          description: 'quota_counter'
          example: 35
        quota_max:
          type: float
          description: 'quota_max'
          example: 100
        template_counter:
          type: string
          description: 'template_counter'
          example: 1
        template_max:
          type: int
          description: 'template_max'
          example: 3
        created_at:
          type: string
          description: 'created_at'
          example: '2024-08-06T12:14:39.137Z'




    ResponseSuccessCreateNewEditorSession:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        url:
          type: string
          description: 'Status'
          example: 'https://craftmypdf.com/designer/?template_id=a2777b23223444&session_token=RlX2lkIjogIxzOEFROCJ9&sig=c6c7f8b90cd7901'
        expire_after_unix_timestamp:
          type: integer
          description: Expiration datetime in Unix timestamp
          example: 1674097492
        expire_after:
          type: integer
          description: Expiration in simplified extended ISO ISO 8601 format
          example: '2023-01-19T03:04:51.811Z'
        token_uuid:
          type: string
          description: Unique identifier for the session
          example: 66b0e71d-5a72-4fee-b4a5-7f1713fd2fb5


    ResponseSuccessDeactivateEditorSession:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'


    ResponseUpdateTemplate:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'

    ResponseCreateParallel:
      type: object
      properties:
        status:
          type: string
          description: 'Status'
          example: 'success'
        results:
          type: object
          description: Array of requests
          example: [ { "file": "https://craftmypdf-gen-de.s3.eu-central-1.amazonaws.com/dvbewe-2a8b-4182-b92c-33dfw3fcds/output.pdf", "transaction_ref": "dvbewe-2a8b-4182-b92c-33dfw3fcds", "status": "success", "total_pages": 1, "template_id": "be277b31334bfa0", "index": 0, "meta": "yourrefernce0001" }, { "file": "https://craftmypdf-gen-de.s3.eu-central-1.amazonaws.com/06ddf85d-980e-3dfb-8f6c-3e3vssvc/output.pdf", "transaction_ref": "06ddf85d-980e-3dfb-8f6c-3e3vssvc", "status": "success", "total_pages": 1, "template_id": "4a3724423bc54", "index": 1, "meta": "yourrefernce0002" } ]
