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

# Update User

PUT https://testgatewayapi.insurapps.net/api/offline/users/{userId}
Content-Type: application/json

## Kullanıcı Güncelle

Offline kapsamındaki mevcut bir kullanıcının profil ve güvenlik alanlarını günceller. Bu endpoint; sigorta şirketlerinin veya acentelerin kendi kapsamlarındaki kullanıcıların kullanıcı adı, e-posta, ad soyad bilgilerini ve güvenlik ayarlarını (şifre değiştirme zorunluluğu, iki adımlı doğrulama, e-posta onay durumu) güncellemesine olanak tanır. İstek; doğrulama kontrolleri, kimlik kapsamı çözümlemesi, hedef kullanıcı erişim kontrolü ve duplicate e-posta/kullanıcı adı kontrollerinden sonra güncelleme işlemini gerçekleştirir.

***

## Endpoint Bilgisi

| Özellik           | Değer                           |
| ----------------- | ------------------------------- |
| **HTTP Metodu**   | `PUT`                           |
| **URL**           | `/api/offline/users/{id}`       |
| **Content-Type**  | `application/json`              |
| **Yetkilendirme** | `Authorization: Bearer {token}` |

### Yetkilendirme Rolleri

Çağıranın aşağıdaki rollerden birine sahip olması gerekir:

| Rol                        | Erişim Kapsamı                                           |
| -------------------------- | -------------------------------------------------------- |
| `InsuranceCompanyAPIAdmin` | Şirket kapsamındaki kullanıcıları güncelleyebilir        |
| `Supervizor`               | Şirket/acente kapsamındaki kullanıcıları güncelleyebilir |

> **Not:** Endpoint `Update` policy'si ile korunur. Bu rollere sahip olmayan kullanıcılar `403 Forbidden` alır.

### Route Parametreleri

| Parametre | Tip      | Zorunlu | Açıklama                                           |
| --------- | -------- | ------- | -------------------------------------------------- |
| `id`      | `string` | Evet    | Güncellenecek kullanıcının benzersiz tanımlayıcısı |

***

## İstek Modeli

### Ana İstek

Tüm alanların gönderilmesi zorunludur.

| Alan                 | Tip       | Zorunlu | Açıklama                                     | Doğrulama Kuralları                                                                                                                                                                    |
| -------------------- | --------- | ------- | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UserName`           | `string`  | Evet    | Kullanıcı adı                                | Zorunlu: `"UserName is required."`  Min. 3 karakter: `"UserName must be at least 3 characters."`  Maks. 256 karakter: `"UserName must be less than or equal to 256 characters."`       |
| `Email`              | `string`  | Evet    | E-posta adresi                               | Zorunlu: `"Email is required."`  Geçerli e-posta formatı olmalı: `"Email must be a valid email address."`  Maks. 256 karakter: `"Email must be less than or equal to 256 characters."` |
| `FullName`           | `string`  | Evet    | Ad soyad                                     | Zorunlu: `"FullName is required."`  Min. 3 karakter: `"FullName must be at least 3 characters."`  Maks. 100 karakter: `"FullName must be less than or equal to 100 characters."`       |
| `NeedPasswordChange` | `boolean` | Evet    | Sonraki girişte şifre değiştirme zorunluluğu | Zorunlu: `"NeedPasswordChange is required."`                                                                                                                                           |
| `TwoFactorEnabled`   | `boolean` | Evet    | İki adımlı doğrulama aktif/pasif durumu      | Zorunlu: `"TwoFactorEnabled is required."`                                                                                                                                             |
| `EmailConfirmed`     | `boolean` | Evet    | E-posta onay durumu                          | Zorunlu: `"EmailConfirmed is required."`                                                                                                                                               |

***

## İstek Örneği

```http
PUT /api/offline/users/4c31d679-b285-4040-9b57-5ce49e9f604c
Authorization: Bearer {token}
Content-Type: application/json
{
  "UserName": "updated-user",
  "Email": "updated-user@acme.local",
  "FullName": "Updated User",
  "NeedPasswordChange": true,
  "TwoFactorEnabled": true,
  "EmailConfirmed": false
}

```

***

## Yanıt Formatı

### Başarılı Yanıt

**HTTP Durumu:** `204 No Content`

Başarılı güncellemede yanıt gövdesi boştur.

```http
HTTP/1.1 204 No Content

```

### Hata Yanıtı

```json
{
    "Status": false,
    "Code": "Error.Code",
    "Message": "Error description",
    "Response": null
}

```

Doğrulama hatalarında `Response` alanı detayları içerir:

```json
{
    "Status": false,
    "Code": "Validation.General",
    "Message": "One or more validation errors occurred",
    "Response": [
        {
            "Field": "FieldName",
            "Message": "Error message description"
        }
    ]
}

```

***

## HTTP Durum Kodları

| Durum                       | Açıklama                                              |
| --------------------------- | ----------------------------------------------------- |
| `204 No Content`            | Kullanıcı başarıyla güncellendi                       |
| `400 Bad Request`           | İstek doğrulama hatası                                |
| `401 Unauthorized`          | Eksik, geçersiz veya süresi dolmuş token              |
| `403 Forbidden`             | Yetersiz yetki, geçersiz rol/scope veya erişim kısıtı |
| `404 Not Found`             | Belirtilen kullanıcı mevcut değil                     |
| `409 Conflict`              | Duplicate email veya kullanıcı adı                    |
| `500 Internal Server Error` | Beklenmeyen business hatası                           |

***

## Hata Kodları Referansı

| Kod                                       | HTTP Durumu | Mesaj                                                               |
| ----------------------------------------- | ----------- | ------------------------------------------------------------------- |
| `Validation.General`                      | 400         | One or more validation errors occurred                              |
| `OfflineUsers.NotAccessible`              | 403         | User '\{id}' is not accessible within the current scope.            |
| `OfflineUsers.InsuranceCompanyNotFound`   | 403         | No valid insurance company assignment found in token.               |
| `OfflineUsers.AgentNotFound`              | 403         | No valid agent assignment found for agent user.                     |
| `OfflineUsers.AgentOrCompanyRoleRequired` | 403         | Only agent or company users are authorized for this endpoint.       |
| `OfflineUsers.UserNotFound`               | 404         | The requested user '\{id}' does not exist.                          |
| `OfflineUsers.DuplicateEmail`             | 409         | Email '\{email}' already exists.                                    |
| `OfflineUsers.DuplicateUserName`          | 409         | UserName '\{userName}' already exists.                              |
| `OfflineUsers.UpdateFailed`               | 500         | User '\{id}' could not be updated due to a business rule violation. |

***

## İşleme Akışı

Endpoint, isteği aldığında aşağıdaki adımları sırasıyla uygular:

1. **Kimlik Doğrulama** — Bearer token doğrulanır; token yoksa/geçersizse `401` döner.

2. **Yetkilendirme** — `Update` policy'si ve `InsuranceCompanyAPIAdmin` / `Supervizor` rolü kontrol edilir; yetersizse `403` döner.

3. **İstek Doğrulama** — Tüm zorunlu alanlar ve doğrulama kuralları kontrol edilir; ihlal varsa `400` döner.

4. **Identity Scope Çözümleme** — Token claim'lerinden `InsuranceCompanyIds` (company) veya `AgentIds` (agent) okunur. Uygun rol/scope yoksa `403` döner.

5. **Hedef Kullanıcı Erişim Kontrolü** — Company scope için ve agent scope kullanıcı için erişim kontrolü sağlanır; yoksa `OfflineUsers.NotAccessible` ile `403` döner.

6. **Duplicate Kontrolleri** — `Email` ve `UserName` için tekillik kontrolü yapılır; çakışma varsa `409` döner.

7. **Kullanıcı Güncelleme** — Business katmanında gerekli işlemler yapılır.

8. **Sonuç** — Başarıyla güncellenirse `204 No Content` döner. Business katmanından `NotFoundException` alınırsa `OfflineUsers.UserNotFound` koduyla `404`, `BusinessRuleException` alınırsa `OfflineUsers.UpdateFailed` koduyla `500` döner.

***

## Notlar

* **Identity Scope:** Güncelleme işlemi, yalnızca çağıran tokenın kapsamındaki (şirket veya acente) kullanıcılar üzerinde yapılabilir. Kapsam dışındaki kullanıcılara yapılan istekler `OfflineUsers.NotAccessible` ile reddedilir.

* **Duplicate Kontrolleri:** `Email` ve `UserName` tekilliği sistem genelinde kontrol edilir. Güncelleme sırasında bu alanların başka bir kullanıcıda kullanılmadığından emin olun.

* **Şifre Güncellemesi:** Bu endpoint şifre güncellemesi yapmaz. `NeedPasswordChange: true` gönderilirse yalnızca kullanıcıya sonraki girişte şifresini değiştirmesi zorunluluğu tanımlanır.

* **Bulunamayan Kullanıcı:** Route'ta belirtilen `id`'ye karşılık bir kullanıcı yoksa `OfflineUsers.UserNotFound` koduyla `404 Not Found` döner.

***

Reference: https://docs.insurgateway.com/insurgateway-api/offline/update-user

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://testgatewayapi.insurapps.net` (https://testgatewayapi.insurapps.net, default)
- `https://gatewayapi.insurapps.net` (https://gatewayapi.insurapps.net)

## Request

### Path parameters

- `userId` (string, required) — Unique identifier of the target user

## Response

### 204

No Content

## Errors

### 400 Bad Request Error

Bad Request

### 403 Forbidden Error

Forbidden

### 409 Conflict Error

Conflict

## Examples

**Request**

```json
{
  "userName": "test.user.updated",
  "email": "test.user.updated@company.com",
  "fullName": "Test User Updated",
  "needPasswordChange": false,
  "twoFactorEnabled": true,
  "emailConfirmed": true
}
```

**Response**

```json
"string"
```

**SDK Code**

```python
import requests

url = "https://testgatewayapi.insurapps.net/api/offline/users/user-id"

payload = {
    "userName": "test.user.updated",
    "email": "test.user.updated@company.com",
    "fullName": "Test User Updated",
    "needPasswordChange": False,
    "twoFactorEnabled": True,
    "emailConfirmed": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://testgatewayapi.insurapps.net/api/offline/users/user-id';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"userName":"test.user.updated","email":"test.user.updated@company.com","fullName":"Test User Updated","needPasswordChange":false,"twoFactorEnabled":true,"emailConfirmed":true}'
};

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://testgatewayapi.insurapps.net/api/offline/users/user-id"

	payload := strings.NewReader("{\n  \"userName\": \"test.user.updated\",\n  \"email\": \"test.user.updated@company.com\",\n  \"fullName\": \"Test User Updated\",\n  \"needPasswordChange\": false,\n  \"twoFactorEnabled\": true,\n  \"emailConfirmed\": true\n}")

	req, _ := http.NewRequest("PUT", 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://testgatewayapi.insurapps.net/api/offline/users/user-id")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"userName\": \"test.user.updated\",\n  \"email\": \"test.user.updated@company.com\",\n  \"fullName\": \"Test User Updated\",\n  \"needPasswordChange\": false,\n  \"twoFactorEnabled\": true,\n  \"emailConfirmed\": true\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.put("https://testgatewayapi.insurapps.net/api/offline/users/user-id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"userName\": \"test.user.updated\",\n  \"email\": \"test.user.updated@company.com\",\n  \"fullName\": \"Test User Updated\",\n  \"needPasswordChange\": false,\n  \"twoFactorEnabled\": true,\n  \"emailConfirmed\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://testgatewayapi.insurapps.net/api/offline/users/user-id', [
  'body' => '{
  "userName": "test.user.updated",
  "email": "test.user.updated@company.com",
  "fullName": "Test User Updated",
  "needPasswordChange": false,
  "twoFactorEnabled": true,
  "emailConfirmed": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://testgatewayapi.insurapps.net/api/offline/users/user-id");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"userName\": \"test.user.updated\",\n  \"email\": \"test.user.updated@company.com\",\n  \"fullName\": \"Test User Updated\",\n  \"needPasswordChange\": false,\n  \"twoFactorEnabled\": true,\n  \"emailConfirmed\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "userName": "test.user.updated",
  "email": "test.user.updated@company.com",
  "fullName": "Test User Updated",
  "needPasswordChange": false,
  "twoFactorEnabled": true,
  "emailConfirmed": true
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://testgatewayapi.insurapps.net/api/offline/users/user-id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```