Preskočiť na obsah

API – Pošta

Cesty sú za https://api.innovanet.com. Hlavička Authorization: Bearer inv_mcp_…. Funkcia innovanet() je v kapitole Rozhranie API.

post_type: 1 došlá, 2 odoslaná. Predvolene došlá.

GET /api/post

Parameter Typ Povinné Popis
page integer nie predvolene 1
limit integer nie predvolene 20
year integer nie
post_type integer nie 1 alebo 2
status integer nie
project_id integer nie
company_id integer nie
search string nie
sort_by string nie predvolene post_created
sort_order string nie ASC alebo DESC
$res = innovanet('GET', '/api/post?post_type=1&year=2026');

Odpoveď 200

{
  "success": true,
  "data": {
    "items": [
      {
        "id": 7,
        "post_type": 1,
        "post_subject": "Zmluva",
        "post_customer_name": "Acme s.r.o.",
        "post_delivered": "2026-11-04",
        "post_created_by_name": "Jana Nováková"
      }
    ],
    "total": 1,
    "page": 1,
    "limit": 20,
    "total_pages": 1
  }
}

Detail: GET /api/post/7.

POST /api/post

Dátum doručenia alebo odoslania nesmie byť v budúcnosti.

Pole Typ Povinné Popis
post_type integer nie 1 došlá, 2 odoslaná
post_subject string nie
post_delivered dátum nie nie v budúcnosti
post_customer_id integer nie partner z adresára
post_number string nie podacie číslo
post_owner integer nie zodpovedná osoba, predvolene vy
project_id integer nie
post_desc string nie
post_note string nie
notified_user_ids pole integerov nie koho upozorniť

Požiadavka

{
  "post_type": 1,
  "post_subject": "Zmluva",
  "post_delivered": "2026-11-04",
  "post_customer_id": 120,
  "post_number": "RP123456789SK"
}

PHP

$res = innovanet('POST', '/api/post', [
    'post_type' => 1,
    'post_subject' => 'Zmluva',
    'post_delivered' => '2026-11-04',
    'post_customer_id' => 120,
]);

Odpoveď 201

{
  "success": true,
  "message": "Zásielka bola vytvorená",
  "data": { "id": 7 }
}

Budúci dátum vráti 422.

Ostatné cesty

Každá cesta nižšie je súčasťou tohto modulu. Názvy polí sú tie, ktoré API číta. Súbor na stiahnutie nie je JSON.

GET /api/post/list-info

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

GET /api/post/stats

Parametre

Pole Typ Povinné
year string nie
scope string nie

API tieto polia číta. Povinnosť platí, keď je v tabuľke áno.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

GET /api/post/carriers/{carrierId}/classes

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

POST /api/post/export

Telo

Pole Typ Povinné
carrier_id integer áno
post_ids array áno
sender object nie
{
  "carrier_id": 1,
  "post_ids": [7, 8],
  "sender": { "name": "innovanet", "city": "Bratislava" }
}
$res = innovanet('POST', '/api/post/export', [
    'carrier_id' => 1,
    'post_ids' => [7, 8],
]);

Bez carrier_id alebo post_ids je 400. sender dopĺňa odosielateľa na štítku.

Odpoveď – Odpoveď je súbor, nie JSON.

POST /api/post/import

Import dopĺňa podacie čísla existujúcich zásielok z odpovede prepravcu. Vyžaduje oprávnenie spravovať všetku poštu. Požiadavka je multipart/form-data.

Pole Typ Povinné Popis
carrier_id integer áno identifikátor prepravcu z list-info
file file áno odpoveď prepravcu, napríklad XML Slovenskej pošty

Príklad pre shell Bash; identifikátor prepravcu a cestu k súboru nahraďte vlastnými hodnotami.

curl -sS -X POST "https://api.innovanet.com/api/post/import" -H "Authorization: Bearer inv_mcp_…" -H "Accept: application/json" -F "carrier_id=1" -F "file=@response.xml"

PHP cURL: súbor musí byť objekt CURLFile. Nepoužívajte JSON pomocníka innovanet() pre toto volanie.

$ch = curl_init('https://api.innovanet.com/api/post/import');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer inv_mcp_…',
        'Accept: application/json',
    ],
    CURLOPT_POSTFIELDS => [
        'carrier_id' => 1,
        'file' => new CURLFile(__DIR__ . '/response.xml'),
    ],
]);
$raw = curl_exec($ch);
$status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($raw, true);

Odpoveď 200 obsahuje počet spracovaných záznamov a chyby. Aj pri úspešnej HTTP odpovedi skontrolujte pole errors.

{
  "success": true,
  "data": { "imported": 2, "errors": [] },
  "message": "..."
}

Chyby: 400 pri chýbajúcom prepravcovi/súbore alebo nepodporovanom importe, 403 bez oprávnenia, 404 pri neznámom prepravcovi. Nové zásielky toto volanie nevytvára.

GET /api/post/{id}/history-attachments

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

GET /api/post/{id}/history

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

POST /api/post/{id}/comments

Telo

Pole Typ Povinné
body string nie
reason_id string nie
{
  "body": "text",
  "reason_id": "text"
}
$res = innovanet('POST', '/api/post/1/comments', [
    'body' => 'text',
    'reason_id' => 'text',
]);

API tieto polia číta. Povinnosť platí, keď je v tabuľke áno.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

GET /api/post/{id}/attachments

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

POST /api/post/{id}/attachments

Priloženie súboru k zásielke. Súbor je povinný a zásielka musí byť používateľovi dostupná. Úspech: 200 so success: true; chýbajúci alebo neplatný súbor: 400.

Pole Typ Povinné
file file áno

Súbor odošlite ako multipart/form-data. Príklad pre Bash:

curl -sS -X POST "https://api.innovanet.com/api/post/7/attachments" -H "Authorization: Bearer inv_mcp_…" -H "Accept: application/json" -F "file=@document.pdf"

DELETE /api/post/{id}/attachments/{attachmentId}

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

GET /api/post/{id}/attachments/{attachmentId}/download

Bez tela.

Odpoveď – Odpoveď je súbor, nie JSON.

GET /api/post/{id}/notified

Bez tela.

Odpoveď 200 – Obálka { "success": true, "data": ... }.

PUT /api/post/{id}/notified

Telo

Pole Typ Povinné
user_ids string nie
{
  "user_ids": "text"
}
$res = innovanet('PUT', '/api/post/1/notified', [
    'user_ids' => 'text',
]);

API tieto polia číta. Povinnosť platí, keď je v tabuľke áno.

Odpoveď 200 – Obálka { "success": true, "data": ... }.


Máte záujem vyskúšať túto funkciu? Aktivujte si innovanet v skúšobnej dobe →