> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 建立 User Profile

> 在你的 Primary Profile 底下建立一個新的 User Profile。

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

<PlansAvailable plans={["business"]} maxPackRequired={false} />

在你的 Primary Profile 底下建立一個新的 Profile。User Profile 建立成功後，API 回應會包含與新建立的 Profile 關聯的 Profile Key。請將 Profile Key 安全地儲存在你的系統中，因為之後代表該使用者呼叫 API 時會用到它。

請注意，基於安全考量，Profile Key 僅會在下列兩種情境下回傳：

1. User Profile 建立時：當一個新的 User Profile 建立時。
2. 在 Ayrshare 控制台中：你可以在 Ayrshare 控制台中查看每個 Profile 的 Profile Key。切換到該 User Profile，然後前往 Profile Key 頁面。

我們建議你將 Profile Key 安全地儲存在你的系統中。

## 管理社群網路

使用 disableSocial 欄位來管理（新增／移除）顯示的社群網路。詳情請參閱[管理社群帳號](/apis/profiles/overview#enable-or-disable-social-networks)。

## 管理使用中的 User Profile

請參閱此處的[管理使用中的 User Profile](/multiple-users/manage-user-profiles#managing-active-user-profiles) 建議。

## 重要的安全性注意事項

<Warning>
  <ul className="custom-bullets">
    <li>請勿公開分享 Profile Key，或將其暴露於用戶端程式碼或公開的程式碼儲存庫中。</li>
    <li>Profile Key 是敏感憑證，用於驗證與授權對 User Profile 的存取。</li>
    <li>務必將 Profile Key 安全地儲存在你的系統中，並設定適當的存取控管，以維護使用者資料的完整性與機密性。</li>
    <li>基於安全考量，Profile Key 無法再透過 API 取得。不過，你可以從[控制台](/multiple-users/manage-user-profiles#get-the-profile-key)取得 Profile Key。</li>
    <li>也應儲存 `refId`，以便將 Profile 與端點回傳結果關聯起來。</li>
  </ul>
</Warning>

## 標頭參數

<HeaderAPI noProfileKey />

## Body 參數

<ParamField body="title" type="string" required>
  新 Profile 的標題。必須唯一。此標題會顯示在社群帳號連結頁面上。
</ParamField>

<ParamField body="messagingActive" type="boolean" default={false}>
  設為 true 可為此 user profile 啟用私訊功能。你的 Ayrshare 帳號必須先啟用私訊功能。
</ParamField>

<ParamField body="hideTopHeader" type="boolean" default={false}>
  在社群帳號連結頁面上隱藏頂部標題列。
</ParamField>

<ParamField body="hideLogo" type="boolean" default={false}>
  僅在此 user profile 的社群帳號連結頁面上隱藏公司 Logo。其他 Profile 上的帳號層級 Logo 不受影響。適用於針對特定合作夥伴 Profile 進行白牌處理，同時保留其餘 Profile 的品牌識別。
</ParamField>

<ParamField body="topHeader" type="string">
  變更社群帳號連結頁面的標題。如果未設定，會顯示：「Social Accounts for "title"」，其中 "title" 為 Profile 的標題。
</ParamField>

<ParamField body="disableSocial" type="array">
  針對此使用者 Profile 停用的社群網路陣列。Primary Profile 的停用社群網路清單具有優先順序。

  可用網路：`bluesky`、`facebook`、`gmb`、`instagram`、`linkedin`、`pinterest`、`reddit`、`snapchat`、`telegram`、`threads`、`tiktok`、`twitter` 與 `youtube`。

  更多資訊請參閱[啟用或停用社群網路](/apis/profiles/overview#enable-or-disable-social-networks)。
</ParamField>

<ParamField body="team" type="boolean" default={false}>
  將 `team: true` 設定為 true，即可將新的 user profile 建立為團隊成員。`email` 欄位會用於寄送邀請信。相關要求詳情請參閱[邀請團隊成員](/multiple-users/manage-user-profiles#invite-a-team-member)。
</ParamField>

<ParamField body="email" type="string">
  用於寄送團隊成員邀請的有效電子郵件地址。若 `team: true` 則必填。
</ParamField>

<ParamField body="subHeader" type="string">
  變更社群帳號連結頁面的副標題。目前顯示為「Click an icon to link a social network」。設為空字串可將其移除。

  參閱如何變更[說明連結](/multiple-users/manage-user-profiles#help-links-visible)。
</ParamField>

<ParamField body="tags" type="array">
  使用字串陣列為使用者 Profile 加上標籤。這些標籤是內部的組織工具，可有效地分類與管理你的使用者 Profile。
</ParamField>

<RequestExample>
  ```javascript cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"title": "ACME Profile"}' \
  -X POST https://api.ayrshare.com/api/profiles
  ```

  ```javascript JavaScript theme={"system"}
  const API_KEY = "API_KEY";

  fetch("https://api.ayrshare.com/api/profiles", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Authorization": `Bearer ${API_KEY}`
        },
        body: JSON.stringify({
          title: "ACME Profile", // required
        }),
      })
        .then((res) => res.json())
        .then((json) => console.log(json))
        .catch(console.error);
  ```

  ```python Python theme={"system"}
  import requests

  payload = {'title': 'ACME Profile'}
  headers = {'Content-Type': 'application/json',
          'Authorization': 'Bearer API_KEY'}

  r = requests.post('https://api.ayrshare.com/api/profiles',
      json=payload,
      headers=headers)

  print(r.json())
  ```

  ```php PHP theme={"system"}
  <?php
  require 'vendor/autoload.php';    // Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html

  $client = new GuzzleHttp\Client();
  $res = $client->request(
      'POST',
      'https://api.ayrshare.com/api/profiles',
      [
          'headers' => [
              'Content-Type'      => 'application/json',
              'Authorization'     => 'Bearer API_KEY'
          ],
          'title' => ['ACME Profile'],
      ]
  );

  echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
  ```

  ```go Go theme={"system"}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"log"
  	"net/http"
  )

  func main() {
  	message := map[string]interface{}{
  		"title": "ACME Profile"
  	}

  	bytesRepresentation, err := json.Marshal(message)
  	if err != nil {
  		log.Fatalln(err)
  	}

  	req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/profiles",
  		bytes.NewBuffer(bytesRepresentation))

  	req.Header.Add("Content-Type", "application/json; charset=UTF-8")
  	req.Header.Add("Authorization", "Bearer API_KEY")

  	res, err := http.DefaultClient.Do(req)
  	if err != nil {
  		log.Fatal("Error:", err)
  	}

  	res.Body.Close()
  }
  ```

  ```csharp C# theme={"system"}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  namespace CreateProfilePOSTRequest_csharp 
  {
    class CreateProfile
    {
        static async Task Main(string[] args)
        {
            string API_KEY = "API_KEY";
            string url = "https://api.ayrshare.com/api/profiles";
            string json = "{\"title\": \"ACME Profile\"}";

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);

                try
                {
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = await client.PostAsync(url, content);
                    
                    response.EnsureSuccessStatusCode();
                    string responseBody = await response.Content.ReadAsStringAsync();
                    Console.WriteLine(responseBody);
                }
                catch (HttpRequestException e)
                {
                    Console.WriteLine($"Error: {e.Message}");
                }
            }
        }
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
      "status": "success",
      "title": "Digg It",
      "refId": "140b8709bd6ade099b242d895e268fb886130c53",
      "profileKey": "7TVRLEZ-24A43C0-NJW0Z82-F11984N",
      "messagingActive": true // true if messaging for this user profile is active
  }
  ```

  ```json 400: Profile Title Already Exists theme={"system"}
  {
    "action": "create",
    "status": "error",
    "code": 146,
    "message": "Profile title already exists."
  }
  ```
</ResponseExample>
