Create or link chain
const url = 'https://sender.sandbox-api.kivra.com/dr/v1/chains';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"Demo chain","vat":"SE555555555501","address":{"street1":"Gatan 1","postalcode":"13254","city":"onebuying","country":"SWE"},"icon":{"data":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=","content_type":"image/png"},"item_display_fields":["article_number_pos"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://sender.sandbox-api.kivra.com/dr/v1/chains \ --header 'Content-Type: application/json' \ --data '{ "name": "Demo chain", "vat": "SE555555555501", "address": { "street1": "Gatan 1", "postalcode": "13254", "city": "onebuying", "country": "SWE" }, "icon": { "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=", "content_type": "image/png" }, "item_display_fields": [ "article_number_pos" ] }'Creates a chain or links to an existing chain.
Access scope
- PARTNER
Matching
To determine if this is an existing chain the following fields need to match
- name
- vat
It is only possible to create one chain per VAT number.
Validation rules
- Either
vatorexternal_id(or both) must be provided - A chain cannot have bothretained_activatedandgreenbin_activatedset to true - The partner must have the respective feature activated before a chain can activate it
Activation defaults
If neither retained_activated nor greenbin_activated is provided in the request, the chain will inherit the activation setting from the partner. If the partner has retained receipts enabled (e.g. via send-to-all), the chain will have retained_activated set to true by default. To opt out, explicitly set retained_activated to false.
If only one of the two fields is provided, the omitted field defaults to false.
Request Bodyrequired
Section titled “Request Bodyrequired”Takes in a chain object with required information to create a new chain
object
External identifier for the chain, unique per partner
The name of the chain
The VAT number of the chain
The phone number of the store
The address of the store
object
Icon displayed on the receipt
object
Base64 encoded image
The image content type
Logo displayed on the receipt
object
Base64 encoded image
The image content type
The extra fields from receipt items that should be displayed in the app
Whether retained receipts are activated for this chain. If omitted along with greenbin_activated, defaults to the partner’s setting. If the other field is provided but this one is omitted, defaults to false.
object
External identifier for the chain, unique per partner
The name of the chain
The VAT number of the chain
The phone number of the store
The address of the store
object
Icon displayed on the receipt
object
Base64 encoded image
The image content type
Logo displayed on the receipt
object
Base64 encoded image
The image content type
The extra fields from receipt items that should be displayed in the app
Whether retained receipts are activated for this chain. If omitted along with greenbin_activated, defaults to the partner’s setting. If the other field is provided but this one is omitted, defaults to false.
Examples
Create chain with VAT
{ "name": "Demo chain", "vat": "SE555555555501", "address": { "street1": "Gatan 1", "postalcode": "13254", "city": "onebuying", "country": "SWE" }, "icon": { "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=", "content_type": "image/png" }, "item_display_fields": [ "article_number_pos" ]}Create chain with external_id
{ "name": "Demo chain", "external_id": "abc123def45", "address": { "street1": "Gatan 1", "postalcode": "13254", "city": "onebuying", "country": "SWE" }}Responses
Section titled “Responses”Chain already exists
object
Example
{ "chain_id": "15594097555922f97bfeb148d6b9a6ef76f76ebdce", "vat": 55555, "created": false}Chain successfully created
object
Example
{ "chain_id": "15594097555922f97bfeb148d6b9a6ef76f76ebdce", "vat": 55555, "created": true}Bad request
object
Examples
{ "error_code": "40000", "short_message": "bad request", "long_message": "body is missing required fields or has invalid fields"}{ "error_code": "40002", "short_message": "bad request", "long_message": "unsupported content type header"}Unauthorized
object
Examples
{ "error_code": "40100", "short_message": "unauthorized", "long_message": "permission denied"}Not found
object
Examples
{ "error_code": "40400", "short_message": "not found", "long_message": "the requested resource could not be found"}Conflict
object
Examples
{ "error_code": "40900", "short_message": "conflict", "long_message": "company with the given vat exists"}Internal server error
object
Example
{ "error_code": "50000", "short_message": "internal server error", "long_message": "unknown error ocurred"}