> This page is for Developers.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.iot.telia.lt/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.iot.telia.lt/_mcp/server.

# Update user by ID

PATCH https://iot.telia.lt/api/v1/user/{user_id}
Content-Type: application/json

Provided fields

* `username` (String optional) - has to be user's email
* `name` (String optional)
* `status` (Object optional)
* `organisation` (Object optional) - must be the current organisation or not to be provided

#### Notes

* Password is not provided. Separate calls provide password management.
* The organisation is not modifiable. A user can be updated, if belonging to the same organisation as the requesting user,
  or to an organisation which is a direct child of the requesting user's organisation.
* Status can be changed between ACTIVE (id: 1) and SUSPENDED (id: 2), and from ACTIVATION\_PENDING (id: 0) to SUSPENDED.

Modifying the username invalidates account and triggers the activation procedure.

Reference: https://docs.iot.telia.lt/developers/api/user-management/user-by-id-patch

## Authentication

- `Authorization` header (bearer token, required) — An `auth_token` should be provided to authenticate a session. To obtain an `auth_token`, see the [`/api/v1/authenticate` **POST** request](/developers/api/authentication/authenticate).

## Request

### Path parameters

- `user_id` (double, required) — User ID

### Body (application/json)

This endpoint expects an object.

- `username` (string, required)
- `name` (string, required)
- `status` (ApiV1UserUserIdPatchRequestBodyContentApplicationJsonSchemaStatus, required)

## Response

### 204

The server has successfully fulfilled the request and that there is no additional content to send in the response payload body

## Errors

### 403 Forbidden Error

Your role doesn't include the permission this endpoint requires. Most endpoints return `error_code`, `error_token`, and `message`. Some return only `status_code` and `message`.

- `error_code` (integer, optional)
- `error_token` (string, optional)
- `status_code` (integer, optional)
- `message` (string, optional)

### 422 Unprocessable Entity Error

Unprocessable Entity. See HTTP response body for details.

- `error_code` (integer, optional)
- `error_token` (string, optional)
- `message` (string, optional)
- `errors` (list of ApiV1UserUserIdPatchResponsesContentApplicationJsonSchemaErrorsItems, optional)

## Types

### ApiV1UserUserIdPatchRequestBodyContentApplicationJsonSchemaStatus

### ApiV1UserUserIdPatchResponsesContentApplicationJsonSchemaErrorsItems

## Examples

**Request**

```json
{
  "username": "eabbot@flatland.org",
  "name": "Edwin Abbott",
  "status": {
    "id": 1
  }
}
```

**SDK Code**

```python
import requests

url = "https://iot.telia.lt/api/v1/user/1.1"

payload = {
    "username": "eabbot@flatland.org",
    "name": "Edwin Abbott",
    "status": { "id": 1 }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://iot.telia.lt/api/v1/user/1.1';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"username":"eabbot@flatland.org","name":"Edwin Abbott","status":{"id":1}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://iot.telia.lt/api/v1/user/1.1"

	payload := strings.NewReader("{\n  \"username\": \"eabbot@flatland.org\",\n  \"name\": \"Edwin Abbott\",\n  \"status\": {\n    \"id\": 1\n  }\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://iot.telia.lt/api/v1/user/1.1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"username\": \"eabbot@flatland.org\",\n  \"name\": \"Edwin Abbott\",\n  \"status\": {\n    \"id\": 1\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://iot.telia.lt/api/v1/user/1.1")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"username\": \"eabbot@flatland.org\",\n  \"name\": \"Edwin Abbott\",\n  \"status\": {\n    \"id\": 1\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://iot.telia.lt/api/v1/user/1.1', [
  'body' => '{
  "username": "eabbot@flatland.org",
  "name": "Edwin Abbott",
  "status": {
    "id": 1
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://iot.telia.lt/api/v1/user/1.1");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"username\": \"eabbot@flatland.org\",\n  \"name\": \"Edwin Abbott\",\n  \"status\": {\n    \"id\": 1\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "username": "eabbot@flatland.org",
  "name": "Edwin Abbott",
  "status": ["id": 1]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://iot.telia.lt/api/v1/user/1.1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```