MENU navbar-image

Introduction

PhpIndDesign api for creating on the fly indesign documents and packages

This documentation aims to provide all the information you need to work with our API.

Base URL

http://localhost:89

Authenticating requests

To authenticate requests, include an Authorization header with the value "Bearer {YOUR_AUTH_KEY}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

Authentication tokens can be requested using the proper channels, please visit Guideline Belgium for more information.

Documents

Documents api calls. To create, edit, delete, etc. documents in InDesign.

Create Document

requires authentication

Handle the incoming request to create a document. A "status" of "success" or "error" will be returned. Any relevant data requested will be found in the "data" set depending on your parameters, or null will be returned

Example request:
$client = new \GuzzleHttp\Client();
$response = $client->post(
    'http://localhost:89/api/create-document',
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_AUTH_KEY}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
            'Accept-Encoding' => 'gzip, deflate, br',
            'Connection' => 'keep-alive',
        ],
        'json' => [
            'templates' => [
                'cover' => 'http://app.phpindesign/templates/template_cover.idml',
                'content' => 'http://app.phpindesign/templates/template_content.idml',
            ],
            'company' => 'Guideline',
            'outputFileName' => 'MyDocument',
            'outputFileType' => 'pdf',
            'maxGenerateTime' => 5,
            'hide' => [
                'Image_1',
                'Text_2',
                'Title',
            ],
            'data' => [
                'book' => [
                    'documents' => [
                        [
                            'template' => 'cover',
                            'swatches' => '...',
                            'pages' => [
                                [
                                    'masterPage' => '8-Master',
                                    'data' => [
                                        [
                                            'html' => '...',
                                            'images' => '...',
                                            'texts' => '...',
                                        ],
                                    ],
                                ],
                            ],
                        ],
                        [
                            'template' => 'content',
                            'swatches' => '...',
                            'pages' => [
                                [
                                    'masterPage' => '8-Master',
                                    'data' => [
                                        [
                                            'html' => '...',
                                            'images' => '...',
                                            'texts' => '...',
                                        ],
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
curl --request POST \
    "http://localhost:89/api/create-document" \
    --header "Authorization: Bearer {YOUR_AUTH_KEY}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --header "Accept-Encoding: gzip, deflate, br" \
    --header "Connection: keep-alive" \
    --data "{
    \"templates\": {
        \"cover\": \"http:\\/\\/app.phpindesign\\/templates\\/template_cover.idml\",
        \"content\": \"http:\\/\\/app.phpindesign\\/templates\\/template_content.idml\"
    },
    \"company\": \"Guideline\",
    \"outputFileName\": \"MyDocument\",
    \"outputFileType\": \"pdf\",
    \"maxGenerateTime\": 5,
    \"hide\": [
        \"Image_1\",
        \"Text_2\",
        \"Title\"
    ],
    \"data\": {
        \"book\": {
            \"documents\": [
                {
                    \"template\": \"cover\",
                    \"swatches\": \"...\",
                    \"pages\": [
                        {
                            \"masterPage\": \"8-Master\",
                            \"data\": [
                                {
                                    \"html\": \"...\",
                                    \"images\": \"...\",
                                    \"texts\": \"...\"
                                }
                            ]
                        }
                    ]
                },
                {
                    \"template\": \"content\",
                    \"swatches\": \"...\",
                    \"pages\": [
                        {
                            \"masterPage\": \"8-Master\",
                            \"data\": [
                                {
                                    \"html\": \"...\",
                                    \"images\": \"...\",
                                    \"texts\": \"...\"
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }
}"
const url = new URL(
    "http://localhost:89/api/create-document"
);

const headers = {
    "Authorization": "Bearer {YOUR_AUTH_KEY}",
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Accept-Encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
};

let body = {
    "templates": {
        "cover": "http:\/\/app.phpindesign\/templates\/template_cover.idml",
        "content": "http:\/\/app.phpindesign\/templates\/template_content.idml"
    },
    "company": "Guideline",
    "outputFileName": "MyDocument",
    "outputFileType": "pdf",
    "maxGenerateTime": 5,
    "hide": [
        "Image_1",
        "Text_2",
        "Title"
    ],
    "data": {
        "book": {
            "documents": [
                {
                    "template": "cover",
                    "swatches": "...",
                    "pages": [
                        {
                            "masterPage": "8-Master",
                            "data": [
                                {
                                    "html": "...",
                                    "images": "...",
                                    "texts": "..."
                                }
                            ]
                        }
                    ]
                },
                {
                    "template": "content",
                    "swatches": "...",
                    "pages": [
                        {
                            "masterPage": "8-Master",
                            "data": [
                                {
                                    "html": "...",
                                    "images": "...",
                                    "texts": "..."
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
import requests
import json

url = 'http://localhost:89/api/create-document'
payload = {
    "templates": {
        "cover": "http:\/\/app.phpindesign\/templates\/template_cover.idml",
        "content": "http:\/\/app.phpindesign\/templates\/template_content.idml"
    },
    "company": "Guideline",
    "outputFileName": "MyDocument",
    "outputFileType": "pdf",
    "maxGenerateTime": 5,
    "hide": [
        "Image_1",
        "Text_2",
        "Title"
    ],
    "data": {
        "book": {
            "documents": [
                {
                    "template": "cover",
                    "swatches": "...",
                    "pages": [
                        {
                            "masterPage": "8-Master",
                            "data": [
                                {
                                    "html": "...",
                                    "images": "...",
                                    "texts": "..."
                                }
                            ]
                        }
                    ]
                },
                {
                    "template": "content",
                    "swatches": "...",
                    "pages": [
                        {
                            "masterPage": "8-Master",
                            "data": [
                                {
                                    "html": "...",
                                    "images": "...",
                                    "texts": "..."
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }
}
headers = {
  'Authorization': 'Bearer {YOUR_AUTH_KEY}',
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Accept-Encoding': 'gzip, deflate, br',
  'Connection': 'keep-alive'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200):


{
    "status": "success",
    "message": "Message describing the response result",
    "data": {
        "file": "Url to the generated file requested"
    }
}
 

Example response (401):


{
    "status": "error",
    "message": "Message describing the error",
    "data": null
}
 

Request   

POST api/create-document

Body Parameters

templates   object   

The indesign idml or indt template(s) to use as a key/value pair. An identifier and url to the downloadable file.

company   string   

The company id used as unique key as reference

outputFileName   string   

The output file name to use for all documents created

outputFileType   string  optional  

optional The output file type to return once generation is done created

maxGenerateTime   integer  optional  

optional The maximum execution time in minutes a generation can run before a response is returned

hide   string[]  optional  

optional The frames to hide by script label(s) given.

data   object  optional  

optional The data set to generate. .