Skip to content
Console

API tokens

An API token is used to call Bitiful's HTTP APIs, for example to query bucket capacity, pull access logs, purge the CDN cache, and fetch certificate contents. It's a different credential from an AccessKey, and the two can't be used interchangeably.

API tokenAccessKey
Where it's usedThe API at https://api.bitiful.comThe S3 protocol: SDKs, rclone, presigned URLs, and so on
Permission scopeThe whole main accountThe buckets and directories granted to its sub-user
Where to create itAvatar › API TokenObject storage › Sub-users & Keys (对象存储 › 子账户&Key)
DocsThis pageSub-users and AccessKeys

Create a token

Open the API Token page

Click the avatar in the upper-right corner › API Token, or open https://console.bitiful.com/apiToken directly.

Create

Click Create Token (创建 Token) in the upper-right corner. After you see "创建成功" (created successfully), the new token appears in the list and is usable immediately.

Each account can have up to 3 tokens. If you already have 3, creating another shows "最多只能创建3个token" (at most 3 tokens can be created). Tokens have no name and no expiration time, so keep your own record of where each token is used.

View and copy

By default, a token in the list shows only the first and last 4 characters. Click the eye icon on the left to show the full content, then click the copy icon next to it. You can view the full content again at any time.

Use a token

Put the token as is in the Authorization request header, without a Bearer prefix:

curl -H "Authorization: <API Token>" \
  "https://api.bitiful.com/s4/data/<bucket-name>/usage"

When authentication fails, it returns HTTP 401:

{"message":"鉴权失败"}

The message means "authentication failed".

Available endpoints:

A token has API permissions for the whole account, including reading certificate private keys. Use it only on the server. Don't put it in web pages, apps, public repositories, or logs.

Delete and rotate

Click Delete (删除) in the list and confirm in "确定删除?" (delete it?). It stops working immediately after deletion, programs using it get a 401, and it can't be recovered.

To rotate tokens regularly: create a new token first, switch your programs over, and delete the old one after you confirm everything works.

Impact of an overdue balance

When your account has an overdue balance, query endpoints (GET) still work, but POST endpoints such as cache purge and certificate upload return HTTP 403:

{"message":"您的账号已欠费,暂时无法访问该接口"}

The message means "your account is overdue, this endpoint is temporarily unavailable".

FAQ

It keeps returning 401 “鉴权失败” (authentication failed)

Check in order: whether you added an extra Bearer ; whether you used an AccessKey by mistake; whether the token has been deleted; and whether you copied extra characters.

Can I limit a token to read only one bucket?

No. A token's permissions cover the whole account. To restrict permissions by bucket or directory, use a sub-user's AccessKey over the S3 protocol.

Can a token be used to upload files?

No. For uploads and downloads, use an AccessKey and an S3 SDK.