DiMaker DiMaker В чём разница?


Using the DiMaker API, you can create files with personal data and, if necessary, send them to recipients. API requests can be made both from another server and from the browser via CORS request.

Getting Started

In the "Integration" - "API Tokens" section, you need to obtain a Secure token for requests and allow the use of this token. In addition, you need to create a document containing variables for personal data, a letter template for mailings, and a folder in the Drive for the prepared files.

Creating Files

To create files, you need to send Data-POST or GET requests to the address
with the data listed below.
The encoding of the request is UTF-8. Required fields are marked with an asterisk.

  • secure*

    The token (string, 36 characters)

  • doc_id*

    The ID of the document (string, 36 characters) that will be used to create the file. The ID can be obtained in the address bar when the document is open. The document should not be in the trash, but can be in any folder in the Docs.

  • mask*

    JSON string containing all variables for substitution in the form of a key (variable) - value (text for substitution). It can contain data for creating several files (without restrictions on the number).
    Example for one file:
    [{"%name": "Ivanov", "%score":"100"}]
    Example for multiple files:
    [{"%name": "Ivanov", "%score":"100"}, {"%name": "Petrov", "%score":"200"}, {"%name": "Sidorov", "%score":"300"}]
    To specify the email address, use %email; for the file name, use %filename. To send created files to multiple email addresses, separate the email addresses with commas. In this case, the sending status in the Drive will be displayed for the first address.
    Only double quotes can be used in accordance with the standard. If the value of the key contains quotes, they must be escaped.

    To pass an image to a block with an image, you can use either a direct link (http:// or https://) or a Base64-encoded image. In the second case, the string should start with "data:image/".

    Alternative method
    If it is not possible to send a JSON string, strings for substitution can be sent as request fields. Each variable for substitution must start with the prefix mask_, for example mask_name, and contain the value for substitution. In this case, the variable will be searched for after the prefix in the document. For example, the mask_name field corresponds to the variable %name. To specify the email address, use mask_email; for the file name, use mask_filename.

  • mail_id

    The ID of the email template (string, 36 characters) for sending by email. The ID can be obtained in the address bar when the template is open. If the variable is not passed, the email will not be sent.

  • email_send

    The time to send the email with the file. It can take the following values:
    onfinish - Send all emails after creating all files (default)
    oncreate - Send emails immediately after creating the file. When creating a single file, onfinish and oncreate are identical.
    timeout - Send emails after a period of time. In this case, two more parameters must be passed:
    email_timeout_value - numeric value of the interval to send emails, integer value
    email_timeout_value - time unit of the interval. Can take the value "m" (minutes), "h" (hours), "d" (days).
    Alternatively, to specify the exact time of sending, pass the time in Unix time format in email_timeout_timestamp. If both timeout and email_timeout_timestamp are passed, the latter has priority.

  • folder_id

    The ID of the folder in the Drive (string, 36 characters) to save files. If the folder does not exist, it will be created automatically when the first file is created.

  • page_id

    The ordinal number of the sheet (number or string) if there are multiple sheets in the document. You can pass one number (the first sheet is 0) or numbers (comma-separated) of sheets that need to be used to create the file.

  • result

    Determines how to return the result. Can take the following values:

    • Value is absent. A JSON string with the request result will be returned (see below)
    • link. If the request is successful, a string containing a link to the created file will be returned (if multiple files were created, a link to the first one will be returned). To get the file itself, go to the specified link. It takes time to prepare the files - from 1 to 5 seconds per file. Until the file is created, the request to this address will return a 404 error. If the request does not result in the creation of the file, a JSON string with an error will be returned (see below).
    • Result

      The server will return a JSON-string that can have the following possible values:

      • result

        The result of the request. Can have the following values:
        error - request error. Files are not created.
        success - successful request to create files. Depending on the API usage scenario, you can report the successful creation of files or display a form for obtaining files.

      • create_id

        The ID of the generation. Only on successful completion of the request. May be useful for other requests to the API.

      • files

        An array containing the IDs of the created files. Only on successful completion of the request. To get the file itself in JPG format, you need to go to https://dimaker.app/getfile/{ID}/. To download a PDF file, you need to add pdf/ to the address. The API returns the file ID immediately, but it takes time to prepare the files themselves - from 1 to 5 seconds per file. Until the file is created, a request to https://dimaker.app/getfile/{ID}/ will return a 404 error.

      • url

        The URL string for displaying a file download widget. Only on successful completion of the request. You need to create an Iframe with the specified URL. Simply clicking on the URL will not give a result. The domain of the site where the file is being received must be correctly specified in the API settings.
        Creating each file takes 1 second + several seconds for processing the entire group. Immediately after sending the request, you can open Iframe with the specified URL. If the files are not yet ready, a corresponding message will be displayed. As soon as the files are ready, they will be offered for download.
        You can display the download widget in a dialog box on top of the page. To do this, you need to create an Iframe with the following additional styles: position:fixed; width:100%; height:100%; top:0; bottom:0; right:0; left:0; z-index:10000; background: rgb(0 0 0 / 72%); Add ?view=modal to the address bar, and place this Iframe in the body.

      • error_text

        Only on error. Text description of the error. Possible errors: incorrect Secure token, substitution mask, document ID, email template ID, Disk folder ID, or internal server error.

      Example of returned data on successful request:

      Creating multiple files in one request

      You can send a request to create multiple files from different documents in one go. With such a request, you can create multiple files, for example, using templates in Russian and English. By sending one request, the server will create the required number of files.

      To send such a request, the doc_id variable must be an array (variable name - doc_id[]). In this case, there may be several doc_id[] variables in one request - to create multiple files. Other variables, such as mail_id, email_send, folder_id can also be sent as arrays, so that each of the files is sent in a specific template, at a specific time or saved in a specific folder. If this is not necessary, only the doc_id field should be an array.

      For example, you need to create two files from different documents and put them in different folders on Drive. To do this, you need to send two doc_id[] variables and two folder_id[] variables (in the same order). Also, if you need to send them in one email, you need to specify one mail_id, and in email_send[] first specify "manual", and then "oncreate". In this case, the first file will be created, then the second. And only after the second is created, the email specified in mail_id will be sent.

      Sending a file to yourself after creation

      The file will be sent to the email of your account immediately after it is created. In the "Email Template" field you can choose which template to use for sending. Previously, in Email Templates, you can create a separate template for sending emails to your email. If you write the variable %data in the email text, all file data will be added as a table to that location.

      Other Integrations