Getting started with the API

How to sign in, make your first call and handle the most common scenarios. All examples are in curl, C#, JavaScript and TypeScript.

Introduction

The API is available at https://{CompanyName}.api.ros.bclogia.cz, where {CompanyName} is the name of your company (database). The API recognises which company you are working with from this address.

There are two interfaces, each with its own documentation and sign-in:

InterfaceIntended forSign-inDocumentation
userapplications in which a signed-in user worksuser name and password, method auth/login/doc/en/v1-user
systemsystem integration without a userOAuth2 client credentials (ClientID and ClientSecret)/doc/en/v1-system

All calls are sent over HTTPS and as JSON. The C# examples assume an HttpClient http with BaseAddress set and the Authorization header from the sign-in; the JavaScript and TypeScript examples assume the constants BASE and headers.

Sign-in – user

Call POST /api/v1/auth/login with the user name and password. The response contains the access token (access_token), the refresh token (refresh_token) and the validity of the access token in seconds (expires_in). Send the access token in the Authorization: Bearer … header of every further call.

curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"Username":"john.smith","Password":"secret-password"}'
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json.Nodes;

using var http = new HttpClient { BaseAddress = new Uri("https://{CompanyName}.api.ros.bclogia.cz") };

var response = await http.PostAsJsonAsync("/api/v1/auth/login",
    new { Username = "john.smith", Password = "secret-password" });
response.EnsureSuccessStatusCode();

var tokens = await response.Content.ReadFromJsonAsync<JsonObject>();
var accessToken = (string)tokens!["access_token"]!;
var refreshToken = (string)tokens["refresh_token"]!;

http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
const BASE = "https://{CompanyName}.api.ros.bclogia.cz";

const response = await fetch(`${BASE}/api/v1/auth/login`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ Username: "john.smith", Password: "secret-password" }),
});
if (!response.ok) throw new Error(`Login failed (${response.status})`);

const tokens = await response.json();
const headers = {
  "Content-Type": "application/json",
  Authorization: `Bearer ${tokens.access_token}`,
};
const BASE = "https://{CompanyName}.api.ros.bclogia.cz";

interface TokenResponse {
  access_token: string;
  refresh_token: string;
  expires_in: number;
  token_type: string;
  scope: string;
}

const response = await fetch(`${BASE}/api/v1/auth/login`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ Username: "john.smith", Password: "secret-password" }),
});
if (!response.ok) throw new Error(`Login failed (${response.status})`);

const tokens: TokenResponse = await response.json();
const headers: Record<string, string> = {
  "Content-Type": "application/json",
  Authorization: `Bearer ${tokens.access_token}`,
};

Before the access token expires, exchange it for a new one by calling POST /api/v1/auth/refresh with the body {"RefreshToken":"…"}. Signing out (POST /api/v1/auth/logout, same body) invalidates the refresh token.

Sign-in – system

A system integration obtains a token from the identity server using the OAuth2 client credentials flow. The administrator assigns you the client_id and client_secret. In addition to the standard fields, also send company – the name of the company the token is issued for. The token is valid for the system interface (scope=ros).

curl -X POST "https://identity.bclogia.cz/connect/token" \
  -d "grant_type=client_credentials" \
  -d "client_id=MY_CLIENT_ID" \
  -d "client_secret=MY_CLIENT_SECRET" \
  -d "scope=ros" \
  -d "company={CompanyName}"
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json.Nodes;

using var identity = new HttpClient();
var tokenResponse = await identity.PostAsync("https://identity.bclogia.cz/connect/token",
    new FormUrlEncodedContent(new Dictionary<string, string>
    {
        ["grant_type"] = "client_credentials",
        ["client_id"] = "MY_CLIENT_ID",
        ["client_secret"] = "MY_CLIENT_SECRET",
        ["scope"] = "ros",
        ["company"] = "{CompanyName}",
    }));
tokenResponse.EnsureSuccessStatusCode();

var token = (string)(await tokenResponse.Content.ReadFromJsonAsync<JsonObject>())!["access_token"]!;

using var http = new HttpClient { BaseAddress = new Uri("https://{CompanyName}.api.ros.bclogia.cz") };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
const BASE = "https://{CompanyName}.api.ros.bclogia.cz";

const tokenResponse = await fetch("https://identity.bclogia.cz/connect/token", {
  method: "POST",
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
  body: new URLSearchParams({
    grant_type: "client_credentials",
    client_id: "MY_CLIENT_ID",
    client_secret: "MY_CLIENT_SECRET",
    scope: "ros",
    company: "{CompanyName}",
  }),
});
if (!tokenResponse.ok) throw new Error(`Obtaining the token failed (${tokenResponse.status})`);

const { access_token } = await tokenResponse.json();
const headers = {
  "Content-Type": "application/json",
  Authorization: `Bearer ${access_token}`,
};
const BASE = "https://{CompanyName}.api.ros.bclogia.cz";

const tokenResponse = await fetch("https://identity.bclogia.cz/connect/token", {
  method: "POST",
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
  body: new URLSearchParams({
    grant_type: "client_credentials",
    client_id: "MY_CLIENT_ID",
    client_secret: "MY_CLIENT_SECRET",
    scope: "ros",
    company: "{CompanyName}",
  }),
});
if (!tokenResponse.ok) throw new Error(`Obtaining the token failed (${tokenResponse.status})`);

const { access_token } = (await tokenResponse.json()) as { access_token: string };
const headers: Record<string, string> = {
  "Content-Type": "application/json",
  Authorization: `Bearer ${access_token}`,
};
Secrets. Never store client_secret in code or in a browser web application – request the token from the identity server on the server side.

Lists: selection, sorting and paging

Lists are retrieved with POST …/list (for example POST /api/v1/company/list). In the body you send the selection parameters (the filter, for example OrganizationName), Skip and Take for paging and Sorted for sorting (a field name from the response and the direction Ascending or Descending).

The response has the form { "result": [...], "count": 123, "requestId": "…", "cached": true }: result contains the records of the page, count is the total number of records in the selection.

Prepared lists (cached = true)

If the response contains cached = true next to requestId (for example the company list), the API prepares the selection on the server on the first call and the further pages are read from it. The calls are therefore of two kinds:

First call (without x-request-id)Next calls (with a valid x-request-id)
What happensa database query is run according to the selection parameters; the result is prepared on the serverthe prepared result is read, the database is not used
Selection parameterssend themkeep sending the same ones; with a valid x-request-id they do not affect the result, but they allow the selection to be reloaded if it expires. If they differ from the original ones, the response reports it with the message SELECTION_PARAMETERS_IGNORED
Skipignored, the first page is always returnedapplied
Take, Sortedappliedapplied (sorting and paging are done on the prepared result)
Responsea new requestIdthe same requestId

Procedure: the first call without x-request-id and with the selection parameters; all further calls with the same selection parameters, the x-request-id header from the previous response and the required Skip, Take and Sorted. If you want a different selection, start again with a first call (without x-request-id); changing the parameters in a call with a valid x-request-id does not change the selection.

Without x-request-id, a prepared list always returns the first page. The value of Skip is ignored in such a call and the result is prepared again (which opens another selection, see the limit below).
Different parameters with a valid x-request-id. If, in a call with a valid x-request-id, you send selection parameters other than those the selection was prepared with, the result stays the original one (the new parameters are not applied) and the response contains the warning SELECTION_PARAMETERS_IGNORED with severity warning in messages. If you want a selection according to the new parameters, start with a new first call (without x-request-id). Only the content of the selection parameters is compared; Skip, Take, Sorted, spaces around text, letter case and omitting an empty parameter have no effect on the warning.
Expiry. If the prepared result has expired in the meantime (see the validity period below), the API reloads it: it prepares it again according to the selection parameters of this call, returns the requested page from the newly prepared data, a new requestId, and reports the reload with the message CACHE_EXPIRED_RELOADED in messages. From then on use the new requestId. Because the data was loaded again, it may have changed in the meantime (records may be added, removed or shift); for a consistent walk-through, start the list from the first page. That is why you should send the selection parameters always the same – without them the selection would be reloaded without a filter.
# 1st call: selection parameters, no x-request-id (database query; returns the first page and a requestId)
curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/list" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"OrganizationName":"Smith","Skip":0,"Take":50,"Sorted":[{"Name":"OrganizationFullName","Direction":"Ascending"}]}'

# next calls: x-request-id from the previous response and the same selection parameters (the database is not used)
curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/list" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -H "x-request-id: REQUEST_ID" \
  -d '{"OrganizationName":"Smith","Skip":50,"Take":50,"Sorted":[{"Name":"OrganizationFullName","Direction":"Ascending"}]}'
using System.Net.Http.Json;
using System.Text.Json.Nodes;

var sorted = new[] { new { Name = "OrganizationFullName", Direction = "Ascending" } };

string? requestId = null;
for (var skip = 0; ; skip += 50)
{
    // Send the same selection parameters in every call; x-request-id only from the second call.
    using var request = new HttpRequestMessage(HttpMethod.Post, "/api/v1/company/list")
    {
        Content = JsonContent.Create(new { OrganizationName = "Smith", Skip = skip, Take = 50, Sorted = sorted }),
    };
    if (requestId is not null) request.Headers.Add("x-request-id", requestId);

    var response = await http.SendAsync(request);
    response.EnsureSuccessStatusCode();

    var page = (await response.Content.ReadFromJsonAsync<JsonObject>())!;
    requestId = (string?)page["requestId"];   // after a selection reload this is the new requestId

    if (page["messages"]?.AsArray().Any(m => (string?)m?["code"] == "CACHE_EXPIRED_RELOADED") == true)
        Console.WriteLine("The selection was reloaded because the original expired; the data may have changed in the meantime.");

    var records = page["result"]!.AsArray();
    foreach (var record in records) Console.WriteLine(record!["OrganizationFullName"]);

    if (skip + records.Count >= (int)page["count"]!) break;
}
const take = 50;
const sorted = [{ Name: "OrganizationFullName", Direction: "Ascending" }];
let requestId = null;

for (let skip = 0; ; skip += take) {
  // Send the same selection parameters in every call; x-request-id only from the second call.
  const response = await fetch(`${BASE}/api/v1/company/list`, {
    method: "POST",
    headers: requestId ? { ...headers, "x-request-id": requestId } : headers,
    body: JSON.stringify({ OrganizationName: "Smith", Skip: skip, Take: take, Sorted: sorted }),
  });
  if (!response.ok) throw new Error(`List request failed (${response.status})`);

  const page = await response.json();
  requestId = page.requestId; // after a selection reload this is the new requestId

  if (page.messages?.some((m) => m.code === "CACHE_EXPIRED_RELOADED"))
    console.warn("The selection was reloaded because the original expired; the data may have changed in the meantime.");

  page.result.forEach((c) => console.log(c.OrganizationFullName));

  if (skip + page.result.length >= page.count) break;
}
interface Page<T> {
  result: T[];
  count: number;
  requestId: string;
  cached: boolean;
  messages: { code: string; message: string }[] | null;
}

interface CompanyRow {
  CompanyId: number;
  OrganizationFullName: string;
  CompanyRegistrationNumber: string;
}

interface Sort {
  Name: string;
  Direction: "Ascending" | "Descending";
}

interface CompanyListRequest {
  OrganizationName?: string; // selection parameters; the same in every call
  Skip: number;
  Take: number;
  Sorted: Sort[];
}

const take = 50;
const sorted: Sort[] = [{ Name: "OrganizationFullName", Direction: "Ascending" }];
let requestId: string | null = null;

for (let skip = 0; ; skip += take) {
  // Send the same selection parameters in every call; x-request-id only from the second call.
  const body: CompanyListRequest = { OrganizationName: "Smith", Skip: skip, Take: take, Sorted: sorted };

  const response: Response = await fetch(`${BASE}/api/v1/company/list`, {
    method: "POST",
    headers: requestId ? { ...headers, "x-request-id": requestId } : headers,
    body: JSON.stringify(body),
  });
  if (!response.ok) throw new Error(`List request failed (${response.status})`);

  const page: Page<CompanyRow> = await response.json();
  requestId = page.requestId; // after a selection reload this is the new requestId

  if (page.messages?.some((m) => m.code === "CACHE_EXPIRED_RELOADED"))
    console.warn("The selection was reloaded because the original expired; the data may have changed in the meantime.");

  page.result.forEach((c) => console.log(c.OrganizationFullName));

  if (skip + page.result.length >= page.count) break;
}

Other lists (cached = false)

For lists whose response contains cached = false, every call is evaluated again with a database query. Send the selection parameters together with Skip, Take and Sorted in every call and do not use the x-request-id header.

Limit of concurrent selections

A prepared list (cached = true) occupies memory on the server, so the number of concurrently open selections is limited to 5 per user and list. Every first call (without x-request-id) opens one selection. A selection is released:

If you have the maximum number of selections open and try to open another, the API returns 429 with the code SessionLimitExceeded, the limit and the list of open selections sessions (oldest first; for each requestId, createdAt, rowCount and expiresInSeconds). The Retry-After header tells you in how many seconds the earliest selection expires. Delete a selection you do not need and repeat the call.

Use the new requestId. If the response returns a different requestId than the one you sent (and the message CACHE_EXPIRED_RELOADED, because the original selection expired), it is a new selection and from then on send only its requestId. If you keep sending the old one, every call opens another selection, and as soon as you have five you get 429.
# open selections and the maximum allowed number
curl "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/sessions" \
  -H "Authorization: Bearer ACCESS_TOKEN"

# extend the validity of one selection
curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/sessions/REQUEST_ID/refresh" \
  -H "Authorization: Bearer ACCESS_TOKEN"

# delete one selection
curl -X DELETE "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/sessions/REQUEST_ID" \
  -H "Authorization: Bearer ACCESS_TOKEN"

# delete all selections
curl -X DELETE "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/sessions" \
  -H "Authorization: Bearer ACCESS_TOKEN"
using System.Net;
using System.Net.Http.Json;
using System.Text.Json.Nodes;

// First call of the list; when the limit is reached, it deletes the oldest open selection and repeats.
async Task<HttpResponseMessage> ListFirstPageAsync(object filter)
{
    var response = await http.PostAsJsonAsync("/api/v1/company/list", filter);
    if (response.StatusCode != HttpStatusCode.TooManyRequests) return response;

    var error = (await response.Content.ReadFromJsonAsync<JsonObject>())!;
    var oldest = error["sessions"]!.AsArray()[0]!;   // oldest first
    (await http.DeleteAsync($"/api/v1/company/sessions/{oldest["requestId"]}")).EnsureSuccessStatusCode();

    return await http.PostAsJsonAsync("/api/v1/company/list", filter);
}

// Release a selection you no longer need (after reading all pages).
await http.DeleteAsync($"/api/v1/company/sessions/{requestId}");
// First call of the list; when the limit is reached, it deletes the oldest open selection and repeats.
async function listFirstPage(filter) {
  const send = () => fetch(`${BASE}/api/v1/company/list`, {
    method: "POST",
    headers,
    body: JSON.stringify(filter),
  });

  let response = await send();
  if (response.status !== 429) return response;

  const error = await response.json();
  const oldest = error.sessions[0]; // oldest first
  await fetch(`${BASE}/api/v1/company/sessions/${oldest.requestId}`, { method: "DELETE", headers });

  response = await send();
  return response;
}

// Release a selection you no longer need (after reading all pages).
await fetch(`${BASE}/api/v1/company/sessions/${requestId}`, { method: "DELETE", headers });
interface ListSession {
  requestId: string;
  createdAt: string;
  rowCount: number;
  expiresInSeconds: number;
}

interface SessionLimitError {
  code: "SessionLimitExceeded";
  limit: number;
  sessions: ListSession[]; // oldest first
}

// First call of the list; when the limit is reached, it deletes the oldest open selection and repeats.
async function listFirstPage(filter: object): Promise<Response> {
  const send = (): Promise<Response> =>
    fetch(`${BASE}/api/v1/company/list`, { method: "POST", headers, body: JSON.stringify(filter) });

  let response = await send();
  if (response.status !== 429) return response;

  const error: SessionLimitError = await response.json();
  const oldest = error.sessions[0];
  await fetch(`${BASE}/api/v1/company/sessions/${oldest.requestId}`, { method: "DELETE", headers });

  response = await send();
  return response;
}

// Release a selection you no longer need (after reading all pages).
await fetch(`${BASE}/api/v1/company/sessions/${requestId}`, { method: "DELETE", headers });

Other lists (city, street, address, country, …) are called according to the cached field of the response, as described above; the description is also with the respective method in the documentation.

Synchronising company changes (system)

If you want to keep a copy of the companies in your system, download only the changes. The procedure consists of two calls:

  1. POST /api/v1/system/company/list_changed returns a batch of changed companies ordered by version (RowVersion). Request the first batch without LastRv; in the next request send the RowVersion of the last record of the previous batch. An empty list means that there are no more changes. The batch size (BatchSize) is 1 to 100, default 20.
  2. POST /api/v1/system/company/read_batch returns the detail of companies for the list IDS (at most 100 IDs).

A cancelled company is returned with Deleted = true; if it was replaced by another one, its ID is in ReplacedById. Store the last RowVersion; the next run starts from it.

curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/system/company/list_changed" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"LastRv":null,"BatchSize":100}'

curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/system/company/read_batch" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"IDS":[101,102,103]}'
using System.Net.Http.Json;
using System.Text.Json.Nodes;

string? lastRv = null;   // from the last run; null on the first run
while (true)
{
    var changedResponse = await http.PostAsJsonAsync("/api/v1/system/company/list_changed",
        new { LastRv = lastRv, BatchSize = 100 });
    changedResponse.EnsureSuccessStatusCode();

    var changed = (await changedResponse.Content.ReadFromJsonAsync<JsonArray>())!;
    if (changed.Count == 0) break;   // hotovo

    var ids = changed.Where(c => !(bool)c!["Deleted"]!).Select(c => (int)c!["CompanyId"]!).ToArray();
    if (ids.Length > 0)
    {
        var detailResponse = await http.PostAsJsonAsync("/api/v1/system/company/read_batch", new { IDS = ids });
        detailResponse.EnsureSuccessStatusCode();
        var details = (await detailResponse.Content.ReadFromJsonAsync<JsonArray>())!;
        // ... store details in your system
    }

    // handle cancelled companies (Deleted, possibly ReplacedById) from the records in changed
    lastRv = (string)changed[^1]!["RowVersion"]!;   // store it permanently too
}
let lastRv = null; // from the last run; null on the first run
for (;;) {
  const changedResponse = await fetch(`${BASE}/api/v1/system/company/list_changed`, {
    method: "POST",
    headers,
    body: JSON.stringify({ LastRv: lastRv, BatchSize: 100 }),
  });
  if (!changedResponse.ok) throw new Error(`list_changed failed (${changedResponse.status})`);

  const changed = await changedResponse.json();
  if (changed.length === 0) break; // hotovo

  const ids = changed.filter((c) => !c.Deleted).map((c) => c.CompanyId);
  if (ids.length > 0) {
    const detailResponse = await fetch(`${BASE}/api/v1/system/company/read_batch`, {
      method: "POST",
      headers,
      body: JSON.stringify({ IDS: ids }),
    });
    const details = await detailResponse.json();
    // ... store details in your system
  }

  // handle cancelled companies (Deleted, possibly ReplacedById) from the records in changed
  lastRv = changed[changed.length - 1].RowVersion; // store it permanently too
}
interface ChangedCompany {
  CompanyId: number;
  RowVersion: string;
  Invalidated: boolean;
  ReplacedById: number | null;
  Deleted: boolean;
}

let lastRv: string | null = null; // from the last run; null on the first run
for (;;) {
  const changedResponse: Response = await fetch(`${BASE}/api/v1/system/company/list_changed`, {
    method: "POST",
    headers,
    body: JSON.stringify({ LastRv: lastRv, BatchSize: 100 }),
  });
  if (!changedResponse.ok) throw new Error(`list_changed failed (${changedResponse.status})`);

  const changed: ChangedCompany[] = await changedResponse.json();
  if (changed.length === 0) break; // hotovo

  const ids = changed.filter((c) => !c.Deleted).map((c) => c.CompanyId);
  if (ids.length > 0) {
    const detailResponse = await fetch(`${BASE}/api/v1/system/company/read_batch`, {
      method: "POST",
      headers,
      body: JSON.stringify({ IDS: ids }),
    });
    const details: Record<string, unknown>[] = await detailResponse.json();
    // ... store details in your system
  }

  // handle cancelled companies (Deleted, possibly ReplacedById) from the records in changed
  lastRv = changed[changed.length - 1].RowVersion; // store it permanently too
}

Creating and changing companies (user)

1. Look up the data first

When creating a company, the API looks nothing up; you must pass all values already resolved. So before creating, call:

2. Creating by company type

MethodCompany type
POST /api/v1/company/create/companybusiness, with a registration number (IČ)
POST /api/v1/company/create/company-noidbusiness, without a registration number (IČ)
POST /api/v1/company/create/foreignbusiness, foreign entity
POST /api/v1/company/create/municipalitymunicipality
POST /api/v1/company/create/citizennon-business, citizen
POST /api/v1/company/create/unknownwithout a type distinction (requires a special permission)

The response (201) contains the whole record of the created company including its CompanyId. A headquarters is created with an empty or zero premises number; for premises, enter its number and the organisation identifier of the headquarters (ParentOrganization).

curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/create/company" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "CompanyRegistrationNumber": "12345678",
    "OrganizationName": "Smith and Son Ltd.",
    "VatNumber": "CZ12345678",
    "WinyxAddressId": 1001,
    "CityId": 55,
    "CityStreetId": 3021,
    "PostalCode": "11000",
    "HouseNumber": "12"
  }'
using System.Net.Http.Json;
using System.Text.Json.Nodes;

var response = await http.PostAsJsonAsync("/api/v1/company/create/company", new
{
    CompanyRegistrationNumber = "12345678",
    OrganizationName = "Smith and Son Ltd.",
    VatNumber = "CZ12345678",
    WinyxAddressId = 1001,   // AddressId from address/geography/resolve
    CityId = 55,
    CityStreetId = 3021,
    PostalCode = "11000",
    HouseNumber = "12",
});

if (response.IsSuccessStatusCode)
{
    var company = (await response.Content.ReadFromJsonAsync<JsonObject>())!;
    Console.WriteLine($"Company created {company["CompanyId"]}");
}
// 409 with ConfirmationRequired: see the chapter Errors and confirmation
const response = await fetch(`${BASE}/api/v1/company/create/company`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    CompanyRegistrationNumber: "12345678",
    OrganizationName: "Smith and Son Ltd.",
    VatNumber: "CZ12345678",
    WinyxAddressId: 1001, // AddressId from address/geography/resolve
    CityId: 55,
    CityStreetId: 3021,
    PostalCode: "11000",
    HouseNumber: "12",
  }),
});

if (response.ok) {
  const company = await response.json();
  console.log(`Company created ${company.CompanyId}`);
}
// 409 with ConfirmationRequired: see the chapter Errors and confirmation
interface NewCompany {
  CompanyRegistrationNumber: string;
  OrganizationName: string;
  VatNumber?: string;
  WinyxAddressId?: number;
  CityId?: number;
  CityStreetId?: number;
  PostalCode?: string;
  HouseNumber?: string;
}

const newCompany: NewCompany = {
  CompanyRegistrationNumber: "12345678",
  OrganizationName: "Smith and Son Ltd.",
  VatNumber: "CZ12345678",
  WinyxAddressId: 1001, // AddressId from address/geography/resolve
  CityId: 55,
  CityStreetId: 3021,
  PostalCode: "11000",
  HouseNumber: "12",
};

const response = await fetch(`${BASE}/api/v1/company/create/company`, {
  method: "POST",
  headers,
  body: JSON.stringify(newCompany),
});

if (response.ok) {
  const company: { CompanyId: number } = await response.json();
  console.log(`Company created ${company.CompanyId}`);
}
// 409 with ConfirmationRequired: see the chapter Errors and confirmation

3. Change and removal

# read, edit (in company.json) and send the whole record
curl "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company?CompanyId=101" \
  -H "Authorization: Bearer ACCESS_TOKEN" -o company.json

curl -X PUT "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company?CompanyId=101" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  --data-binary @company.json
using System.Net.Http.Json;
using System.Text.Json.Nodes;

var company = (await http.GetFromJsonAsync<JsonObject>("/api/v1/company?CompanyId=101"))!;
company["Note"] = "New note";   // change what you need

var response = await http.PutAsJsonAsync("/api/v1/company?CompanyId=101", company);   // the whole record
response.EnsureSuccessStatusCode();
const getResponse = await fetch(`${BASE}/api/v1/company?CompanyId=101`, { headers });
const company = await getResponse.json();
company.Note = "New note"; // change what you need

const response = await fetch(`${BASE}/api/v1/company?CompanyId=101`, {
  method: "PUT",
  headers,
  body: JSON.stringify(company), // the whole record
});
if (!response.ok) throw new Error(`Update failed (${response.status})`);
type Company = { CompanyId: number } & Record<string, unknown>;

const getResponse = await fetch(`${BASE}/api/v1/company?CompanyId=101`, { headers });
const company: Company = await getResponse.json();
company.Note = "New note"; // change what you need

const response = await fetch(`${BASE}/api/v1/company?CompanyId=101`, {
  method: "PUT",
  headers,
  body: JSON.stringify(company), // the whole record
});
if (!response.ok) throw new Error(`Update failed (${response.status})`);

Errors and confirmation

Errors always have the same form (application/problem+json). The code field is for processing in your application, title and detail can be shown to the user, quote traceId when reporting a problem. For invalid data, issues contains the individual errors together with the field they concern (field).

Language of the texts. The texts of errors and warnings (title, detail, issues[].text, warnings[].text) are in Czech by default. If you send the Accept-Language: en header (or x-language: en, which takes precedence), they are returned in English; a text without a translation stays in Czech. The codes (code) and field names do not depend on the language, so use them to tell errors apart in your application. The complete list of codes and texts is on the page Error and warning codes.

StatusMeaningWhat to do
400invalid request or datacorrect the data according to issues; it cannot be confirmed
401missing or invalid tokensign in again or refresh the token
403missing permissionask the administrator for the permission
404the record does not existcheck the identifier
409the record already exists, cannot be removed, or confirmation is requiredsee below
429the maximum allowed number of list selections is opendelete a selection you do not need (see the chapter Lists) and repeat the call
500server-side errortry again; if it repeats, report the traceId

Confirming warnings

Some operations (creating or changing a company) find a warning that the user can confirm – for example another company with the same registration number (IČ) or VAT number (DIČ). The operation is then not carried out and the API returns 409 with the code ConfirmationRequired:

{
  "status": 409,
  "code": "ConfirmationRequired",
  "warnings": [ { "code": "DuplicateRegistrationNumber", "text": "A company with the same registration number already exists." } ],
  "confirmationToken": "…",
  "confirmationTokenExpiresAt": "2026-10-07T12:30:00Z"
}
  1. Show the warnings to the user.
  2. If they agree, send exactly the same request again and add the token to the X-Confirmation-Token header.
  3. The token is valid for a limited time (10 minutes by default), only for this data and only for you. If the data changes or another warning is found, the API returns 409 again with a new token – repeat the procedure.
# the same request as before, plus the token header
curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/company/create/company" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -H "X-Confirmation-Token: CONFIRMATION_TOKEN" \
  -d @newcompany.json
using System.Net;
using System.Net.Http.Json;
using System.Text.Json.Nodes;

async Task<HttpResponseMessage> CreateAsync(JsonObject body, Func<JsonArray, bool> userConfirms)
{
    string? token = null;
    while (true)
    {
        using var request = new HttpRequestMessage(HttpMethod.Post, "/api/v1/company/create/company")
        {
            Content = JsonContent.Create(body),
        };
        if (token is not null) request.Headers.Add("X-Confirmation-Token", token);

        var response = await http.SendAsync(request);
        if (response.StatusCode != HttpStatusCode.Conflict) return response;

        var error = (await response.Content.ReadFromJsonAsync<JsonObject>())!;
        if ((string?)error["code"] != "ConfirmationRequired") return response;   // a different 409

        if (!userConfirms(error["warnings"]!.AsArray())) return response;        // the user does not agree
        token = (string)error["confirmationToken"]!;                              // repeat with the same data
    }
}
async function createCompany(body, userConfirms) {
  let token = null;
  for (;;) {
    const response = await fetch(`${BASE}/api/v1/company/create/company`, {
      method: "POST",
      headers: token ? { ...headers, "X-Confirmation-Token": token } : headers,
      body: JSON.stringify(body),
    });
    if (response.status !== 409) return response;

    const error = await response.json();
    if (error.code !== "ConfirmationRequired") return response; // a different 409

    if (!(await userConfirms(error.warnings))) return response; // the user does not agree
    token = error.confirmationToken; // repeat with the same data
  }
}
interface ApiWarning {
  code: string;
  text: string;
}

interface ApiError {
  code?: string;
  warnings?: ApiWarning[];
  confirmationToken?: string;
}

async function createCompany(
  body: object,
  userConfirms: (warnings: ApiWarning[]) => Promise<boolean>,
): Promise<Response> {
  let token: string | null = null;
  for (;;) {
    const response: Response = await fetch(`${BASE}/api/v1/company/create/company`, {
      method: "POST",
      headers: token ? { ...headers, "X-Confirmation-Token": token } : headers,
      body: JSON.stringify(body),
    });
    if (response.status !== 409) return response;

    const error: ApiError = await response.json();
    if (error.code !== "ConfirmationRequired") return response; // a different 409

    if (!(await userConfirms(error.warnings ?? []))) return response; // the user does not agree
    token = error.confirmationToken ?? null; // repeat with the same data
  }
}

Importing calculations (user)

POST /api/v1/calculation/import imports the calculation of one plant: the header and three blocks of rows (WasteRows – waste, SecondaryRows – secondary raw materials, ServiceRows – other services). The number of rows is not limited.

curl -X POST "https://{CompanyName}.api.ros.bclogia.cz/api/v1/calculation/import" \
  -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "CompanyRegistrationNumber": "12345678",
    "PeriodFrom": "2026-01-01",
    "PeriodTo": "2026-12-31",
    "Abc": "B",
    "Division": "Bohemia",
    "Plant": "Pardubice",
    "WasteRows": [
      { "WasteID": 1503, "ActivityCode": 110, "Unit": "t", "QtyPerPickup": 0.1, "PickupsPerPeriod": 12, "DisposalPerUnit": 3295, "RevPerUnit": 13650 }
    ],
    "SecondaryRows": [],
    "ServiceRows": [
      { "Item": "Training", "Unit": "ks", "QtyPerPeriod": 2, "CostPerUnit": 1200, "RevPerUnit": 2000 }
    ]
  }'
using System.Net.Http.Json;
using System.Text.Json.Nodes;

var response = await http.PostAsJsonAsync("/api/v1/calculation/import", new
{
    CompanyRegistrationNumber = "12345678",
    PeriodFrom = "2026-01-01",
    PeriodTo = "2026-12-31",
    Abc = "B",
    Division = "Bohemia",
    Plant = "Pardubice",
    WasteRows = new[]
    {
        new { WasteID = 1503, ActivityCode = 110, Unit = "t", QtyPerPickup = 0.1m, PickupsPerPeriod = 12m, DisposalPerUnit = 3295m, RevPerUnit = 13650m },
    },
    SecondaryRows = Array.Empty<object>(),
    ServiceRows = new[]
    {
        new { Item = "Training", Unit = "ks", QtyPerPeriod = 2m, CostPerUnit = 1200m, RevPerUnit = 2000m },
    },
});
response.EnsureSuccessStatusCode();

var result = (await response.Content.ReadFromJsonAsync<JsonObject>())!;
Console.WriteLine($"Calculation {result["CalculationId"]}, replaced: {result["Replaced"]}");
const response = await fetch(`${BASE}/api/v1/calculation/import`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    CompanyRegistrationNumber: "12345678",
    PeriodFrom: "2026-01-01",
    PeriodTo: "2026-12-31",
    Abc: "B",
    Division: "Bohemia",
    Plant: "Pardubice",
    WasteRows: [
      { WasteID: 1503, ActivityCode: 110, Unit: "t", QtyPerPickup: 0.1, PickupsPerPeriod: 12, DisposalPerUnit: 3295, RevPerUnit: 13650 },
    ],
    SecondaryRows: [],
    ServiceRows: [
      { Item: "Training", Unit: "ks", QtyPerPeriod: 2, CostPerUnit: 1200, RevPerUnit: 2000 },
    ],
  }),
});
if (!response.ok) throw new Error(`Import failed (${response.status})`);

const result = await response.json();
console.log(`Kalkulace ${result.CalculationId}, replaced: ${result.Replaced}`);
interface WasteRow {
  WasteID: number;
  ActivityCode?: number;
  Unit?: string;
  QtyPerPickup?: number;
  PickupsPerPeriod?: number;
  DisposalPerUnit?: number;
  RevPerUnit?: number;
}

interface ServiceRow {
  Item?: string;
  Unit?: string;
  QtyPerPeriod?: number;
  CostPerUnit?: number;
  RevPerUnit?: number;
}

interface CalculationImport {
  CompanyRegistrationNumber: string;
  PeriodFrom: string; // yyyy-mm-dd
  PeriodTo: string;
  Abc?: "A" | "B" | "C";
  Division?: string;
  Plant?: string;
  WasteRows: WasteRow[];
  SecondaryRows: object[];
  ServiceRows: ServiceRow[];
}

const calculation: CalculationImport = {
  CompanyRegistrationNumber: "12345678",
  PeriodFrom: "2026-01-01",
  PeriodTo: "2026-12-31",
  Abc: "B",
  Division: "Bohemia",
  Plant: "Pardubice",
  WasteRows: [
    { WasteID: 1503, ActivityCode: 110, Unit: "t", QtyPerPickup: 0.1, PickupsPerPeriod: 12, DisposalPerUnit: 3295, RevPerUnit: 13650 },
  ],
  SecondaryRows: [],
  ServiceRows: [
    { Item: "Training", Unit: "ks", QtyPerPeriod: 2, CostPerUnit: 1200, RevPerUnit: 2000 },
  ],
};

const response = await fetch(`${BASE}/api/v1/calculation/import`, {
  method: "POST",
  headers,
  body: JSON.stringify(calculation),
});
if (!response.ok) throw new Error(`Import failed (${response.status})`);

const result: { CalculationId: number; Replaced: boolean } = await response.json();
console.log(`Kalkulace ${result.CalculationId}, replaced: ${result.Replaced}`);

The description of all fields is in the documentation of the user interface (field descriptions are in Czech and mirror the captions in WinyX).