> For the complete documentation index, see [llms.txt](https://docs.mclimate.eu/mclimate-api-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mclimate.eu/mclimate-api-documentation/endpoints.md).

# Basic endpoints

## User profile

### Login

*Request URL:*

```
POST /auth/login
```

*Headers:*

```
Content-Type: application/json
```

*Body:*

```
{
  "client_id" : "",
  "client_secret" : "",
  "username" : "",
  "password" : ""
}
```

*Response:*

```
{
    "auth": {
        "access_token": "1e516******************************ca",
        "expires_in": 86400,
        "token_type": "Bearer",
        "scope": null,
        "refresh_token": "e8ec5********************************26b3"
    },
    "_links": {
        "self": {
            "href": "/v1/auth/login"
        }
    }
}
```

### Renew Access Token

*Request URL:*

```
POST /auth/renew
```

*Headers:*

```
Content-Type: application/json
```

*Body:*

```
{
  "client_id" : "",
  "client_secret" : "",
  "refresh_token" : ""
}
```

*Response:*

```
{
    "auth": {
        "access_token": "44******************23263e59d3c5a3",
        "expires_in": 86400,
        "token_type": "Bearer",
        "scope": null
    },
    "_links": {
        "self": {
            "href": "/v1/auth/renew"
        }
    }
}
```

### Fetch Personal Info

*Request URL:*

```
GET /users/me
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
Accept-Response: Advanced
```

*Response:*

```
{
    "users": {
        "user_id": ,
        "username": "",
        "firstname": "",
        "lastname": "",
        "phone": null,
        "country_id": ,
        "created": "2",
        "_relation": {
            "country": {
                "id": ,
                "geoname_id": ,
                "continent_code": "",
                "continent_name": "",
                "country_code": "",
                "country_name": "",
                "city_name": "",
                "time_zone": ""
            }
        }
    },
    "_links": {
        "self": {
            "href": "/v1/users"
        },
        "controller": {
            "href": "/v1/controller/{serial_number}",
            "templated": true
        }
    }
}
```

## Controllers

### Fetch user’s controllers

*Request URL:*

```
GET /controllers
```

*Optional params: type={device type} (melissa; bobbie; smart\_plug...) & mac={device mac}*

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Response:*

```
{
  "_embedded": {
    "controller": [
      {
        "user_id": 200,
        "serial_number": "H5******J6X",
        "mac": "“ACCF***6522E\"",
        "firmware_version": "V1SHTHF",
        "name": "Melissa H59****X",
        "type": "melissa",
        "room_id": 7,
        "online": false,
        "brand_id": 9,
        "controller_log": [],
        "_links": {
          "self": {
            "href": "/v1/controllers/H59I****6X"
          }
        }
      },
      {…},
	 {…},
	 {…},
	…	
    ]
  },
  "total": 22,
  "_links": {
    "self": {
      "href": "/v1/controllers"
    },
    "first": {
      "href": "/v1/controllers?page=1"
    },
    "last": {
      "href": "/v1/controllers?page=1"
    }
  }
}
```

### Fetch one controller

*Request URL:*

```
GET /controllers/{serial_number}
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Response:*

```
{
    "controller": {
        "user_id": 200,
        "serial_number": "H5******J6X",
        "mac": "ACCF***6522E",
        "firmware_version": "V1SHTHF",
        "name": "Melissa H59****X",
        "type": "melissa",
        "room_id": 7,
        "online": false,
        "brand_id": 9,
        "controller_log": [],
        "_links": {
          "self": {
            "href": "/v1/controllers/H59I****6X"
          }
        }
      },
    "_links": {
        "self": {
            "href": "/v1/controllers/H5******J6X"
        }
    }
}
```

### Controller Assign

*Request URL:*

```
POST /controllers/{serial_number}/assign
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Response:*

```
{
    "controller_reassign": {
        "id": 1***,
        "user_id": 200,
        "serial_number": "H5******J6X",
        "mac": "ACCF***6522E",
        "firmware_version": "V1SHTHF",
        "name": "Melissa H59****X",
        "type": "melissa",
        "device_group": "mclimate",
        "status_push": 0,
        "room_id": null,
        "created": "2016-04-12 11:25:47",
        "assigned_at": "2020-11-20 15:19:29",
        "deleted_at": null
    },
    "_links": {
        "self": {
            "href": "/v1/controllers/H5******J6X/assign"
        }
    }
}
```

### Controller Reassign

*Request URL:*

```
PATCH /controllers/{serial_number}/reassign
```

*Headers:*

```
Content-Type: application/json
Authorization: Bearer {access_token}
```

*Body*:

```
{
  "owner" : "n*****@s******a.com"
}
```

*Response:*

```
{
    "controller_reassign": {
        "id": 1***,
        "user_id": 200,
        "serial_number": "H5******J6X",
        "mac": "ACCF***6522E",
        "firmware_version": "V1SHTHF",
        "name": "Melissa H59****X",
        "type": "melissa",
        "device_group": "mclimate",
        "status_push": 0,
        "room_id": null,
        "created": "2016-04-12 11:25:47",
        "assigned_at": "2020-11-20 15:19:29",
        "deleted_at": null
    },
    "_links": {
        "self": {
            "href": "/v1/controllers/H5******J6X/assign"
        }
    }
}
```

## MClimate LoRaWAN Products

If you are interested in our LoRaWAN devices, you can find more information [here](https://mclimate.bit.ai/docs/HodBXcDAtTgv1Lhf).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.mclimate.eu/mclimate-api-documentation/endpoints.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
