> 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}/credit-quota

依客戶序號查詢目前的合約額度水位。查無此客戶（含跨租戶命中）一律回傳 404 company_not_found，兩種情況無法從回應內容區分。客戶存在但從未設定過合約額度時仍是 200，不是 404：creditAmount 為 0、enabled 為 false（合約額度側「缺列即不卡控」，與點數額度側的預設相反）、memo 為空字串、updatedAt 為 null。

Reference: https://docs.orderupb2b.com/api-reference/credit-quota/get-credit-quota

## 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 排查步驟，請參閱「驗證與簽章」。

## Request

### Path parameters

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

## Response

### 200

OK

- `companyId` (long, optional) — 客戶序號，即 CompanyResponse 的 id。
- `companyOuterSysCode` (string, optional, nullable) — 這個客戶的 ERP 代碼，即 outerSysCode。
- `creditAmount` (double, optional) — 目前的絕對合約額度，數值（小數 4 位），由批次同步端點寫入的最新值。
- `pendingAmount` (double, optional) — 已下單但尚未出貨、佔用中的額度金額。
- `availableAmount` (double, optional) — 目前還能使用的額度，等於 creditAmount 減去 pendingAmount；可能為負，代表佔用已經超過額度，刻意不夾在 0。
- `enabled` (boolean, optional) — 是否啟用合約額度卡控。這個欄位真的會影響下單：下單流程會讀它，false 時不檢查合約額度、直接放行。與點數額度側的同名欄位不對稱——那邊目前只回報不卡控，詳見批次同步端點的說明。
- `memo` (string, optional, nullable) — 備註，最長 200 字元，由批次同步端點寫入。
- `updatedAt` (datetime, optional, nullable) — 最後一次同步的時間；從未設定過時為 null。

## Errors

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

- `type` (string, optional, nullable) — 錯誤類型的識別 URI，通常可以忽略。
- `title` (string, optional, nullable) — 簡短的錯誤摘要。
- `status` (integer, optional, nullable) — 對應的 HTTP 狀態碼。
- `detail` (string, optional, nullable) — 詳細的錯誤說明文字。
- `instance` (string, optional, nullable) — 發生錯誤的請求路徑。

### 500 Internal Server Error

Internal Server Error

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

## Examples

**Response**

```json
{
  "companyId": 1,
  "companyOuterSysCode": "string",
  "creditAmount": 1.1,
  "pendingAmount": 1.1,
  "availableAmount": 1.1,
  "enabled": true,
  "memo": "string",
  "updatedAt": "2024-01-15T09:30:00Z"
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/companies/1/credit-quota"

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

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

print(response.json())
```

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

	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/credit-quota")

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

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

```csharp
using RestSharp;

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