> 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/companies/{id}/users

分頁查詢某一家客戶底下的帳號，依 id 由小到大排序。

可用下列參數篩選：

  - `account`、`name`、`email`：大小寫不敏感的子字串比對
  - `status`：Active 或 Inactive，完全比對，但大小寫不敏感


`page` 從 1 起算，`pageSize` 為 1–100（預設 100），超出範圍一律回 400。

客戶不存在或屬於其他租戶時回傳 404 company_not_found，而不是空的清單——這樣才分得出「這家客戶還沒有帳號」與「客戶序號帶錯」。

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

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

## Request

### Path parameters

- `id` (long, required) — 客戶序號，對應客戶主檔的 id。查無此客戶或屬於其他租戶時，一律回傳 404 company_not_found。

### Query parameters

- `account` (string, optional) — 依帳號篩選。大小寫不敏感的子字串比對，前後空白會被忽略。
- `name` (string, optional) — 依姓名篩選。規則與 account 相同。
- `email` (string, optional) — 依電子郵件篩選。規則與 account 相同。
- `status` (string, optional) — 依帳號狀態篩選，Active 或 Inactive。完全比對，但大小寫不敏感，前後空白也會被忽略。帶其他值不會回傳錯誤，只會查不到任何帳號。
- `page` (integer, optional) — 頁碼，從 1 起算，省略時預設 1。小於 1 回傳 400 invalid_page；頁碼大到讓內部位移量溢位時同樣回傳 400 invalid_page。
- `pageSize` (integer, optional) — 每頁筆數，範圍 1 至 100，省略時預設 100。超出範圍一律回傳 400 invalid_page_size，不會自動夾限成合法值，避免分批掃描時誤判為已經抓完全部資料。

## Response

### 200

OK

- `data` (list of CompanyUserResponse, optional, nullable) — 本頁的客戶帳號資料，形狀與「查詢單一客戶帳號」的回應相同。
- `totalCount` (integer, optional) — 符合篩選條件的帳號總數，涵蓋所有頁，不受目前頁碼影響。
- `currentPage` (integer, optional) — 目前頁碼，即請求帶入的 page，從 1 起算。
- `pageSize` (integer, optional) — 目前頁面的筆數上限，即請求帶入的 pageSize。
- `totalPages` (integer, optional) — 總頁數，等於 totalCount 除以 pageSize 後無條件進位；沒有符合的資料時為 0。

## Errors

### 400 Bad Request Error

Bad Request

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

### 401 Unauthorized Error

Unauthorized

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

### 403 Forbidden Error

Forbidden

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

### 404 Not Found Error

Not Found

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

### 500 Internal Server Error

Internal Server Error

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

## Types

### CompanyUserResponse

客戶帳號的讀取內容，GET /v1/companies/\{id}/users/\{userId} 直接回傳，GET /v1/companies/\{id}/users 的每一列也是同一個形狀。不包含密碼。

- `id` (long, optional) — 客戶帳號序號。
- `companyId` (long, optional) — 所屬客戶的序號，永遠等於網址上的 `{id}`。
- `account` (string, optional, nullable) — 登入帳號。
- `name` (string, optional, nullable) — 姓名。
- `email` (string, optional, nullable) — 電子郵件，未填時為空字串。
- `phone` (string, optional, nullable) — 手機號碼，未填時為空字串。
- `roleId` (long, optional) — 目前指派的角色序號，對應 GET /v1/company-user-roles 的 id。沒有角色指派的帳號不會出現在查詢結果中。
- `roleName` (string, optional, nullable) — 目前指派的角色名稱，與 roleId 對應。
- `roleType` (string, optional, nullable) — 目前角色的類型：Boss、Employee，或租戶自訂角色的 Custom 開頭代碼。
- `status` (string, optional, nullable) — 帳號狀態，Active（生效）或 Inactive（停用）。
- `inviteCode` (string, optional, nullable) — 這個帳號的邀請碼，沒有邀請碼時為空字串。
- `firstLoginDatetime` (datetime, optional, nullable) — 首次登入時間（UTC）。null 表示還沒完成前台的首次登入流程；若貴租戶要求首次登入變更密碼，他第一次登入時會被要求改密碼。

## Examples

**Response**

```json
{
  "data": [
    {
      "id": 1,
      "companyId": 1,
      "account": "string",
      "name": "string",
      "email": "string",
      "phone": "string",
      "roleId": 1,
      "roleName": "string",
      "roleType": "string",
      "status": "string",
      "inviteCode": "string",
      "firstLoginDatetime": "2024-01-15T09:30:00Z"
    }
  ],
  "totalCount": 1,
  "currentPage": 1,
  "pageSize": 1,
  "totalPages": 1
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/companies/1/users"

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

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

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/companies/1/users';
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/companies/1/users"

	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/companies/1/users")

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/companies/1/users")
  .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/companies/1/users', [
  'headers' => [
    'X-Signature' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/companies/1/users");
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/companies/1/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()
```