## Response Codes

| Code | Status | Description | Error cause |
| --- | --- | --- | --- |
| 200 | OK | operation completed successfully | - |
| 400 | Bad Request | malformed query | syntax error |
| 401 | Unauthorized | authorization error | missing or invalid token |
| 403 | Forbidden | authorization error | insufficient user permissions (in Money Sx) |
| 404 | Not Found | not found | incorrect endpoint address, server unavailable |
| 415 | Unsupported Media Type | unsupported format | request sent in an unsupported format (e.g. incorrect Content-Type) |
| 500 | Internal server error | internal server error | specific error description in the response body |

## GET request

```json
GET http(s)://[adresa API]/graphql?query={[dotaz]}
např.: GET https://demo.moneyerp.cz/graphql?query={[dotaz]}
Authorization: Bearer [token]
```

## POST request

```json
POST http(s)://[adresa API]/graphql
Authorization: Bearer [token]
request body: {„query“:“{[dotaz]}“}
```

## Schema

```json
GET http(s)://[adresa API]/graphql/schema
(bez autorizace)
```

## Reading - query

Queries are performed using query on individual objects, with the option to use filtering, grouping, and sorting. Individual fields are always listed within the relevant references. User-defined fields for an agenda are available after they have been added to the agenda and the API has been restarted.

You can also query subordinate references (e.g. document items) as a standalone list. The usual link field is Parent\_ID (e.g. FakturaVydana.ID = PolozkaFakturyVydane.Parent\_ID); some lists also specify the object name itself as the link field (e.g. Artikl\_ID, Cenik\_ID, Zasoba\_ID).

```json
{
    IssuedInvoices(Filter: "DatumVystaveni~gte~2022-02-13#DatumVystaveni~lte~2025-02-14") {
        ID,
        ZpusobPlatby {
            Nazev, Kod
        },
        ZpusobPlatby_ID,
        ZpusobDopravy {
            Nazev, Kod
        },
        ZpusobDopravy_ID,
        AdresaKoncovehoPrijemceEmail,
        AdresaKoncovehoPrijemceKontaktniOsobaNazev,
        AdresaKoncovehoPrijemceStat_ID,
        AdresaKoncovehoPrijemceTelefon,
        AdresaKontaktniOsobaJmeno,
        AdresaKontaktniOsobaNazev,
        AdresaKontaktniOsobaPrijmeni,
        AdresaMisto,
        AdresaNazev,
        AdresaPrijemceFakturyKontaktniOsobaNazev,
        AdresaPrijemceFakturyStat_ID,
        AdresaPSC,
        AdresaStat{Nazev, Kod},
        AdresaStat_ID,
        AdresaUlice,
        CisloDokladu,
        DatumVystaveni,
        DodaciAdresaFirma_ID,
        DodaciAdresaMisto,
        DodaciAdresaNazev,
        DodaciAdresaPSC,
        DodaciAdresaStat,
        DodaciAdresaUlice,
        DomaciMena_ID,
        FakturacniAdresaMisto,
        FakturacniAdresaNazev,
        FakturacniAdresaPSC,
        FakturacniAdresaStat,
        FakturacniAdresaUlice,
        Poznamka,
        SumaCelkemCM,
        VariabilniSymbol,
        UhradyZbyvaCM,
        ZapornyPohyb,
        OdkazNaDoklad,
        PrimarniUcet_ID
        PrimarniUcet { ID, CisloUctu},
        Predkontace_ID,
        Predkontace { ID, Kod, Nazev},
        Mena_ID,
        Mena {
            Kod
        },
        Stredisko_ID,
        Stredisko { ID, Kod, Nazev},
        Zakazka_ID,
        Zakazka { ID, Kod, Nazev},
        Cinnost_ID,
        Cinnost { ID, Kod, Nazev},
        Polozky {
             ID,
            Poradi,
            Nazev,
            Katalog,
            Jednotka,
            Mnozstvi,
            JednCenaCM,
            DphSazba,
            CelkovaCenaCM,
            TypCeny,
            Sleva,
            Vratka,
            ObsahPolozky {
             Artikl_ID,
             Artikl{ID, Katalog, Kod, CarovyKod, Nazev, VlastniHmotnost},
             Sklad_ID,
             Sklad {ID, Kod, Nazev},
             Zasoba_ID,
             Zasoba {ID, Kod, Nazev, DostupneMnozstvi, PredpokladaneMnozstvi, Rezervovano, Objednano},
             Cenik_ID,
             Cenik {ID, Kod, Nazev}
         },
        },
        Create_Date,
        Modify_Date
    }
}
```

## Writing - mutation (create)

Article

```
POST http(s)://[adresa API]/graphql
{"query":"mutation { CreateArticle(Article:{Nazev: \"Artikl\"}) {ID,Nazev} }"}
```

Received order

```json
POST http(s)://[adresa API]/graphql
{"query":"mutation { CreateReceivedOrder(ReceivedOrder:{Nazev: \"objednávka\", Polozky: [{Nazev: \"položka\", ObsahPolozky: {Artikl_ID:\"848a11a5-97bc-43e4-8e88-25c803bb51ff\"}}]}) {ID,Nazev} }"}
```

The structure of required and optional fields is similar throughout the system. Descriptions are provided in the individual references. You must also take into account the individual settings for the agenda, especially groups and their pre-filled data. For example, some groups have a number series pre-filled by the user, so there is no need to send a document number; other settings may include controlling variables or the document rounding method after saving. These settings may affect the document when saved or subsequently saved again.

```json
mutation {
  CreateReceivedOrder(
    ReceivedOrder: {
      CisloDokladu: "22030001"
      Nazev: "Objednávka č.22030001 z solitea.cz"
      VariabilniSymbol: "22030001"
      Odkaz: "22030001"
      Group_ID: "c2b0081d-bda0-4c6e-b85a-48a4ac62b52c"
      IC: "01572377"
      DIC: "CZ01572377"
      Firma_ID: "d9d5324f-ca16-43b4-a326-f854ff03bca3"
      AdresaNazev: "Solitea, a.s."
      AdresaUlice: "Drobného 555/49"
      AdresaMisto: "Brno"
      AdresaPSC: "60200"
      AdresaStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      DodaciAdresaFirma_ID: null
      DodaciAdresaNazev: "Solitea, a.s."
      DodaciAdresaUlice: "Okružní 732/5"
      DodaciAdresaMisto: "Brno"
      DodaciAdresaPSC: "63800"
      DodaciAdresaStat: "Česká republika"
      AdresaKoncovehoPrijemceStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      AdresaKoncovehoPrijemceKontaktniOsobaNazev: "Jan Novák"
      AdresaKoncovehoPrijemceTelefon: "+420734123456"
      AdresaKoncovehoPrijemceEmail: "moneyerp@solitea.cz"
      FakturacniAdresaFirma_ID: null
      FakturacniAdresaNazev: "Solitea, a.s."
      FakturacniAdresaUlice: "Drobného 555/49"
      FakturacniAdresaMisto: "Brno"
      FakturacniAdresaPSC: "60200"
      AdresaPrijemceFakturyStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      ZpusobPlatby_ID: "5b035689-496c-4f5f-a48a-4418a7d041ae"
      ZpusobDopravy_ID: "73cd5949-ceaa-4ed3-ace8-34710f724e9c"
      Mena_ID: "00f9adb2-d300-42c3-9240-ae1320b019cc"
      #Zaplaceno_UserData:false,
      Sleva: 0.0000
      Poznamka: "Poznámka k dokladu"
      System_Komentar: "Komentář dokladu"
      System_Priznak: 2
      Polozky: [
        {
          Poradi: 1
          GenerateSubItems: true
          Nazev: "Skladová položka"
          Katalog: "11K1"
          Jednotka: "ks"
          Mnozstvi: 2
          JednCenaCM: 12
          DphSazba: 21
          TypCeny: 1
          TypObsahu: 1
          ObsahPolozky: {
            Artikl_ID: "7bb036fa-ef6e-4bd4-acf5-031143161c03"
            Sklad_ID: "9bcfddf9-d7c0-4f59-8c9b-73ae5bba3c15"
            Cenik_ID: "afe86a46-6fa4-4a8a-b97d-ede320d33c7c"
          }
          Sleva: 0
          Vratka: false
        }
        {
          Poradi: 2
          Nazev: "Neskladová položka"
          Katalog: "12K2"
          Jednotka: "ks"
          Mnozstvi: 3
          JednCenaCM: 33.33
          DphSazba: 21
          TypCeny: 1
          TypObsahu: 0
          Sleva: 0
          Vratka: false
        }
      ]
    }
  ) {
    ID
    CisloDokladu
    Polozky {
      ID
      Nazev
      Poradi
      Mnozstvi
      JednCenaCM
      CelkovaCenaCM
      DphSazba
    }
  }
}
```

```json
mutation {
  CreateCompany(
    Company: {
      Kod: "ADR00001"
      Group_ID: "d894c9c9-e1df-4cc4-bd0e-f6cd26bec0d8"
      Nazev: "Solitea - zařadit"
      DIC: "CZ01572377"
      ICO: "01572377"
      OdlisnaAdresaProvozovny: true
      OdlisnaFakturacniAdresa: true
      ObchMisto: "Brno"
      ObchNazev: "Solitea, a.s."
      ObchUlice: "Drobného 555/49"
      ObchPsc: "60200"
      ObchStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      ProvMisto: "Brno"
      ProvNazev: "Solitea, a.s."
      ProvUlice: "Drobného 555/49"
      ProvPsc: "60200"
      ProvStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      FaktMisto: "Brno"
      FaktNazev: "Solitea, a.s."
      FaktUlice: "Drobného 555/49"
      FaktPsc: "60200"
      FaktStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      VariabilniSymbol: ""
      PouzivatKredit: true
      HodnotaKreditu: 500.0000
      VlastniSleva: true
      HodnotaSlevy: 10.0000
      VlastniSplatnostPohledavek: false
      SplatnostPohledavek: 0
      VlastniSplatnostZavazku: false
      SplatnostZavazku: 0
      SeznamSpojeni: [
        {
          SpojeniCislo: "+420 731123456"
          TypSpojeni_ID: "999a45ed-7c85-425c-8230-d58ae08a21c6"
        }
        {
          SpojeniCislo: "muj@email.cz"
          TypSpojeni_ID: "dc748a02-43ed-4cc5-8264-4994b56919d0"
        }
      ]
      Zprava: ""
      Poznamka: ""
    }
  ) {
    ID
    Nazev
    Tel1Cislo
    Tel2Cislo
    Email
    SeznamSpojeni {
      ID
      Poradi
      SpojeniCislo
    }
  }
}
```

```json
mutation {
  CreateReceivedInvoice(
    ReceivedInvoice: {
      CisloDokladu: "22030003"
      Nazev: "Faktura č.22030002"
      VariabilniSymbol: "22030001"
      DatumVystaveni: "2023-11-15T00:00:00"
      DatumUcetnihoPripadu: "2023-11-15T00:00:00"
      DatumPlneni: "2023-11-15T00:00:00"
      DatumSplatnosti: "2023-11-15T00:00:00"
      DatumSkladovehoPohybu: "2023-11-15T00:00:00"
      DatumUplatneni: "2023-11-15T00:00:00"
      OdkazNaDoklad: "ProVykaz"
      PuvodniDoklad: ""
      # ParovaciSymbol:"",
      Group_ID: "b9bf30ab-f702-4ff9-ae03-c9b6562f5b85"
      IC: "01572377"
      DIC: "CZ01572377"
      Firma_ID: "97385817-15a2-4dd4-a652-bf1aaa29325d"
      AdresaNazev: "Seyfor, a.s."
      AdresaUlice: "Drobného 555/49"
      AdresaMisto: "Brno"
      AdresaPSC: "60200"
      AdresaStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      DodaciAdresaFirma_ID: null
      DodaciAdresaNazev: "Seyfor, a.s."
      DodaciAdresaUlice: "Okružní 732/5"
      DodaciAdresaMisto: "Brno"
      DodaciAdresaPSC: "63800"
      DodaciAdresaStat: "Česká republika"
      AdresaKoncovehoPrijemceStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"
      AdresaKoncovehoPrijemceKontaktniOsobaNazev: "Jan Novák"
      AdresaKoncovehoPrijemceTelefon: "+420734123456"
      AdresaKoncovehoPrijemceEmail: "obchod@moneyerp.com"
      FakturacniAdresaFirma_ID: null
      FakturacniAdresaNazev: "Seyfor, a.s."
      FakturacniAdresaUlice: "Drobného 555/49"
      FakturacniAdresaMisto: "Brno"
      FakturacniAdresaPSC: "60200"
      AdresaPrijemceFakturyStat_ID: "3d3f235c-df25-42ad-9cce-1b460e3a3c5f"

      ZpusobPlatby_ID: "5b035689-496c-4f5f-a48a-4418a7d041ae"
      ZpusobDopravy_ID: "73cd5949-ceaa-4ed3-ace8-34710f724e9c"

      # Měna na dokladu je dosazena automaticky výchozí domácí obvykle CZK,
      # pokud má být jiná, tak je potřeba určit měnu a kurz
      # Mena_ID:"e9daab77-0517-4f36-ac41-9b798182a7ae",
      # UcetniKurzKurz: 25.30,
      # KurzMnozstvi: 1,

      # Následující hodnoty jsou obvykle převzaty ze skupiny dokladů
      # Predkontace_ID:"acc2154d-93f6-48e5-bab0-7a2e9971a9ba"
      # CleneniDPH_ID:"bd0fe7aa-10a4-4fcc-8ad3-dc7a779ebc3e"
      # PrimarniUcet_ID:"b06c2efc-3c07-46f4-924d-051337043e04"

      #Kontrolingové proměnné, pokud není doplněno na položce, použije se z hlavičky
      #Stredisko_ID: "06fda739-f4d7-43a3-8689-a2a49a926166",
      #Zakazka_ID: "4d46f8e3-88e8-4e3b-bd7d-8235c4dc6e7d",
      #Cinnost_ID: "0318e49c-cfeb-490f-9fca-b9d9539de2fe",

      Sleva: 0.0000
      Poznamka: "Poznámka k dokladu"
      Polozky: [
        {
          Poradi: 1
          GenerateSubItems: true # Pokud je položka skladová a se složením, tak automticky vloží její složení, je možné posílat výdy u všech položek
          Nazev: "Skladová položka 1"
          Katalog: "11K1"
          Jednotka: "ks"
          Mnozstvi: 2
          JednCenaCM: 12 # Jednotková cena v cizí měně, pokud je měna stejná jako domácí, tak hodnota bez CM je také stejná
          DphSazba: 21
          TypCeny: 1 # 0-bezDPH, 1-sDPH, 2-PouzeZaklad, 3-PouzeDan
          TypObsahu: 1 # vazba na sklad, vyžaduje ObsahPolozky
          ObsahPolozky: {
            Artikl_ID: "5f051127-89d7-49b9-be36-00aa04e5269b"
            Sklad_ID: "8537627e-11d4-4a2d-a2ef-f55f59ad662f"
          }
          Sleva: 0
          Vratka: false
        }
        {
          Poradi: 2
          GenerateSubItems: true
          Nazev: "Skladová položka 2"
          Katalog: "11K1"
          Jednotka: "ks"
          Mnozstvi: 2
          JednCenaCM: 12
          DphSazba: 21
          TypCeny: 1
          TypObsahu: 1
          ObsahPolozky: {
            Artikl_ID: "8ba207a4-8705-41c5-a9db-77169210529e"
            Sklad_ID: "8537627e-11d4-4a2d-a2ef-f55f59ad662f"
          }
        }
        {
          Poradi: 3
          GenerateSubItems: true
          Nazev: "Textová položka"
          Katalog: "T12"
          Jednotka: "ks"
          Mnozstvi: 2
          JednCenaCM: 33
          DphSazba: 21
          TypCeny: 1
          TypObsahu: 0
          Sleva: 0
          Vratka: false
        }
        {
          Poradi: 4
          GenerateSubItems: true
          Nazev: "Úcetní položka"
          Katalog: "T14"
          Jednotka: "ks"
          Mnozstvi: 1
          JednCenaCM: 33
          DphSazba: 21
          TypCeny: 2 #Pouze základ
          TypObsahu: 0
          Sleva: 0
          Vratka: false
          UcetDal_ID: "b06c2efc-3c07-46f4-924d-051337043e04"
          UcetMD_ID: "72d27c2c-c32c-41a4-a45f-eb5027181cf6"
          # Stredisko_ID: "1a6b0adc-4100-46ad-b182-c994314b9f25",
          # Zakazka_ID: "4d46f8e3-88e8-4e3b-bd7d-8235c4dc6e7d",
          # Cinnost_ID: "4c438132-d971-42e7-9475-156782874c12",
        }
      ]
    }
  ) {
    ID
    Nazev
    IC
    DIC
    Polozky {
      ID
      Nazev
      ObsahPolozky {
        ID
        Artikl_ID
      }
    }
  }
}
```

###  Groups in lists (Group\_ID)

When submitting a document, it is recommended to include the Group\_ID element, which assigns the document to a specific group that may have settings such as its own number series or cost centre. Each list has a shared Unassigned group; users create their own additional groups (with different Group\_ID values).
Example object names: ObjednavkaPrijata, ObjednavkaVydana, FakturaPrijata, FakturaVydana, Zasoba, PolozkaCeniku, Artikl, DodaciListVydany, DodaciListPrijaty, Firma, PokladniDoklad, BankovniVypis, ProdejkaVydana, ProdejkaPrijata, SkladovyDoklad

```json
POST http(s)://[adresa API]/graphql
request body: {"query":"{MerpGroups(ObjectName:\"ObjednavkaVydana\") {ID, Parent_ID, Kod, Nazev, Object_ID, ObjectName}}"}
```

## Writing - mutation (edit)

```
POST http(s)://[adresa API]/graphql
{"query":"mutation { EditArticle(Article:{ID: \"8cf11616-833d-4f17-b4d3-98ba92e6fd27\", Nazev: \"Artikl-upr\"}) {ID,Nazev} }"}
```

When editing a document header, you can change only the specific fields you want to update.
If you need to **edit document items, you must send all the required details for each item. Editing document items deletes all previous items and replaces them with the items as submitted.**

## Writing - mutation (delete)

```json
POST http(s)://[adresa API]/graphql
{"query":"mutation { DeleteArticle(ID: \"8cf11616-833d-4f17-b4d3-98ba92e6fd27\") }"}
```

## Additional XmlExchangeImport

GraphQL also exposes the System\_XmlExchangeImport object, which is used for external database writes for imports using custom Import XML configurations. This object lets you submit a request through the API to create, edit, or delete most objects in Money, including the option to apply XSLT transformation templates beforehand. In practice, a record containing the XML itself is written to the import table through the API, and is then processed according to the configured custom Import XML logic.

## PDF generation

The GraphQL API lets you retrieve a specific record for **all objects** (with a print form) and generate a downloadable .pdf using the selected report, just as if the user had performed the action directly in Money. The file is not stored anywhere in Money; the request returns the data recorded on the document at that moment. This is analogous to clicking the button above a document in Money to print it to .pdf. This is not PDF printing or generating a print report; it is effectively retrieving or generating a .pdf file.

For the query, you must specify **the API object name, record ID, report ID, and its design ID**. The object name corresponds to the [API reference](/developer/reference-api), where you can find both the API name and its translation, e.g. [issued invoice](/developer/reference-api/issuedinvoice), [received order](/developer/reference-api/receivedorder), [issued delivery notes](/developer/reference-api/issueddeliverynote), etc. The report ID and design ID must be provided by the Money user. The program may have several reports for one object, and a given report may have different designs. These IDs are usually specific to each user, depending on the reports they have created.

Standard query pattern (not /graphql):

```json
GET http(s)://[adresa API]
/pdfreport?objectname=issuedinvoice&id=XYZ&reportid=RRR&designid=DDD
```

For the demo server, the request would look like this, for example (ID of the default system report):

```json
GET https://demo.moneyerp.cz
/pdfreport?objectname=issuedinvoice&id=4cdc32ff-5e60-4d7b-ab00-8074f2165045&reportid=454498F9-A2CB-465D-9A0C-958AB5434DE2&designid=45A40150-E310-4EE9-BA12-6ECFDD94BC18
```

The Money user provides the required IDs, which can be found under *Agenda – Print report settings*. After selecting a specific report for an object, click *Edit* and find the graphic design ID at the bottom of the list of designs. For a user/administrator of print reports in the agenda, this is a routine part of working with and editing templates.

![Image](/uploads/docs/tisk_pdf1.jpg)![Image](/uploads/docs/tisk_pdf2.jpg)

## Uploading attachments

The GraphQL API can also be used to upload attachments to all objects that support attachments in the Money program. Attachments are always added **to a specific object and a specific existing record**, similarly to PDF generation (e.g. ReceivedInvoice or IssuedInvoice). The API imposes no limits on attachment size or quantity; this may be governed by individual IIS settings. Attachments are always uploaded to the database, with no option to change the type (e.g. to a URL link). Write permissions are determined by the user's roles (the user assigned to the API key) in Money. The request is sent as POST, using form-data, and the files are included in the files collection.

```
POST http(s)://[adresa API]
/attachment/IssuedInvoice/8952b0de-1a15-41b2-ad74-876c425db883
```

![api_attachment](/uploads/docs/api_attachment.png)

:::callout {type="warning"}

Postman Web may not handle attachments correctly in Cloud or Agent mode (it may fail to load/send them). The desktop Postman App is recommended for testing.

:::

## Response object

Properties of the wrapper object included in the response sent by S5API:

**Data** - the data content

**RowCount** - total number of records in the database matching the request

**PageCount** - number of pages matching the request. If the number of records in the database matching the request exceeds the specified limit, only the number of records corresponding to that limit is returned. PageCount indicates how many requests the user must split the query into to retrieve all requested data after aggregation.

**Message** - error message

**StackTrace** - contents of the memory stack at the time the error occurred

**Status** - response status [OK = 1, Warning = 2, Error = 3)]

```json
{
    "PageCount": 23,
    "RowCount": 46,
    "Data": {
        "Articles": [
            {
                "ID": "10e76c44-d1cb-4834-9b26-0248307d643b",
                "Nazev": "Boty Under Armour UA Charged Impulse 3-GRY vel. 44",
                "Vyrobce_Nazev": ""
            },
            {
                "ID": "c7ce703f-e21a-4b9f-b04c-03178c9e8a43",
                "Nazev": "Potisk",
                "Vyrobce_Nazev": ""
            }
        ]
    },
    "Status": 1,
    "Message": "",
    "StackTrace": ""
}
```
