Skip to content

API Token Authentication

Overview

API Tokens are a Bearer Token-based authentication method that allows you to remotely manage data in SakuraNav via API. Suitable for:

  • Script automation (batch import/export, scheduled backups)
  • Third-party tool integration
  • CI/CD pipelines

Creating a Token

  1. Log in and navigate to Personal SpaceAPI Tokens tab
  2. Click the "Create Token" button
  3. Enter a token name and select an expiration time (1 month / 90 days / 1 year / Never expire)
  4. After creation, copy and save the token immediately — it cannot be viewed again after closing the dialog

⚠️ Each user can create up to 10 tokens. Token permissions are equivalent to the creator's permissions.

Usage

Include Authorization: Bearer <token> in the API request header:

bash
curl -H "Authorization: Bearer sak_your_token_here" \
     https://your-domain.com/api/tags

Supported Endpoints

The following endpoints support Token authentication:

CategoryMethodPathDescription
TagsGET/POST/api/tagsList/Create tags
PUT/DELETE/api/tagsUpdate/Delete tags
POST/api/tags/reorderReorder tags
PUT/api/tags/[tagId]/sites/reorderReorder sites in tag
PUT/api/tags/[tagId]/sites/restoreRestore tag associations
SitesGET/POST/api/site-cardsList/Create sites
PUT/DELETE/api/site-cardsUpdate/Delete sites
POST/api/site-cards/batchBatch create sites
POST/api/site-cards/reorder-globalGlobal site reorder
POST/api/site-cards/check-onlineBatch online check
POST/api/site-cards/check-online-singleSingle site online check
PATCH/api/site-cards/memoUpdate site memo
Social CardsGET/POST/api/social-cardsList/Create cards
PUT/DELETE/api/social-cardsUpdate/Delete cards
PUT/api/social-cards/reorderReorder cards
Note CardsGET/POST/api/note-cardsList/Create notes
PUT/DELETE/api/note-cardsUpdate/Delete notes
POST/api/note-cards/upload-imageUpload note image
POST/api/note-cards/upload-fileUpload note file
GET/POST/PATCH/DELETE/api/note-cards/attachmentAttachment management
SnapshotsGET/POST/api/snapshotsList/Create snapshots
DELETE/PATCH/api/snapshotsDelete/Rename snapshots
NavigationGET/api/navigation/tagsGet tags (returns user's own data with Token)
GET/api/navigation/cardsGet all cards (sites + social + notes)
GET/api/navigation/site-cardsGet site cards (only empty card_type)
GET/api/navigation/social-cardsGet social cards
GET/api/navigation/note-cardsGet note cards
SearchGET/api/search/suggestSearch suggestions
User DataPOST/api/user/data/exportExport user data
POST/api/user/data/importImport user data
POST/api/user/data/detectDetect import file type
POST/api/user/data/clearClear user tags and sites
POST/api/user/data/resetReset user data
User ProfileGET/api/user/profileGet user profile
Token ManagementGET/POST/api/user/tokensList/Create tokens
DELETE/api/user/tokens/[id]Delete token

Unsupported Endpoints

The following operations must be performed via browser Cookie session (for security):

  • Authentication (login/logout/register/OAuth)
  • Admin panel (user management/global settings/OAuth config)
  • Password change, username change
  • Avatar upload/delete
  • OAuth bind/unbind
  • Account deletion
  • Appearance config, floating buttons
  • Notification config
  • AI features
  • Asset file uploads
  • System config import/export/reset

Request Examples

Get tag list:

bash
curl -H "Authorization: Bearer sak_xxx" \
     https://your-domain.com/api/tags

Create a site:

bash
curl -X POST \
     -H "Authorization: Bearer sak_xxx" \
     -H "Content-Type: application/json" \
     -d '{"name":"GitHub","url":"https://github.com","tagIds":["tag-1"]}' \
     https://your-domain.com/api/site-cards

Export user data:

bash
curl -X POST \
     -H "Authorization: Bearer sak_xxx" \
     -o backup.zip \
     https://your-domain.com/api/user/data/export

Security Notes

  • Token is shown only once: Save it immediately after creation; the database does not store plaintext
  • Do not leak tokens: Never commit tokens to version control or share them publicly
  • Rotate regularly: Periodically delete old tokens and create new ones
  • Least privilege: Token permissions equal the creator's; create dedicated accounts to limit access
  • Delete promptly: Delete tokens that are no longer in use