> 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.

# GetAllUsers

GET https://testgatewayapi.insurapps.net/api/offline/users

## Kullanıcıları Listele

Token'daki yetki kapsamına göre sigorta şirketi ve/veya acente kapsamındaki kullanıcıları sayfalı (paginated) olarak listeler. Kullanıcı adı, e-posta ve aktiflik durumuna göre filtreleme ile dinamik sıralama desteği sunar.

***

## Endpoint Bilgisi

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

### Yetkilendirme Rolleri

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

| Rol                        | Erişim Kapsamı                                                    |
| -------------------------- | ----------------------------------------------------------------- |
| `InsuranceCompanyAPIAdmin` | Token'daki yetki kapsamı dahilindeki kullanıcıları listeleyebilir |
| `Supervizor`               | Token'daki yetki kapsamı dahilindeki kullanıcıları listeleyebilir |

> **Not:** Ek olarak `Read` policy yetkisi gereklidir.

***

## Query Parametreleri

| Parametre   | Tip       | Zorunlu | Varsayılan | Açıklama                                 | Doğrulama Kuralları                                                                                                              |
| ----------- | --------- | ------- | ---------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `Page`      | `integer` | Hayır   | `1`        | Sayfa numarası                           | 1'den büyük veya eşit olmalı: `"Page must be greater than or equal to 1."`                                                       |
| `PageSize`  | `integer` | Hayır   | `50`       | Sayfa başı kayıt sayısı                  | 1–200 arasında olmalı: `"PageSize must be between 1 and 200."`                                                                   |
| `SortOrder` | `string`  | Hayır   | `desc`     | Sıralama yönü: `asc` veya `desc`         | Geçerli değer: `"SortOrder must be 'asc' or 'desc'."`                                                                            |
| `SortBy`    | `string`  | Hayır   | `fullName` | Sıralama alanı                           | Geçerli değerler: `fullName`, `userName`, `email`, `lastLogin`: `"SortBy must be one of: fullName, userName, email, lastLogin."` |
| `UserName`  | `string`  | Hayır   | —          | Kullanıcı adına göre filtre (`Contains`) | Min 3, Maks 256 karakter                                                                                                         |
| `Email`     | `string`  | Hayır   | —          | E-postaya göre filtre (`Contains`)       | Min 3, Maks 256 karakter                                                                                                         |
| `IsActive`  | `boolean` | Hayır   | `null`     | Aktiflik durumu filtresi                 | Geçerli değerler: `true`, `false`                                                                                                |

### Aktiflik Filtresi Davranışı

API'deki `IsActive` alanı, veritabanı tarafındaki `Disabled` alanına dönüştürülür:

| `IsActive` Değeri | Uygulanan Koşul                          |
| ----------------- | ---------------------------------------- |
| `true`            | Aktif kullanıcılar (`Disabled == false`) |
| `false`           | Pasif kullanıcılar (`Disabled == true`)  |
| `null` / boş      | Durum filtresi uygulanmaz                |

### Sıralama Davranışı

* `SortOrder`: yalnızca `asc` veya `desc` kabul eder; geçersiz değer validation hatası üretir.

* `SortBy`: Boş gelirse varsayılan olarak `fullName` kullanılır.

* Eşitlik durumunda `Id` alanı ile ikincil sıralama (tie-break) uygulanır.

### Yetki Kapsamı

Yetki kapsamı, çağıranın sahip olduğu role göre belirlenir. Kullanıcı **company** veya **agent** rollerinden en az birine sahip değilse istek reddedilir.

* Kullanıcı company ya da agent rolünde değilse **`403 Forbidden`** döner.

  * Hata kodu: `OfflineUsers.AgentOrCompanyRoleRequired`
* Kullanıcı **company rolüne** sahipse, token'daki `InsuranceCompanyIds` claim'i okunur.

  * Liste boşsa **`403 Forbidden`** döner.
    * Hata kodu: `OfflineUsers.InsuranceCompanyNotFound`
  * Liste doluysa ilgili şirketlere bağlı kullanıcılar filtrelenir.
* Kullanıcı **agent rolüne** sahipse, token'daki `AgentIds` claim'i okunur.

  * Liste boşsa **`403 Forbidden`** döner.
    * Hata kodu: `OfflineUsers.AgentNotFound`
  * Liste doluysa ilgili acentelere bağlı kullanıcılar filtrelenir.
* Kullanıcı her iki role de sahipse iki filtre birlikte uygulanır.

***

## Hata Yanıtları

| HTTP Kodu | Hata Kodu                                 | Mesaj | Açıklama                                                                    |
| --------- | ----------------------------------------- | ----- | --------------------------------------------------------------------------- |
| `403`     | `OfflineUsers.AgentOrCompanyRoleRequired` | —     | Kullanıcı company ya da agent rolünde değil                                 |
| `403`     | `OfflineUsers.InsuranceCompanyNotFound`   | —     | Company rolündeki kullanıcının token'ında geçerli şirket ataması bulunamadı |
| `403`     | `OfflineUsers.AgentNotFound`              | —     | Agent rolündeki kullanıcının token'ında geçerli acente ataması bulunamadı   |

***

## Yanıt Formatı

#### PagedData Alanları

| Alan              | Tip       | Açıklama             |
| ----------------- | --------- | -------------------- |
| `TotalCount`      | `integer` | Toplam kayıt sayısı  |
| `Page`            | `integer` | Mevcut sayfa         |
| `Size`            | `integer` | Sayfa boyutu         |
| `TotalPage`       | `integer` | Toplam sayfa sayısı  |
| `HasNextPage`     | `boolean` | Sonraki sayfa var mı |
| `HasPreviousPage` | `boolean` | Önceki sayfa var mı  |
| `Items`           | `array`   | Kullanıcı listesi    |

#### UserDTO Alanları

| Alan             | Tip        | Açıklama                              |
| ---------------- | ---------- | ------------------------------------- |
| `Id`             | `string`   | Kullanıcı kimliği                     |
| `FullName`       | `string`   | Ad soyad                              |
| `UserName`       | `string`   | Kullanıcı adı                         |
| `Email`          | `string`   | E-posta adresi                        |
| `EmailConfirmed` | `boolean`  | E-posta doğrulanmış mı                |
| `Disabled`       | `boolean`  | Kullanıcı pasif mi                    |
| `LastLogin`      | `datetime` | Son giriş tarihi                      |
| `UserRoles`      | `array`    | Rol adları                            |
| `AssignedRoles`  | `string`   | Rol adlarının virgülle birleşmiş hali |

Reference: https://docs.insurgateway.com/insurgateway-api/offline/get-all-users

## 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)

## Response

### 200

OK

## Errors

### 400 Bad Request Error

Bad Request

### 403 Forbidden Error

Forbidden

## Examples

**Response**

```json
{
  "TotalCount": 3600,
  "Page": 1,
  "Size": 1,
  "TotalPage": 3600,
  "HasNextPage": true,
  "HasPreviousPage": false,
  "Items": [
    {
      "Id": "a1b2c3d4-5678-9101-abcd-ef1234567890",
      "FullName": "kullanici_001@sirket.com.tr",
      "Email": "kullanici_001@sirket.com.tr",
      "UserName": "kullanici_001@sirket.com.tr",
      "AssignedRoles": "InsuranceCompanyAPIUser",
      "PhoneNumber": null,
      "Disabled": true,
      "EmailConfirmed": true,
      "TwoFactorEnabled": false,
      "LastLogin": "0001-01-01T00:00:00",
      "LockoutEnd": null,
      "SelectedInsuranceCompanies": null,
      "UserRoles": [
        "InsuranceCompanyAPIUser"
      ],
      "AddedInsuranceCompanies": []
    }
  ]
}
```

**SDK Code**

```python Offline_getAllUsers_example
import requests

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

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Offline_getAllUsers_example
const url = 'https://testgatewayapi.insurapps.net/api/offline/users';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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

```go Offline_getAllUsers_example
package main

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

func main() {

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

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

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

url = URI("https://testgatewayapi.insurapps.net/api/offline/users")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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

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

HttpResponse<String> response = Unirest.get("https://testgatewayapi.insurapps.net/api/offline/users")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://testgatewayapi.insurapps.net/api/offline/users', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Offline_getAllUsers_example
using RestSharp;

var client = new RestClient("https://testgatewayapi.insurapps.net/api/offline/users");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Offline_getAllUsers_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://testgatewayapi.insurapps.net/api/offline/users")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```