s.id Logo
s.id
Nền tảng nhà phát triển

Xây dựng trên s.id — REST API, Webhook & OAuth

Tạo liên kết rút gọn, theo dõi lượt nhấp và tự động hóa quy trình làm việc với nền tảng nhà phát triển s.id. Xác thực API key đơn giản, webhook thời gian thực và OAuth 2.0 cho ứng dụng bên thứ ba.

REST API

Quản lý liên kết, mã QR và dữ liệu người dùng với API JSON sạch sẽ. Xác thực Bearer token, 38 yêu cầu/phút.

Tìm hiểu thêm

Webhooks

Đăng ký link.created, link.clicked, qr.scanned và nhiều hơn nữa. Payload được ký bằng HMAC.

Tìm hiểu thêm

OAuth 2.0

Luồng authorization-code với PKCE và xoay vòng refresh token cho phép ứng dụng của bạn hoạt động thay mặt người dùng s.id.

Tìm hiểu thêm

Bắt đầu nhanh

Tạo liên kết rút gọn chỉ trong một lần gọi API.

1

Mở Dashboard → Developer → API Keys

2

Tạo key với các phạm vi bạn cần

3

Gọi API với Bearer sk_live_...

URL cơ sở: https://api.s.id/v2

curl -X POST https://api.s.id/v2/links \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"long_url": "https://example.com/long-url", "custom_slug": "mylink"}'

Các endpoint

Tất cả endpoint đều yêu cầu API key với phạm vi phù hợp.

Phương thứcĐường dẫn
GET/links
POST/links
POST/links/available
GET/links/{short}
PUT/links/{short}
DELETE/links/{short}
POST/links/{short}/unarchive
GET/links/{short}/stats
GET/links/{short}/stats/lifetime
GET/user
GET/quota
GET/microsites
POST/microsites
GET/microsites/{slug}
PUT/microsites/{slug}
DELETE/microsites/{slug}
POST/links/bulk
GET/stats
GET/qr
PUT/qr
GET/links/{short}/qr
PUT/links/{short}/qr
POST/microsites/available
GET/microsites/{slug}/components
POST/microsites/{slug}/components
PUT/microsites/{slug}/components/{componentId}
DELETE/microsites/{slug}/components/{componentId}
POST/microsites/{slug}/components/order
GET/oauth/authorize
POST/oauth/token
POST/oauth/revoke
GET/oauth/userinfo
GET/api/user/oauth/apps
DELETE/api/user/oauth/apps/{clientId}
Tài liệu API đầy đủ ↗

Phạm vi API

Mỗi API key có phạm vi riêng — chỉ yêu cầu quyền mà tích hợp của bạn cần.

links:readList and read links
links:writeCreate and update links (create, edit, restore)
links:archiveArchive links
links:analyticsRead per-link click statistics and lifetime counts
qr:readRead QR code settings (global and per-link)
qr:writeCustomize QR code settings (global and per-link)
user:readRead the authenticated user profile and account quota
microsites:readRead microsites
microsites:writeCreate, update, delete and manage components of microsites

Webhooks

Đăng ký endpoint HTTPS để nhận sự kiện thời gian thực. Mỗi lần gửi được ký POST bằng HMAC-SHA256.

Các sự kiện có sẵn

link.createdFired when a new link is created
link.updatedFired when a link's URL or title is changed
link.archivedFired when a link is archived
link.clickedFired on each redirect (per-click event)
microsite.publishedFired when a microsite is published
qr.scannedFired when a QR code is scanned

Ví dụ payload

{
  "event": "link.created",
  "link": {
    "id": 123,
    "short": "mylink",
    "short_url": "https://s.id/mylink",
    "long_url": "https://example.com/long-url",
    "title": "My Link",
    "created": "2026-06-22T10:00:00Z"
  },
  "timestamp": "2026-06-22T10:00:00Z"
}

Xác minh chữ ký (Node.js)

const crypto = require('crypto');

function verifySignature(secret, rawBody, sigHeader) {
  const expected = 'sha256=' +
    crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(sigHeader),
    Buffer.from(expected),
  );
}

Secret được hiển thị một lần khi bạn tạo webhook. Xác minh trước khi xử lý sự kiện.

Hướng dẫn đầy đủ về webhooks

Xác thực

Hai cách xác thực: API key cho luồng máy chủ tới máy chủ, OAuth 2.0 cho luồng thay mặt người dùng.

API Keys

Tạo key tại Dashboard → Developer → API Keys. Truyền nó dưới dạng Bearer token. Key có phạm vi và có thể thu hồi bất cứ lúc nào.

Authorization: Bearer sk_live_...

OAuth 2.0

Sử dụng luồng authorization-code để hoạt động thay mặt người dùng s.id. Chuyển hướng đến /oauth/authorize, đổi code tại /oauth/token.

Hướng dẫn OAuth 2.0

Sẵn sàng bắt đầu xây dựng?

Tạo API key trong vài phút. Đã có gói miễn phí — không cần thẻ tín dụng.