DOKTOMY - Dokumentacja API

Informacje ogólne

W celu połączenia się z API, należy wykonać żądanie POST na adres https://app.doktomy.com/api/[nazwa_metody] z parametrem POST "api_token" zawierającym klucz API, który jest możliwy do wygenerowania w aplikacji DOKTOMY.

Metody API

1. /api/templates

Metoda służy do pobrania listy szablonów.

URL:

https://app.doktomy.com/api/templates

Parametry wejściowe (POST):

Klucz Wymagany Typ danych Opis
api_token TAK string Klucz API
limit TAK int Liczba pobranych rekordów (na potrzeby paginacji). Minimalna wartość to 1, maksymalna 100.
Przykłady użycia
CURL:
                    
curl --location --request POST 'https://app.doktomy.com/api/templates' \
--footer 'Accept: application/json' \
--form 'api_token="[API_KEY]"' \
--form 'limit="100"'
                    
                
PHP:
                    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.doktomy.com/api/templates',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_token' => '[API_KEY]','limit' => '100'),
  CURLOPT_HTTPfooter => array(
    'Accept: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                    
                
Przykłady odpowiedzi
                    
{
  "message": "OK",
  "errors": [],
  "list": {
    "current_page": 1,
    "data": [
      {
        "id": 115,
        "name": "Nazwa szablonu",
        "description": null,
        "file_name": ""
      }
    ],
    "first_page_url": "https://app.doktomy.com/api/templates?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://app.doktomy.com/api/templates?page=1",
    "links": [
      {
        "url": null,
        "label": "« Poprzednia",
        "active": false
      },
      {
        "url": "https://app.doktomy.com/api/templates?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Nastepna »",
        "active": false
      }
    ],
    "next_page_url": null,
    "path": "https://app.doktomy.com/api/templates",
    "per_page": "100",
    "prev_page_url": null,
    "to": 1,
    "total": 1
  }
}
                    
                
                    
{
    "message": "Error",
    "errors": {
        "api_token": [
            "Nieprawidłowy klucz API"
        ]
    }
}
                    
                

2. /api/email-templates

Metoda służy do pobrania listy szablonów e-mail.

URL:

https://app.doktomy.com/api/email-templates

Parametry wejściowe (POST):

Klucz Wymagany Typ danych Opis
api_token TAK string Klucz API
limit TAK int Liczba pobranych rekordów (na potrzeby paginacji). Minimalna wartość to 1, maksymalna 100.
Przykłady użycia
CURL:
                    
curl --location --request POST 'https://app.doktomy.com/api/email-templates' \
--footer 'Accept: application/json' \
--form 'api_token="[API_KEY]"' \
--form 'limit="1"'
                    
                
PHP:
                    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.doktomy.com/api/email-templates',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_token' => '[API_KEY]','limit' => '1'),
  CURLOPT_HTTPfooter => array(
    'Accept: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                    
                
Przykłady odpowiedzi
                    
{
    "message": "OK",
    "errors": [],
    "list": {
        "current_page": 1,
        "data": [
            {
                "id": 17,
                "name": "Przykładowy szablon",
                "description": "Opis przykładowego szablonu",
                "default": 1,
                "email_topic": "Temat przykładowego szablonu",
                "email_content": "Treść przykładowego szablonu",
                "receivers": null,
                "receivers_cc": null,
                "receivers_bcc": null
            }
        ],
        "first_page_url": "https://app.doktomy.com/api/email-templates?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "https://app.doktomy.com/api/email-templates?page=1",
        "links": [
            {
                "url": null,
                "label": "« Poprzednia",
                "active": false
            },
            {
                "url": "https://app.doktomy.com/api/email-templates?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": null,
                "label": "Nastepna »",
                "active": false
            }
        ],
        "next_page_url": null,
        "path": "https://app.doktomy.com/api/email-templates",
        "per_page": "1",
        "prev_page_url": null,
        "to": 1,
        "total": 1
    }
}
                    
                
                    
{
    "message": "Error",
    "errors": {
        "api_token": [
            "Nieprawidłowy klucz API"
        ]
    }
}
                    
                

3. /api/document-footers

Metoda służy do pobrania listy stopek.

URL:

https://app.doktomy.com/api/document-footers

Parametry wejściowe (POST):

Klucz Wymagany Typ danych Opis
api_token TAK string Klucz API
limit TAK int Liczba pobranych rekordów (na potrzeby paginacji). Minimalna wartość to 1, maksymalna 100.
Przykłady użycia
CURL:
                    
curl --location --request POST 'https://app.doktomy.com/api/document-footers' \
--footer 'Accept: application/json' \
--form 'api_token="[API_KEY]"' \
--form 'limit="2"'
                    
                
PHP:
                    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.doktomy.com/api/document-footers',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_token' => '[API_KEY]','limit' => '2'),
  CURLOPT_HTTPfooter => array(
    'Accept: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                    
                
Przykłady odpowiedzi
                    
{
    "message": "OK",
    "errors": [],
    "list": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "name": "Nazwa stopki",
                "description": "Opis stopki",
                "content": "

Treść

", "default": 0 }, { "id": 2, "name": "Nazwa stopki 2", "description": "Opis stopki 2", "content": "

Treść

", "default": 1 } ], "first_page_url": "https://app.doktomy.com/api/document-footers?page=1", "from": 1, "last_page": 1, "last_page_url": "https://app.doktomy.com/api/document-footers?page=1", "links": [ { "url": null, "label": "« Poprzednia", "active": false }, { "url": "https://app.doktomy.com/api/document-footers?page=1", "label": "1", "active": true }, { "url": null, "label": "Nastepna »", "active": false } ], "next_page_url": null, "path": "https://app.doktomy.com/api/document-footers", "per_page": "2", "prev_page_url": null, "to": 2, "total": 2 } }
                    
{
    "message": "Error",
    "errors": {
        "api_token": [
            "Nieprawidłowy klucz API"
        ]
    }
}
                    
                

4. /api/document-headers

Metoda służy do pobrania listy nagłówków.

URL:

https://app.doktomy.com/api/document-headers

Parametry wejściowe (POST):

Klucz Wymagany Typ danych Opis
api_token TAK string Klucz API
limit TAK int Liczba pobranych rekordów (na potrzeby paginacji). Minimalna wartość to 1, maksymalna 100.
Przykłady użycia
CURL:
                    
curl --location --request POST 'https://app.doktomy.com/api/document-headers' \
--header 'Accept: application/json' \
--form 'api_token="[API_KEY]"' \
--form 'limit="2"'
                    
                
PHP:
                    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.doktomy.com/api/document-headers',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_token' => '[API_KEY]','limit' => '2'),
  CURLOPT_HTTPheader => array(
    'Accept: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                    
                
Przykłady odpowiedzi
                    
{
    "message": "OK",
    "errors": [],
    "list": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "name": "Nazwa nagłówka",
                "description": "Opis nagłówka",
                "content": "

Treść

", "default": 0 }, { "id": 2, "name": "Nazwa nagłówka 2", "description": "Opis nagłówka 2", "content": "

Treść

", "default": 1 } ], "first_page_url": "https://app.doktomy.com/api/document-headers?page=1", "from": 1, "last_page": 1, "last_page_url": "https://app.doktomy.com/api/document-headers?page=1", "links": [ { "url": null, "label": "« Poprzednia", "active": false }, { "url": "https://app.doktomy.com/api/document-headers?page=1", "label": "1", "active": true }, { "url": null, "label": "Nastepna »", "active": false } ], "next_page_url": null, "path": "https://app.doktomy.com/api/document-headers", "per_page": "2", "prev_page_url": null, "to": 2, "total": 2 } }
                    
{
    "message": "Error",
    "errors": {
        "api_token": [
            "Nieprawidłowy klucz API"
        ]
    }
}
                    
                

5. /api/template

Metoda służy do pobrania szczegółów szablonu.

URL:

https://app.doktomy.com/api/template

Parametry wejściowe (POST):

Klucz Wymagany Typ danych Opis
api_token TAK string Klucz API
id TAK int ID szablonu.
Przykłady użycia
CURL:
                    
curl --location --request POST 'https://app.doktomy.com/api/template' \
--footer 'Accept: application/json' \
--form 'api_token="[API_KEY]"' \
--form 'id="115"'
                    
                
PHP:
                    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.doktomy.com/api/template',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_token' => '[API_KEY]','id' => '115'),
  CURLOPT_HTTPfooter => array(
    'Accept: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                    
                
Przykłady odpowiedzi
                    
{
    "message": "OK",
    "errors": [],
    "template": {
        "id": 115,
        "name": "Nazwa szablonu",
        "description": null,
        "file_name": "1",
        "variables": [
            "imię",
            "nazwisko",
            "telefon"
        ]
    }
}
                    
                
                    
{
    "message": "Error",
    "errors": {
        "api_token": [
            "Nieprawidłowy klucz API"
        ]
    }
}
                    
                

6. /api/generate-document

Metoda służy do wygenerowania dokumentu.

Metoda zwraca dwie istotne wartości:

URL:

https://app.doktomy.com/api/generate-document

Parametry wejściowe (POST):

Klucz Wymagany Typ danych Opis
api_token TAK string Klucz API
template_id TAK int ID szablonu.
add_footer TAK boolean (0 lub 1) Informacja, czy dołączyć nagłówek do dokumentu.
footer TAK, jeśli add_footer=1 int ID nagłówka.
add_footer TAK boolean (0 lub 1) Informacja, czy dołączyć stopkę do dokumentu.
footer TAK, jeśli add_footer=1 int ID stopki.
variables[XYZ] NIE string Wartości zmiennych. Listę zmiannych dla danego szablonu można pobrać za pomocą metody /api/template. Wartość XYZ należy zastępić nazwą zmiannej. Pole to może występować wielokrotnie w zależności od liczby zmiennych w szablonie.
send_email NIE boolean Informacja, czy wysłąć dokument e-mailem.
email_template_id TAK - jeśli pole send_email=1 int ID szablonu e-mail.
email TAK - jeśli pole send_email=1 int Adres e-mail do wysyłki szablonu.
description NIE string Opis dokumentu.
Przykłady użycia
CURL:
                    
curl --location --request POST 'https://app.doktomy.com/api/generate-document' \
--header 'Accept: application/json' \
--form 'api_token="[API_KEY]"' \
--form 'template_id="115"' \
--form 'add_header="1"' \
--form 'header="1"' \
--form 'variables[imię]="Jan"' \
--form 'variables[nazwisko]="Kowalski"' \
--form 'variables[telefon]="555666777"' \
--form 'add_footer="1"' \
--form 'footer="2"' \
--form 'send_email="1"' \
--form 'email_template_id="17"' \
--form 'email="mail@example.com"' \
--form 'description="Opis"'
                    
                
PHP:
                    
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://app.doktomy.com/api/generate-document',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('api_token' => '[API_KEY]','template_id' => '115','add_header' => '1','header' => '1','variables[imię]' => 'Jan','variables[nazwisko]' => 'Kowalski','variables[telefon]' => '555666777','add_footer' => '1','footer' => '2','send_email' => '1','email_template_id' => '17','email' => 'mail@example.com','description' => 'Opis'),
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                    
                
Przykłady odpowiedzi
                    
{
    "message": "OK",
    "link": "https://app.doktomy.com/api/get-document?api_token=%242y%2410%24lrvYA4O1LZ.rOIxkOB.jsuHKR4or4VEvLjf3rH50qNnQc1%2Fhqdpru&document_token=27d80b8d686456871ed24abdaa6253cc",
    "safe_link": "https://app.doktomy.com/api/document-safe-link?api_token=%242y%2410%24lrvYA4O1LZ.rOIxkOB.jsuHKR4or4VEvLjf3rH50qNnQc1%2Fhqdpru&document_token=27d80b8d686456871ed24abdaa6253cc"
}
                    
                
                    
{
    "message": "Error",
    "errors": {
        "api_token": [
            "Nieprawidłowy klucz API"
        ]
    }
}