# Floors

A **floor** represents an individual level within a [building](/asset-management/graphql-api-overview/buildings.md) and may contain one or more rooms and zones. Buildings can have one or multiple floors, depending on their structure and user requirements.

This page provides guidance on how to [**retrieve**](#get-all-floors), [**create**](#create-floor-s), and [**update floor information**](#update-floor-s) within a building, enabling precise management of floor-specific data.

{% hint style="success" %}
First, obtain an access token to get started [here](/getting-started/authentication.md).
{% endhint %}

***

### Get all floors

```graphql
query allFloors {
  floors {
    data {
      id
      building {
        id
        name
      }
      metadata {
        ...MetaDataFragment
      }
      name
      timezone
      area {
        ...AreaFragment
      }
      capacity {
        ...CapacityFragment
      }
      sensors {
        id
        name
        ...SensorFragment
      }
      hives {
        id
        name
        ...HiveFragment
      }
      rooms {
        id
        name
        ...RoomFragment
      }
      zones {
        id
        name
        ...ZoneFragment
      }
      installation_date
      installation_status
      tags {
        id
        name
        ...TagFragment
      }
      last_battery_change_date
      next_battery_change_date
      floor_plans {
        ...FloorPlanFragment
      }
      floorNumber
      client_id
    }
  }
}

```

#### Code Examples

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://api.butlr.io/api/v3/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer [insert access_token here]' \
--data '{"query":"query allFloors{\n  floors{\n    data {\n      id\n      building {\n        id\n        name\n      }\n      name\n      timezone\n      sensors {\n        sensor_id\n        name\n      }\n      hives {\n        id\n        name\n      }\n      rooms {\n        id\n        name\n      }\n      zones {\n        id\n        name\n      }\n    }\n  }\n}","variables":{}}'
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.butlr.io/api/v3/graphql"
  method := "POST"

  payload := strings.NewReader("{\"query\":\"query allFloors{\\n  floors{\\n    data {\\n      id\\n      building {\\n        id\\n        name\\n      }\\n      name\\n      timezone\\n      sensors {\\n        sensor_id\\n        name\\n      }\\n      hives {\\n        id\\n        name\\n      }\\n      rooms {\\n        id\\n        name\\n      }\\n      zones {\\n        id\\n        name\\n      }\\n    }\\n  }\\n}\",\"variables\":{}}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer [insert access_token here]")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.butlr.io/api/v3/graphql"

payload = "{\"query\":\"query allFloors{\\n  floors{\\n    data {\\n      id\\n      building {\\n        id\\n        name\\n      }\\n      name\\n      timezone\\n      sensors {\\n        sensor_id\\n        name\\n      }\\n      hives {\\n        id\\n        name\\n      }\\n      rooms {\\n        id\\n        name\\n      }\\n      zones {\\n        id\\n        name\\n      }\\n    }\\n  }\\n}\",\"variables\":{}}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer [insert access_token here]'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

***

### Update floor(s)

```graphql
mutation updateFloorInfo($input: UpdateFloorInfoInput!) {
  updateFloorInfo(input: $input) {
    floor {
      id
      name
    }
  }
}

# Variables
{
    "input" : {
        "name": "example_floor_updated_name",
        "id": "space_2mAEeEfqHvPPoWMYoLuEUl6ncWn"
    }
}
```

#### Code Examples

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://api.butlr.io/api/v3/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjJwTC04ZGRDNlhMaDNEblVHa2ptWiJ9.eyJodHRwOi8vYnV0bHIuaW8vY2xpZW50X2lkIjoiY2xpZW50XzJDbFlBYVY1Z0FISlJjUDdsd3JoTUU5ejR1WSIsImh0dHA6Ly9idXRsci5pby9lbWFpbCI6ImV2YWxfMjUxMzMzQGJ1dGxyLnRlY2giLCJodHRwOi8vYnV0bHIuaW8vcm9sZXMiOltdLCJpc3MiOiJodHRwczovL2J1dGxydGVjaC51cy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8dXNlcl8yQ2xZQVpTZjZlMzJVUFRrVVBSUUplTWhLbkciLCJhdWQiOlsiaHR0cHM6Ly91c2Vycy5idXRsci5pby8iLCJodHRwczovL2J1dGxydGVjaC51cy5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNzI2NTExNTA4LCJleHAiOjE3MjY1MTI1MDgsInNjb3BlIjoib3BlbmlkIGVtYWlsIHByb2ZpbGUgb2ZmbGluZV9hY2Nlc3MiLCJndHkiOiJwYXNzd29yZCIsImF6cCI6Imw0bHh3MUsySjlQdUJ2UEZlNXlidkoyejhUNjBNc0pJIiwicGVybWlzc2lvbnMiOltdfQ.k15h6wL5qz6zZrLLLdJ7_dsBrDvtO1J0veqUPzQjzKQ73fHDfidKf3MFNBq694z-NWQA-5Usf-Ck62EJ0POyE4PcZ7ptN42NgyeGD0EB40aDMEmYW_kxXvf8iewpbtBMVjqsIwHOR5YG8pE4VMXDrhPmRdSaurg0ic8kLRhqXGSHAzVqVtGXkVMmy9TXsVsDw-e3GymiJzLgm8S0zhzfBNLbffTgL4h3v4-nQC8hmUraNi3aQLQa4sYBvREV9IKECwNWfAXFWlckn3YC3s_90UOlWL4aFAc-tGTrUJyPDtytrunlegulFEeVDANe71nXnh1yBqLiHuiBNDryD2BqWQ' \
--data '{"query":"mutation updateFloorInfo($input: UpdateFloorInfoInput!) {\n  updateFloorInfo(input: $input) {\n    floor {\n      id\n      name\n    }\n  }\n}","variables":{"input":{"name":"example_floor_updated_name","id":"space_2mAEeEfqHvPPoWMYoLuEUl6ncWn"}}}'
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.butlr.io/api/v3/graphql"
  method := "POST"

  payload := strings.NewReader("{\"query\":\"mutation updateFloorInfo($input: UpdateFloorInfoInput!) {\\n  updateFloorInfo(input: $input) {\\n    floor {\\n      id\\n      name\\n    }\\n  }\\n}\",\"variables\":{\"input\":{\"name\":\"example_floor_updated_name\",\"id\":\"space_2mAEeEfqHvPPoWMYoLuEUl6ncWn\"}}}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjJwTC04ZGRDNlhMaDNEblVHa2ptWiJ9.eyJodHRwOi8vYnV0bHIuaW8vY2xpZW50X2lkIjoiY2xpZW50XzJDbFlBYVY1Z0FISlJjUDdsd3JoTUU5ejR1WSIsImh0dHA6Ly9idXRsci5pby9lbWFpbCI6ImV2YWxfMjUxMzMzQGJ1dGxyLnRlY2giLCJodHRwOi8vYnV0bHIuaW8vcm9sZXMiOltdLCJpc3MiOiJodHRwczovL2J1dGxydGVjaC51cy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8dXNlcl8yQ2xZQVpTZjZlMzJVUFRrVVBSUUplTWhLbkciLCJhdWQiOlsiaHR0cHM6Ly91c2Vycy5idXRsci5pby8iLCJodHRwczovL2J1dGxydGVjaC51cy5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNzI2NTExNTA4LCJleHAiOjE3MjY1MTI1MDgsInNjb3BlIjoib3BlbmlkIGVtYWlsIHByb2ZpbGUgb2ZmbGluZV9hY2Nlc3MiLCJndHkiOiJwYXNzd29yZCIsImF6cCI6Imw0bHh3MUsySjlQdUJ2UEZlNXlidkoyejhUNjBNc0pJIiwicGVybWlzc2lvbnMiOltdfQ.k15h6wL5qz6zZrLLLdJ7_dsBrDvtO1J0veqUPzQjzKQ73fHDfidKf3MFNBq694z-NWQA-5Usf-Ck62EJ0POyE4PcZ7ptN42NgyeGD0EB40aDMEmYW_kxXvf8iewpbtBMVjqsIwHOR5YG8pE4VMXDrhPmRdSaurg0ic8kLRhqXGSHAzVqVtGXkVMmy9TXsVsDw-e3GymiJzLgm8S0zhzfBNLbffTgL4h3v4-nQC8hmUraNi3aQLQa4sYBvREV9IKECwNWfAXFWlckn3YC3s_90UOlWL4aFAc-tGTrUJyPDtytrunlegulFEeVDANe71nXnh1yBqLiHuiBNDryD2BqWQ")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://api.butlr.io/api/v3/graphql"

payload = "{\"query\":\"mutation updateFloorInfo($input: UpdateFloorInfoInput!) {\\n  updateFloorInfo(input: $input) {\\n    floor {\\n      id\\n      name\\n    }\\n  }\\n}\",\"variables\":{\"input\":{\"name\":\"example_floor_updated_name\",\"id\":\"space_2mAEeEfqHvPPoWMYoLuEUl6ncWn\"}}}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjJwTC04ZGRDNlhMaDNEblVHa2ptWiJ9.eyJodHRwOi8vYnV0bHIuaW8vY2xpZW50X2lkIjoiY2xpZW50XzJDbFlBYVY1Z0FISlJjUDdsd3JoTUU5ejR1WSIsImh0dHA6Ly9idXRsci5pby9lbWFpbCI6ImV2YWxfMjUxMzMzQGJ1dGxyLnRlY2giLCJodHRwOi8vYnV0bHIuaW8vcm9sZXMiOltdLCJpc3MiOiJodHRwczovL2J1dGxydGVjaC51cy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8dXNlcl8yQ2xZQVpTZjZlMzJVUFRrVVBSUUplTWhLbkciLCJhdWQiOlsiaHR0cHM6Ly91c2Vycy5idXRsci5pby8iLCJodHRwczovL2J1dGxydGVjaC51cy5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNzI2NTExNTA4LCJleHAiOjE3MjY1MTI1MDgsInNjb3BlIjoib3BlbmlkIGVtYWlsIHByb2ZpbGUgb2ZmbGluZV9hY2Nlc3MiLCJndHkiOiJwYXNzd29yZCIsImF6cCI6Imw0bHh3MUsySjlQdUJ2UEZlNXlidkoyejhUNjBNc0pJIiwicGVybWlzc2lvbnMiOltdfQ.k15h6wL5qz6zZrLLLdJ7_dsBrDvtO1J0veqUPzQjzKQ73fHDfidKf3MFNBq694z-NWQA-5Usf-Ck62EJ0POyE4PcZ7ptN42NgyeGD0EB40aDMEmYW_kxXvf8iewpbtBMVjqsIwHOR5YG8pE4VMXDrhPmRdSaurg0ic8kLRhqXGSHAzVqVtGXkVMmy9TXsVsDw-e3GymiJzLgm8S0zhzfBNLbffTgL4h3v4-nQC8hmUraNi3aQLQa4sYBvREV9IKECwNWfAXFWlckn3YC3s_90UOlWL4aFAc-tGTrUJyPDtytrunlegulFEeVDANe71nXnh1yBqLiHuiBNDryD2BqWQ'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.butlr.io/asset-management/graphql-api-overview/floors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
