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

# 建立後台使用者

POST https://api.example.com/v1/internal-users
Content-Type: application/json

建立一個後台使用者。account、name、email、password、roleId 皆為必填：account／name／email／password 任一未帶，回傳對應的 400 account_required／name_required／email_required／password_required；roleId 必須指向呼叫端所屬租戶的既有角色（見 GET /v1/internal-roles），省略、帶入不存在的 id，或帶入其他租戶的 id，一律回傳 400 invalid_role_id（三種情況統一回同一個代碼）。與客戶、商品、規格不同，這支端點沒有 outerSysCode 去重更新——一律視為新增；同租戶內 account 重複會回傳 400 account_already_used，重送同一份資料不會更新既有帳號，而是被拒絕。

Reference: https://docs.orderupb2b.com/api-reference/internal-users/create-internal-user

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

### Body (application/json)

This endpoint expects an object.

- `account` (string, optional, nullable) — 帳號，用於登入後台。建立時必填，省略回傳 400 account_required；只能在建立時設定，更新後台使用者無法改帳號。同租戶內不能重複，重複會回傳 400 account_already_used；重複比對不分大小寫，也會忽略前後空白，所以 ABC 與 abc 視為同一個帳號。長度上限 50 字元，超過回傳 400 account_too_long。
- `name` (string, optional, nullable) — 姓名。建立時必填，省略回傳 400 name_required。長度上限 30 字元，超過回傳 400 name_too_long。
- `email` (string, optional, nullable) — 電子郵件。建立時必填，省略回傳 400 email_required。長度上限 100 字元，超過回傳 400 email_too_long。
- `password` (string, optional, nullable) — 登入密碼。建立時必填，省略回傳 400 password_required。
- `roleId` (long, optional) — 角色序號，必須指向呼叫端所屬租戶的既有角色，透過 GET /v1/internal-roles 取得合法的 id。建立時為必填欄位；省略、帶入不存在的 id，或帶入其他租戶的 id，一律回傳 400 invalid_role_id（三種情況統一回同一個代碼）。
- `outerSysCode` (string, optional, nullable) — ERP 端的使用者代碼，僅供你端對照使用，本 API 不會拿它去比對或去重。省略視為空字串。長度上限 50 字元，超過回傳 400 outer_sys_code_too_long。

## Response

### 201

Created

- `id` (long, optional) — 新增或更新成功後，該筆資料的 id。

## 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 字串，依代碼判斷失敗原因。

### 500 Internal Server Error

Internal Server Error

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

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": 1
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/internal-users"

payload = {}
headers = {
    "X-Signature": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/internal-users';
const options = {
  method: 'POST',
  headers: {'X-Signature': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{}'
};

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://api.example.com/v1/internal-users"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Signature", "<apiKey>")
	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://api.example.com/v1/internal-users")

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

request = Net::HTTP::Post.new(url)
request["X-Signature"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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.post("https://api.example.com/v1/internal-users")
  .header("X-Signature", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/internal-users', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Signature' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/internal-users");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Signature", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Signature": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/internal-users")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```