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

# Tạo User Profile

> Tạo một User Profile mới trong Primary Profile của bạn.

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

Tạo một profile mới trong Primary Profile của bạn. Sau khi tạo thành công User Profile, phản hồi API sẽ bao gồm Profile Key liên kết với profile vừa được tạo. Hãy lưu trữ Profile Key một cách an toàn trong hệ thống của bạn, vì nó sẽ được yêu cầu để thực hiện các lệnh gọi API thay mặt cho người dùng của bạn.

Xin lưu ý rằng vì lý do bảo mật, Profile Key chỉ được trả về trong hai trường hợp cụ thể:

1. Tạo User Profile: Khi một User Profile mới được tạo.
2. Trong Ayrshare Dashboard: Bạn có thể tìm thấy Profile Key cho từng profile trong Ayrshare Dashboard. Chuyển sang User Profile rồi điều hướng đến trang Profile Key.

Chúng tôi khuyến nghị bạn lưu trữ Profile Key an toàn trong hệ thống của mình.

## Quản lý mạng xã hội

Sử dụng trường disableSocial để quản lý (thêm/xóa) các mạng xã hội khỏi hiển thị. Vui lòng xem [Quản lý Social Accounts](/apis/profiles/overview#enable-or-disable-social-networks) để biết thêm thông tin.

## Quản lý User Profile đang hoạt động

Vui lòng xem tại đây một số khuyến nghị về [quản lý User Profile đang hoạt động](/multiple-users/manage-user-profiles#managing-active-user-profiles).

## Lưu ý bảo mật quan trọng

<Warning>
  <ul className="custom-bullets">
    <li>Tránh chia sẻ Profile Key công khai hoặc lộ chúng trong mã phía client hoặc kho lưu trữ công khai.</li>
    <li>Profile Key là thông tin xác thực nhạy cảm được dùng để xác thực và ủy quyền truy cập vào User Profile.</li>
    <li>Điều quan trọng là phải lưu trữ Profile Key an toàn trong hệ thống của bạn với các kiểm soát truy cập phù hợp để duy trì tính toàn vẹn và bảo mật dữ liệu của người dùng.</li>
    <li>Vì lý do bảo mật, Profile Key không thể được truy xuất lại bằng API. Tuy nhiên, bạn có thể truy xuất Profile Key từ [bảng điều khiển](/multiple-users/manage-user-profiles#get-the-profile-key).</li>
    <li>Bạn cũng nên lưu trữ `refId` để liên kết một profile với kết quả trả về của endpoint.</li>
  </ul>
</Warning>

## Tham số Header

<HeaderAPI noProfileKey />

## Tham số Body

<ParamField body="title" type="string" required>
  Tiêu đề của profile mới. Phải là duy nhất. Tiêu đề này sẽ được hiển thị trên trang liên kết social account.
</ParamField>

<ParamField body="messagingActive" type="boolean" default={false}>
  Đặt thành true để kích hoạt nhắn tin cho user profile này. Nhắn tin phải được bật trước cho tài khoản Ayrshare của bạn.
</ParamField>

<ParamField body="hideTopHeader" type="boolean" default={false}>
  Ẩn tiêu đề trên cùng trên trang liên kết social accounts.
</ParamField>

<ParamField body="hideLogo" type="boolean" default={false}>
  Ẩn logo công ty trên trang liên kết social accounts chỉ dành cho user profile này. Logo toàn tài khoản trên các profile khác không bị ảnh hưởng. Hữu ích để white-label các profile đối tác riêng lẻ mà vẫn giữ thương hiệu trên các profile còn lại.
</ParamField>

<ParamField body="topHeader" type="string">
  Thay đổi tiêu đề trên trang liên kết social accounts. Nếu không đặt, sẽ hiển thị: "Social Accounts for "title" trong đó "title" là tiêu đề profile.
</ParamField>

<ParamField body="disableSocial" type="array">
  Mảng các mạng xã hội bị vô hiệu hóa cho profile của người dùng này. Danh sách các mạng xã hội bị vô hiệu hóa của primary profile được ưu tiên.

  Các mạng có sẵn: `bluesky`, `facebook`, `gmb`, `instagram`, `linkedin`, `pinterest`, `reddit`, `snapchat`, `telegram`, `threads`, `tiktok`, `twitter`, và `youtube`.

  Xem [bật hoặc tắt mạng xã hội](/apis/profiles/overview#enable-or-disable-social-networks) để biết thêm thông tin.
</ParamField>

<ParamField body="team" type="boolean" default={false}>
  Tạo một user profile mới với tư cách là thành viên nhóm bằng cách đặt `team: true`. Trường `email` sẽ được sử dụng để gửi email mời. Xem [mời thành viên nhóm](/multiple-users/manage-user-profiles#invite-a-team-member) để biết chi tiết về yêu cầu.
</ParamField>

<ParamField body="email" type="string">
  Một địa chỉ email hợp lệ nơi lời mời thành viên nhóm sẽ được gửi đến. Bắt buộc nếu `team: true`
</ParamField>

<ParamField body="subHeader" type="string">
  Thay đổi phụ đề trên trang liên kết social accounts. Hiện đang hiển thị "Click an icon to link a social network". Đặt thành chuỗi rỗng để loại bỏ.

  Xem cách thay đổi [liên kết trợ giúp](/multiple-users/manage-user-profiles#help-links-visible).
</ParamField>

<ParamField body="tags" type="array">
  Gắn thẻ user profile bằng cách sử dụng một mảng các chuỗi. Các thẻ này đóng vai trò là công cụ tổ chức nội bộ để phân loại và quản lý các user profile của bạn hiệu quả.
</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>
