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

# 查詢客戶帳號角色清單

GET https://api.example.com/v1/company-user-roles

列出呼叫端所屬租戶可以指派給客戶帳號的角色，用於建立客戶帳號或改派角色前取得合法的 roleId（見 POST /v1/companies/\{id}/users）。`type` 為 Boss、Employee，或租戶自訂角色的 Custom 開頭代碼；只有 Boss 能使用前台的全公司功能。不分頁——一個租戶的角色數量少，建議只查一次並在你端快取。

Reference: https://docs.orderupb2b.com/api-規格/company-user-roles/list-company-user-roles

## Authentication

- `X-Signature` header (required) — 每個 /v1 請求都必須帶 `X-Client-Id`、`X-Timestamp`、`X-Nonce` 與 `X-Signature` 四個標頭。`X-Signature` 是以 client secret 對 canonical string 做 HMAC-SHA256 後的 Base64。 canonical string 的組成、可複製的簽章範例與 401 排查步驟，請參閱[「驗證與簽章」](/authentication)。

## Response

### 200

OK

- `data` (list of CompanyUserRoleResponse, optional, nullable) — 這個租戶可以指派給客戶帳號的完整角色清單。

## Errors

### 401 Unauthorized Error

Unauthorized

- `error` (string, optional, nullable) — 錯誤代碼，固定為 snake_case 字串，依代碼判斷失敗原因。

### 403 Forbidden Error

Forbidden

- `error` (string, optional, nullable) — 錯誤代碼，固定為 snake_case 字串，依代碼判斷失敗原因。

### 500 Internal Server Error

Internal Server Error

- `code` (string, optional, nullable) — 錯誤代碼字串。
- `message` (string, optional, nullable) — 對應的錯誤說明文字。

## Types

### CompanyUserRoleResponse

一個可以指派給客戶帳號的角色，是 GET /v1/company-user-roles 清單裡的一筆。

- `id` (long, optional) — 角色序號，建立或更新客戶帳號時填入 roleId 的值。
- `name` (string, optional, nullable) — 角色名稱。
- `type` (string, optional, nullable) — 角色類型：Boss、Employee，或租戶自訂角色的 Custom 開頭代碼。只有 Boss 能使用前台的全公司功能，每一家客戶至少要保留一個生效中的 Boss 帳號。
- `isSystem` (boolean, optional) — 是否為系統內建角色（Boss、Employee）。內建角色可以在後台調整權限，但不能刪除。

## Examples

**Response**

```json
{
  "data": [
    {
      "id": 1,
      "name": "string",
      "type": "string",
      "isSystem": true
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/company-user-roles"

headers = {"X-Signature": "<apiKey>"}

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

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/company-user-roles';
const options = {method: 'GET', headers: {'X-Signature': '<apiKey>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/company-user-roles"

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

	req.Header.Add("X-Signature", "<apiKey>")

	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://api.example.com/v1/company-user-roles")

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

request = Net::HTTP::Get.new(url)
request["X-Signature"] = '<apiKey>'

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.get("https://api.example.com/v1/company-user-roles")
  .header("X-Signature", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.example.com/v1/company-user-roles', [
  'headers' => [
    'X-Signature' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/company-user-roles");
var request = new RestRequest(Method.GET);
request.AddHeader("X-Signature", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["X-Signature": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/company-user-roles")! 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()
```