Units

Get Units

curl "https://example.ziik.io/api/units"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
[{
    "id": 12,
    "name": "Main Office",
    "description": "",
    "image": [],
    "relationships": {
    },
    "parent": null,
    "selectable": true,
    "unit_type": 1,
    "departments": [],
    "unit": {
        "registration_number": "12345678",
        "vat_number": "DK12345678-01",
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "phone": "+45 3030 1808",
        "email": "info@ziik.dk"
    },
    "delivery": {
        "use_unit_address": true,
        "company": null,
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "phone": "+45 3030 1808",
        "contact": {
            "name": null,
            "phone": null
        },
        "comments": null
    },
    "invoicing": {
        "use_unit_address": true,
        "registration_number": "12345678",
        "vat_number": "DK12345678-01",
        "company": null,
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "comments": null
    },
    "opening_hours": {
        "office_hours": [{
            "day": "1",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "2",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "3",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "4",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "5",
            "starthours": "900",
            "endhours": "1700"
        }],
        "closed": [{
            "start": 1473042600,
            "end": 1473134400
        }]
    },
    "features": [{
        "id": 175,
        "name": "Firstline support",
        "url": "api/units/features/175"
    }, {
        "id": 178,
        "name": "Secondline support",
        "url": "api/units/features/178"
    }],
    "permissions": {
        "edit": true,
        "delete": true
    },
    "url": "api/units/12"
}, {
    "id": 127,
    "name": "Ziik Sweden",
    "description": "",
    "image": [{
        "id": 456,
        "name": "office.jpg",
        "mime": "image/jpeg",
        "size": 18342,
        "type": "image",
        "source": "https://example.ziik.io/api/file/example/office.jpg",
        "versions": {
            "listing": "https://example.ziik.io/sites/default/files/example/styles/article_listing/public/office.jpg",
            "detail": "https://example.ziik.io/sites/default/files/example/styles/article_desktop/public/office.jpg",
            "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/manuals/filename.png"
        }
    }],
    "relationships": [],
    "parent": {
        "id": 1
        "leaf": false,
        "level": 0,
        "name": "Main office",
        "url": "api/units/1"
    },
    "unit": {
        "registration_number": null,
        "vat_number": null,
        "street": "Mässans gata 18, 5tr",
        "street_additional": "World Trade Center, Box 5243",
        "postal_code": "402 24 ",
        "city": "Göteborg",
        "phone": "+46 (0)111 22 33 44",
        "email": "info@ziik.se"
    },
    "delivery": {
        "use_unit_address": true,
        "company": null,
        "street": "Mässans gata 18, 5tr",
        "street_additional": "World Trade Center, Box 5243",
        "postal_code": "402 24 ",
        "city": "Göteborg",
        "phone": "+46 (0)707 31 93 50",
        "contacts": [{
            "name": "Teodor Trygg",
            "phone": "+46 (0)111 22 33 44"
        }],
        "comments": null
    },
    "invoicing": {
        "use_unit_address": false,
        "registration_number": "1111",
        "vat_number": "1111",
        "company": null,
        "street": "Mässans gata 18, 6tr",
        "street_additional": "World Trade Center, Box 5243",
        "postal_code": "402 24 ",
        "city": "Göteborg",
        "comments": null
    },
    "opening_hours": {
        "office_hours": [{
            "day": "1",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "2",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "3",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "4",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "5",
            "starthours": "900",
            "endhours": "1700"
        }],
        "closed": []
    },
    "features": [],
    "permissions": {
        "edit": true,
        "delete": true
    },
    "url": "api/units/127"
}]

This endpoint retrieves all units.

HTTP Request

GET https://example.ziik.io/api/units

Query Parameters

ParameterTypeDefaultDescription
userBooleanfalseFilter units to contain only user's unit or below

Each unit has a "departments" attribute, which can be an array of Unit objects.

Get Single Unit

curl "https://example.ziik.io/api/units/12"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"

The above command returns JSON structured like this:

{
    "id": 12,
    "name": "Main Office",
    "description": "",
    "image": [],
    "relationships": {},
    "parent": null,
    "selectable": true,
    "unit_type": 1,
    "departments": [],
    "unit": {
        "registration_number": "12345678",
        "vat_number": "DK12345678-01",
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "phone": "+45 3030 1808",
        "email": "info@ziik.dk"
    },
    "delivery": {
        "use_unit_address": true,
        "company": null,
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "phone": "+45 3030 1808",
        "contact": {
            "name": null,
            "phone": null
        },
        "comments": null
    },
    "invoicing": {
        "use_unit_address": true,
        "registration_number": "12345678",
        "vat_number": "DK12345678-01",
        "company": null,
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "comments": null
    },
    "opening_hours": {
        "office_hours": [{
            "day": "1",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "2",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "3",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "4",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "5",
            "starthours": "900",
            "endhours": "1700"
        }],
        "closed": [{
            "start": 1473042600,
            "end": 1473134400
        }]
    },
    "features": [{
        "id": 175,
        "name": "Firstline support",
        "url": "api/units/features/175"
    }, {
        "id": 178,
        "name": "Secondline support",
        "url": "api/units/features/178"
    }],
    "permissions": {
        "edit": true,
        "delete": true
    },
    "url": "api/units/12"
}

This endpoint returns a single unit

HTTP Request

GET https://example.ziik.io/api/units/ID

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the unit

The "departments" attribute can be an array of Unit objects.

Create Unit

curl -i -X POST "https://example.ziik.io/api/units"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 201 Created with a location header for where to find the newly created unit

HTTP/1.0 201 Created
Location: https://example.ziik.io/api/units/1234
{
    "message": "Unit created"
}

This endpoint creates a new unit.

HTTP Request

POST https://example.ziik.io/api/units

Request Parameters

ParameterTypeRequiredDescription
nameStringYesUnit name.
descriptionStringNoUnit description.
parentIntegerYesID of unit that should be the parent in the unit hierarchy
unit_typeIntegerNoNormal = 0, Group = 1, Department = 2. Default = 0.
unitArrayNoArray of unit information with the following parameters
- registration_numberStringNoCompany registration number
- vat_numberStringNoVAT number for company
- streetStringNoStreet address
- street_additionalStringNoAdditional street address information
- postal_codeStringNoPostal/Zip code
- cityStringNoCity name
- phoneStringNoMain phone number
- emailStringNoMain contact email
deliveryArrayNoArray of delivery information with the following parameters
- use_unit_addressBooleanNoWhether delivery address is the same as unit address
- companyStringNoAlternative name for deliveries
- streetStringNoDelivery street address
- street_additionalStringNoAdditional street address information
- postal_codeStringNoPostal/Zip code
- cityStringNoCity name
- phoneStringNoMain phone number for delivery
- contactArrayNoContact information regarding deliveries
- - nameStringNoContact name
- - phoneStringNoPhone number for delivery contact
- commentsStringNoAny comments when delivering to this unit
invoicingArrayNoArray of invoicing information with the following parameters
- use_unit_addressBooleanNoWhether invoicing address is the same as unit address
- registration_numberStringNoInvoicing registration number
- vat_numberStringNoInvoicing VAT number
- companyStringNoAlternative name for invoicing
- streetStringNoInvoicing street address
- street_additionalStringNoAdditional street address information re. invoicing
- postal_codeStringNoPostal code for invoicing address
- cityStringNoCity name for invoicing
- commentsStringNoComments regarding invoicing
featuresArrayNoArray of unit feature IDs to describe the unit
imageArrayNoFile data for an image for the unit. If provided, must be an array of arrays with the following values
- typeStringYesType of file - can be either 'upload', 'youtube' or 'vimeo'.
- nameStringYesFile name.
- dataStringYesIf type is 'upload' this must be the base64 encoded content of the file. Else it must be the Youtube/Vimeo embed URL.
opening_hoursArrayNoInformation regarding when the unit is open/closed. Array with the following values
- office_hoursArrayNoArrays for each weekday with the normal business hours, each having the following values
- - dayIntegerYesWeekday (1 = monday, 5 = friday, 7 = sunday)
- - starthoursIntegerYesTime of day of opening in military time (9 AM = 900, 6 PM = 1800)
- - endhoursIntegerYesTime of day of closing, also in military time
- closedArrayNoArrays of periods, where the unit is closed, each with the following values
- - startIntegerYesUnix timestamp of when closing period starts
- - endIntegerYesUnix timestamp of when closing period ends

Permissions Required

  • Administer permission to units

Edit Unit

curl -i -X PATCH "https://example.ziik.io/api/units/123"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on successful update.

HTTP/1.0 204 No Content

This endpoint updates an existing unit.

HTTP Request

PATCH https://example.ziik.io/api/units/ID

Request Parameters

ParameterTypeRequiredDescription
nameStringNoUnit name.
descriptionStringNoUnit description.
parentIntegerNoID of new parent unit
unit_typeIntegerNoNormal = 0, Group = 1, Department = 2.
unitArrayNoArray of unit information with the following parameters
- registration_numberStringNoCompany registration number
- vat_numberStringNoVAT number for company
- streetStringNoStreet address
- street_additionalStringNoAdditional street address information
- postal_codeStringNoPostal/Zip code
- cityStringNoCity name
- phoneStringNoMain phone number
- emailStringNoMain contact email
deliveryArrayNoArray of delivery information with the following parameters
- use_unit_addressBooleanNoWhether delivery address is the same as unit address
- companyStringNoAlternative name for deliveries
- streetStringNoDelivery street address
- street_additionalStringNoAdditional street address information
- postal_codeStringNoPostal/Zip code
- cityStringNoCity name
- phoneStringNoMain phone number for delivery
- contactArrayNoContact information regarding deliveries
- - nameStringNoContact name
- - phoneStringNoPhone number for delivery contact
- commentsStringNoAny comments when delivering to this unit
invoicingArrayNoArray of invoicing information with the following parameters
- use_unit_addressBooleanNoWhether invoicing address is the same as unit address
- registration_numberStringNoInvoicing registration number
- vat_numberStringNoInvoicing VAT number
- companyStringNoAlternative name for invoicing
- streetStringNoInvoicing street address
- street_additionalStringNoAdditional street address information re. invoicing
- postal_codeStringNoPostal code for invoicing address
- cityStringNoCity name for invoicing
- commentsStringNoComments regarding invoicing
featuresArrayNoArray of unit feature IDs to describe the unit
imageArrayNoFile data for an image for the unit. If provided, must be an array of arrays with the following values
- typeStringYesType of file - can be either 'upload', 'youtube' or 'vimeo'.
- nameStringYesFile name.
- dataStringYesIf type is 'upload' this must be the base64 encoded content of the file. Else it must be the Youtube/Vimeo embed URL.
opening_hoursArrayNoInformation regarding when the unit is open/closed. Array with the following values
- office_hoursArrayNoArrays for each weekday with the normal business hours, each having the following values
- - dayIntegerYesWeekday (1 = monday, 5 = friday, 7 = sunday)
- - starthoursIntegerYesTime of day of opening in military time (9 AM = 900, 6 PM = 1800)
- - endhoursIntegerYesTime of day of closing, also in military time
- closedArrayNoArrays of periods, where the unit is closed, each with the following values
- - startIntegerYesUnix timestamp of when closing period starts
- - endIntegerYesUnix timestamp of when closing period ends

Permissions Required

  • Edit permission to units

Delete Unit

curl -i -X DELETE "https://example.ziik.io/api/units/123"
  -H "Authorization: Bearer aaaaaa.bbbbbbb.ccccccc"

The above command returns a 204 No Content header on success:

HTTP/1.0 204 No Content

This endpoint deletes a unit.

HTTP Request

DELETE https://example.ziik.io/api/units/ID

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the unit to delete

Permissions Required

  • Administer permission to units

Get Units Below In Hierarchy

curl "https://example.ziik.io/api/units/123/children"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
[{
    "id": 12,
    "name": "Main Office",
    "description": "",
    "image": [],
    "relationships": null,
    "unit": {
        "registration_number": "12345678",
        "vat_number": "DK12345678-01",
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "phone": "+45 3030 1808",
        "email": "info@ziik.dk"
    },
    "delivery": {
        "use_unit_address": true,
        "company": null,
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "phone": "+45 3030 1808",
        "contact": {
            "name": null,
            "phone": null
        },
        "comments": null
    },
    "invoicing": {
        "use_unit_address": true,
        "registration_number": "12345678",
        "vat_number": "DK12345678-01",
        "company": null,
        "street": "Nørre Voldgade 18, 1.",
        "street_additional": null,
        "postal_code": "1358",
        "city": "Copenhagen K",
        "comments": null
    },
    "opening_hours": {
        "office_hours": [{
            "day": "1",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "2",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "3",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "4",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "5",
            "starthours": "900",
            "endhours": "1700"
        }],
        "closed": [{
            "start": 1473042600,
            "end": 1473134400
        }]
    },
    "features": [{
        "id": 175,
        "name": "Firstline support",
        "url": "api/units/features/175"
    }, {
        "id": 178,
        "name": "Secondline support",
        "url": "api/units/features/178"
    }],
    "permissions": {
        "edit": true,
        "delete": true
    },
    "url": "api/units/12"
}, {
    "id": 127,
    "name": "Ziik Sweden",
    "description": "",
    "image": [{
        "id": 456,
        "name": "office.jpg",
        "mime": "image/jpeg",
        "size": 18342,
        "type": "image",
        "source": "https://example.ziik.io/api/file/example/office.jpg",
        "versions": {
            "listing": "https://example.ziik.io/sites/default/files/example/styles/article_listing/public/office.jpg",
            "detail": "https://example.ziik.io/sites/default/files/example/styles/article_desktop/public/office.jpg",
            "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/manuals/filename.png"
        }
    }],
    "relationships": null,
    "unit": {
        "registration_number": null,
        "vat_number": null,
        "street": "Mässans gata 18, 5tr",
        "street_additional": "World Trade Center, Box 5243",
        "postal_code": "402 24 ",
        "city": "Göteborg",
        "phone": "+46 (0)111 22 33 44",
        "email": "info@ziik.se"
    },
    "delivery": {
        "use_unit_address": true,
        "company": null,
        "street": "Mässans gata 18, 5tr",
        "street_additional": "World Trade Center, Box 5243",
        "postal_code": "402 24 ",
        "city": "Göteborg",
        "phone": "+46 (0)707 31 93 50",
        "contacts": [{
            "name": "Teodor Trygg",
            "phone": "+46 (0)111 22 33 44"
        }],
        "comments": null
    },
    "invoicing": {
        "use_unit_address": false,
        "registration_number": "1111",
        "vat_number": "1111",
        "company": null,
        "street": "Mässans gata 18, 6tr",
        "street_additional": "World Trade Center, Box 5243",
        "postal_code": "402 24 ",
        "city": "Göteborg",
        "comments": null
    },
    "opening_hours": {
        "office_hours": [{
            "day": "1",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "2",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "3",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "4",
            "starthours": "900",
            "endhours": "1700"
        }, {
            "day": "5",
            "starthours": "900",
            "endhours": "1700"
        }],
        "closed": []
    },
    "features": [],
    "permissions": {
        "edit": true,
        "delete": true
    },
    "url": "api/units/127"
}]

This endpoint retrieves all units below a given unit.

HTTP Request

GET https://example.ziik.io/api/units/ID/children

URL Parameters

ParameterTypeDescription
IDIntegerUnit ID to fetch children for

Add Image To Unit

curl -i -X POST "https://example.ziik.io/api/units/image"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on success

HTTP/1.0 204 No Content

This endpoint adds an image to a unit.

HTTP Request

POST https://example.ziik.io/api/units/image

Request Parameters

ParameterTypeDescription
idIntegerThe ID of the unit to add files to
imageArrayNo
- typeStringYes
- nameStringYes
- dataStringYes

Permissions Required

  • Unit edit access

Delete Image From Unit

curl -i -X DELETE "https://example.ziik.io/api/units/123/files/12345"
  -H "Authorization: Bearer aaaaaa.bbbbbbb.ccccccc"

The above command returns a 204 No Content header on success:

HTTP/1.0 204 No Content

This endpoint deletes an image from a unit.

HTTP Request

DELETE https://example.ziik.io/api/units/<UnitID>/files/<FileID>

URL Parameters

ParameterTypeDescription
UnitIDIntegerThe ID of the unit
FileIDIntegerThe ID of the file to delete

Permissions Required

  • Unit edit access