# 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: 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.mclimate.eu/mclimate-api-documentation/endpoints.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.
