Skip to main content

Tags

Working with tags in the REST API

Written by Lenka Haringerová

Throughout the ABRA Flexi system, support for tags has been added. These allow you to attach a status to various objects (e.g., documents, address book, order, …) or even to various states (e.g., payment method, etc.). This way, you can react in a connected system to a situation where an invoice is paid using a method that has a tag (e.g., use a method in an e-shop).

⚠️ If you want to assign a tag to a record, it must first be created in the tag list. Referencing a tag that has not been created will result in an error 400 for the stitky property.


Deleting / updating tags

Working with tags is a bit different, since it is a relation that is emulated as an item. To delete tags or update them, you need to use the removeAll="true" attribute:

<?xml version="1.0"?>
<winstrom version="1.0">
<adresar>
<id>14</id>
<stitky removeAll="true"/>
</adresar>
</winstrom>

The XML above will remove all tags from the specified record in the address book.

To update tags, simply provide a new list of values in the stitky element:

<stitky removeAll="true">STITEK1,NOVY_STITEK</stitky>

or in JSON:

"stitky@removeAll": "true",
"stitky": "STITEK1,NOVY_STITEK"

ℹ️ Without specifying the removeAll="true" attribute, only adding non-existing tags will be performed — existing tags will remain. If you want to actually replace the list, include the attribute.


Exporting a tag group

You can organize tags into tag groups. These then allow for better processing during export. If you set for a group that a document can contain only one tag, the other tags from the same group will be deleted. This makes it easy to emulate the status of a document — the object will always contain only one tag from a group that allows only a single tag.

/c/{firma}/{evidence}.xml?skupina-stitku=SKUPINA1,SKUPINA2

The output might then look like this:

<winstrom>
...
<faktura-vydana>
...
<stitky SKUPINA1="STITEK1" SKUPINA2="STITEK2">STITEK1,STITEK2,STITEK3</stitky>
...
</faktura-vydana>
</winstrom>

💡 Using the ?stitky-as-ids=true parameter, tags can be exported and imported as a list of numeric IDs instead of codes — see Building URLs.


Related

Did this answer your question?