Learn how to keep your sites up to date through the Expansive API
Partial hydration
The Expansive API is set up to hydrate missing fields on records by default, this means you don't need to PATCH the full record and instead can just send a subset of the fields that you want to change.
Resource
/v2/sites/<id>
Method
PATCH
Headers
Key | Value |
Authorization | Bearer <TOKEN> (find out more) |
Content-Type | application/vnd.api+json |
Body
Example: disable a site
{
"data": {
"type": "sites",
"id": "1",
"attributes": {
"enabled": false
}
}
}
Example: change a site's reference
{
"data": {
"type": "sites",
"id": "1",
"attributes": {
"reference": "new reference"
}
}
}
Example: update multiple fields
{
"data": {
"type": "sites",
"id": "1",
"attributes": {
"reference": "new reference",
"enabled": false
}
}
}
Example: updating a relationship, i.e. the site's currency
{
"data": {
"type": "sites",
"id": "1",
"relationships": {
"Currency": {
"data": {
"id": "1",
"type": "currencies"
}
}
}
}
}
Expected Response
200 OK
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://localhost:8080/api/v2/sites/1"
},
"data": {
"type": "sites",
"id": "1",
"attributes": {
"access_times": [
{
"to": "17:00",
"from": "09:00"
},
{
"to": "17:00",
"from": "09:00"
},
{
"to": "17:00",
"from": "09:00"
},
{
"to": "17:00",
"from": "09:00"
},
{
"to": "17:00",
"from": "09:00"
},
{
"to": "14:00",
"from": "09:30"
},
{
"to": "14:00",
"from": "11:00"
}
],
"address": "5 East Cliff",
"built_date": null,
"capacity": null,
"city": "Preston",
"country_id": 1,
"county": "Lancashire",
"created_at": "2024-02-14T11:27:15.000000Z",
"currency_id": 1,
"disabled_access": true,
"emergency_contact_details": "0161 999 6000",
"emergency_procedure": "This is the site-level emergency procedure for the site Expansive HQ.",
"excluded_dates": [],
"geofence": [
[
53.753966613709,
-2.7037914368854
],
[
53.754191806123,
-2.7034454319225
],
[
53.753942825708,
-2.7029733631359
],
[
53.753708116704,
-2.7033274147259
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
],
[
53.753966613709,
-2.7037914368854
]
],
"geofence_area": 1500,
"hazards": null,
"landlord_id": 1,
"latitude": "53.753984",
"lease_end_date": null,
"longitude": "-2.703279",
"name": "Expansive HQ",
"notes": "This is a test site.",
"number_of_employees": null,
"number_of_floors": null,
"number_of_lifts": null,
"number_of_meeting_rooms": null,
"number_of_parking_spaces": null,
"opening_times": null,
"organisation_id": 3,
"permit_instructions": "Permit required, arrange at reception.",
"postcode": "PR1 3JE",
"reference": "test123",
"site_type_id": 1,
"telephone": "0161 987 6000",
"test": false,
"timezone": "Europe/London",
"total_space": null,
"updated_at": "2024-02-14T12:40:29.000000Z",
"usable_space": null,
"enabled": false
},
"relationships": {
"Country": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/country",
"self": "http://localhost:8080/api/v2/sites/1/relationships/country"
}
},
"Landlord": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/landlord",
"self": "http://localhost:8080/api/v2/sites/1/relationships/landlord"
}
},
"Organisation": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/organisation",
"self": "http://localhost:8080/api/v2/sites/1/relationships/organisation"
}
},
"SiteType": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/site-type",
"self": "http://localhost:8080/api/v2/sites/1/relationships/site-type"
}
},
"Users": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/users",
"self": "http://localhost:8080/api/v2/sites/1/relationships/users"
}
},
"WorkOrders": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/work-orders",
"self": "http://localhost:8080/api/v2/sites/1/relationships/work-orders"
}
},
"RecurringWorkOrders": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/recurring-work-orders",
"self": "http://localhost:8080/api/v2/sites/1/relationships/recurring-work-orders"
}
},
"Tags": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/tags",
"self": "http://localhost:8080/api/v2/sites/1/relationships/tags"
}
},
"Currency": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/currency",
"self": "http://localhost:8080/api/v2/sites/1/relationships/currency"
}
},
"MaintainableEntity": {
"links": {
"related": "http://localhost:8080/api/v2/sites/1/maintainable-entity",
"self": "http://localhost:8080/api/v2/sites/1/relationships/maintainable-entity"
}
}
},
"links": {
"self": "http://localhost:8080/api/v2/sites/1"
}
}
}