> For the complete documentation index, see [llms.txt](https://docs.datasuite.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasuite.vn/chia-se-va-quan-ly-truy-cap/truy-cap-qua-api/tao-va-quan-ly-personal-api-key.md).

# Tạo và quản lý Personal API Key

Để sử dụng API, người dùng cần tạo Personal Access Token (token cá nhân) để truyền cho API. Việc sử dụng token cá nhân giúp cho hoạt động gọi API ổn định và có thể quản lý hiệu quả về thời gian hiệu lực (expiration) và chủ động rotate/revoke khi có sự cố lộ key hoặc key hết hạn.

### Tạo API Key

Truy cập <https://datasuite.fptcloud.com/settings/api-keys> hoặc nhấn vào Avatar người dùng ⇒ API Keys

<figure><img src="https://2137341912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIwHpnhGKp0mcSL3nAcxD%2Fuploads%2FBJdOTPZPHwA8SsoSpTk0%2Fds-api-key-1.png?alt=media&amp;token=14bc57ac-10fd-4fea-a470-544c161827f4" alt=""><figcaption></figcaption></figure>

Nhấn Tạo API Key ⇒ Điền thông tin và chọn thời hạn (Expiration Date).

<figure><img src="https://2137341912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIwHpnhGKp0mcSL3nAcxD%2Fuploads%2FXMzY5NsIm1LQdy5mY0SA%2Fds-api-key-2.png?alt=media&amp;token=176ef48e-98cf-4997-8f4c-2537e0173ffa" alt=""><figcaption></figcaption></figure>

Sau khi tạo thành công, hệ thống sẽ hiển thị API key. Người dùng cần copy key này và lưu vào nơi an toàn, vì hệ thống sẽ không hiển thị lại key sau khi tắt.

<figure><img src="https://2137341912-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIwHpnhGKp0mcSL3nAcxD%2Fuploads%2FUesLMjs0ou5BFy2vUBWk%2Fds-api-key-3.png?alt=media&amp;token=e2af31d0-fd67-41c6-9a12-0532887f34cb" alt=""><figcaption></figcaption></figure>

### Sử dụng API Key

Khi gọi API của Data Suite, người dùng truyền API Key vào header "Authorization". Ví dụ:

```
curl --location 'https://datasuite-api.fptcloud.com/api/v2/user' \
--header 'Authorization: Bearer <YOUR_API_KEY>'
```

Danh sách API đầy đủ, xem tại [Bảng tham chiếu API](/chia-se-va-quan-ly-truy-cap/truy-cap-qua-api/bang-tham-chieu-api.md).

### Quản lý API Key

Người dùng có thể Revoke (thu hồi), Rotate (làm mới) API key trước đó.

Mỗi tài khoản có thể có tối đa 10 API Keys đang hoạt động.

### Phạm vi quyền truy cập

Personal API Key được tạo dưới tư cách của người dùng đang đăng nhập, do đó key này đại diện cho chính người dùng. Mọi thao tác gọi API sử dụng Personal API Key, hệ thống sẽ kiểm tra quyền (RBAC/RLS) của chính người dùng đã tạo key.
