Skip to main content

API: Detach / Attach a Company

How do I detach or attach a company using the API?

Written by Alexander Pečeňák

When integrating ABRA Flexi via the API, you may need to connect a company to the instance (that is, make it available to users) or, conversely, disconnect and hide it. The /c/ and /c-all/ endpoints are used for this.


When to use /c/ and when to use /c-all/

Endpoint

What it works with

/c/

Connected companies only.

/c-all/

All companies, including disconnected ones.

If you need to connect or disconnect a company, therefore, always use /c-all/.

🚨 You can no longer reach a disconnected company through /c/. Any request for its data returns 404 with code firmaNeexistuje and the message Company … does not exist. It can therefore be reconnected only through /c-all/. The data remains untouched in the database.


Connecting and disconnecting a company

URL

PUT https://demo.flexibee.eu/c-all/{firma}

The supported methods are PUT and POST. A successful operation returns 201 with an empty body.

JSON

{
"show": true,
"name": "název firmy v Centrální databázi",
"licenseGroup": "id_licencni_skupiny"
}

XML

<companyInfo>
<show>true</show>
<name>Název firmy</name>
<licenseGroup>id_licencni_skupiny</licenseGroup>
</companyInfo>

What do the individual values mean?

Key

Description

show

true = the company will be connected and visible, false = the company will be disconnected.

name

Any name; it is displayed in the central database.

licenseGroup

The ID of the license group the company runs under. It must be an existing group; otherwise the request fails with the error 400 and code licenseGroupNotFound.

None of the keys are required. Values you omit remain unchanged, so to simply connect or disconnect a company, it is enough to send just show. Unknown keys are silently ignored.

ℹ️ You can find a valid license group ID in the company list. For each company, GET /c-all.json returns not only show but also licenseGroup, dbNazev, nazev, stavEnum, and createDt.


Examples

Connecting a company

I want the company to be available in the company selection:

PUT https://demo.flexibee.eu/c-all/moje_firma

{
"show": true,
"name": "Moje firma s.r.o.",
"licenseGroup": "1"
}

Disconnecting a company

The company remains in the database but will not be visible in the company selection:

PUT https://demo.flexibee.eu/c-all/moje_firma

{
"show": false
}

A disconnected company disappears from the GET /c.json list, but it remains in GET /c-all.json with the show value set to false.


Error states

Status

Error code

Cause

404

firmaNeexistuje

The company's database identifier does not exist, or the company is disconnected and you used /c/ instead of /c-all/.

400

licenseGroupNotFound

The specified license group does not exist.

⚠️ This endpoint has no format extension, so errors are returned as an HTML page. You will receive a machine-readable response with messageCode if you include the Accept: application/json header (or application/xml) in the request.


Summary

  • To manage companies in the central database, use the /c-all/ endpoint, because it also works with disconnected companies.

  • You connect or disconnect a company by setting the show value.

  • Both JSON and XML formats are supported.


Related

Did this answer your question?