Backend nhận form API
Trỏ form HTML bất kỳ tới /f/{id}: dữ liệu được lưu, gửi e-mail cho bạn và chuyển tiếp webhook, có honeypot chống spam, Turnstile, giới hạn origin.
POST /v1/form-endpoint tạo một form và trả về địa chỉ công khai endpoint_url (https://apibox.io.vn/f/{id}) cùng đoạn HTML mẫu. Đặt địa chỉ đó vào <form action> trên website tĩnh hay landing page: bộ nhận chấp nhận application/x-www-form-urlencoded, multipart/form-data (trường file bị bỏ qua và được ghi chú) và JSON (fetch có CORS), tối đa 128 KB và 100 trường. Form gửi từ trình duyệt được chuyển hướng tới redirect_url của bạn (hoặc trường _next thuộc origin được phép) hoặc hiện trang cảm ơn song ngữ; lệnh gọi JSON / XHR nhận {"ok": true, "id"}. Trường _subject đặt tiêu đề e-mail.
Chống spam: trường honeypot ẩn (mặc định _gotcha; bị điền = bỏ qua trong im lặng và được đếm), kiểm tra Cloudflare Turnstile tuỳ chọn bằng secret key của chính bạn (turnstile_secret; thêm widget vào form), allowed_origins (origin chính xác hoặc https://*.example.vn), required_fields và giới hạn tần suất theo form và theo IP. Mỗi bản ghi được lưu sẽ gửi e-mail tới địa chỉ đã xác minh của tài khoản (notify_email, dùng chung hạn mức e-mail mỗi ngày với giám sát uptime) và / hoặc POST dạng JSON tới webhook_url của bạn ({"event": "form.submission", "form", "submission"}).
GET /v1/form-endpoint/{id}/submissions liệt kê dữ liệu mới nhất trước (limit, con trỏ before, since), format=csv xuất ra CSV mở bằng Excel (UTF-8 BOM), DELETE để xoá một hoặc tất cả. PATCH /v1/form-endpoint/{id} để đổi cấu hình (paused=true để tạm ngừng nhận). Form gắn với tài khoản; mỗi lần nhận dữ liệu thành công tính một request vào hạn mức của chủ form. Theo gói: Free 2 form, giữ 100 bản ghi mới nhất mỗi form; Starter 20 form, 2.000 bản ghi; Pro 100 form, 10.000 bản ghi.
Tham số
| Tên | Vị trí | Kiểu | Bắt buộc | Mặc định | |
|---|---|---|---|---|---|
name | body | string | không | Tên hiển thị (tối đa 100 ký tự). | |
allowed_origins | body | array | không | Các origin được phép gửi, ví dụ https://example.com, https://*.example.vn (để trống = mọi origin). | |
redirect_url | body | string | không | Trang cảm ơn sau khi gửi từ trình duyệt (chuyển hướng 303). | |
honeypot_field | body | string | không | _gotcha | Tên trường ẩn; có giá trị nghĩa là spam. |
required_fields | body | array | không | Các trường bắt buộc phải có và không rỗng. | |
turnstile_secret | body | string | không | Secret key Cloudflare Turnstile của bạn; khi có, dữ liệu gửi phải kèm cf-turnstile-response hợp lệ (để trống để gỡ). Không bao giờ được trả về. | |
notify_email | body | boolean | không | true | Gửi e-mail mỗi bản ghi tới địa chỉ đã xác minh của tài khoản. |
webhook_url | body | string | không | URL nhận request POST JSON cho mỗi bản ghi; để trống để gỡ. | |
paused | body | boolean | không | false | Tạm ngừng nhận dữ liệu. |
id | path | string | không | /{id} (GET, PATCH, POST, DELETE), /{id}/submissions (GET danh sách / CSV, DELETE tất cả), /{id}/submissions/{sid} (GET, DELETE). | |
format | query | string | không | json | /{id}/submissions: json hoặc csv. |
limit | query | number | không | 50 | /{id}/submissions: 1–500 (CSV tới 10.000). |
before | query | string | không | /{id}/submissions: con trỏ (next_before của trang trước). |
Ví dụ
curl -X POST "https://apibox.io.vn/v1/form-endpoint" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Liên hệ","allowed_origins":["https://shop.example.com","https://*.example.vn"],"redirect_url":"https://shop.example.com/cam-on","required_fields":["email"],"webhook_url":"https://hooks.example.net/form"}'const res = await fetch('https://apibox.io.vn/v1/form-endpoint', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Liên hệ",
"allowed_origins": [
"https://shop.example.com",
"https://*.example.vn"
],
"redirect_url": "https://shop.example.com/cam-on",
"required_fields": [
"email"
],
"webhook_url": "https://hooks.example.net/form"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/form-endpoint",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"name": "Liên hệ", "allowed_origins": ["https://shop.example.com", "https://*.example.vn"], "redirect_url": "https://shop.example.com/cam-on", "required_fields": ["email"], "webhook_url": "https://hooks.example.net/form"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/form-endpoint');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"name":"Liên hệ","allowed_origins":["https://shop.example.com","https://*.example.vn"],"redirect_url":"https://shop.example.com/cam-on","required_fields":["email"],"webhook_url":"https://hooks.example.net/form"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Kết quả trả về
{
"id": "0rwawcx0zfofbpnsuu1e",
"name": "Liên hệ",
"endpoint_url": "https://apibox.io.vn/f/0rwawcx0zfofbpnsuu1e",
"allowed_origins": [
"https://shop.example.com",
"https://*.example.vn"
],
"redirect_url": "https://shop.example.com/cam-on",
"honeypot_field": "_gotcha",
"required_fields": [
"email"
],
"turnstile": false,
"notify_email": true,
"webhook_url": "https://hooks.example.net/form",
"paused": false,
"submission_count": 0,
"spam_count": 0,
"last_submission_at": null,
"created_at": "2026-11-11T03:21:15.000Z",
"html_example": "<form action=\"https://apibox.io.vn/f/0rwawcx0zfofbpnsuu1e\" method=\"POST\">\n <input type=\"email\" name=\"email\" required>\n <textarea name=\"message\"></textarea>\n <input type=\"text\" name=\"_gotcha\" style=\"display:none\" tabindex=\"-1\" autocomplete=\"off\">\n <button type=\"submit\">Send</button>\n</form>"
}
Ứng dụng
- Nhận form liên hệ, đặt hàng trên landing page mà không cần máy chủ
- Đưa khách hàng tiềm năng từ website tĩnh về hộp thư và webhook CRM
- Xuất danh sách đăng ký chiến dịch ra Excel dạng CSV
- Bảo vệ form công khai bằng honeypot, Turnstile và danh sách origin
Hỏi đáp
Trang của tôi có cần JavaScript không?
Không. Một thẻ <form action="https://apibox.io.vn/f/{id}" method="POST"> bình thường là đủ; gửi JSON bằng fetch() cũng được, có CORS cho các origin bạn cho phép.
Người dùng có tải file lên được không?
Chưa: trường file bị bỏ qua và tên được ghi vào _files_ignored. Hãy dùng đường link tới file thay thế.
Dữ liệu form được gửi về e-mail nào?
E-mail đã xác minh của tài khoản chủ form. E-mail dùng chung hạn mức mỗi ngày với cảnh báo monitor; dashboard và API luôn có đủ mọi bản ghi đã lưu.
API liên quan
Metadata của URL
Lấy tiêu đề, mô tả, thẻ Open Graph, Twitter Card, favicon, canonical, RSS và JSON-LD của bất kỳ URL nào dưới dạng JSON.
H:HTTP Header
Xem mã trạng thái HTTP và toàn bộ response header của một URL, kèm tóm tắt các security header như HSTS, CSP, X-Frame-Options.
301Kiểm tra chuyển hướng
Theo từng lần chuyển hướng 301, 302, 307, 308 của một URL và nhận toàn bộ chuỗi kèm mã trạng thái, URL cuối và số bước.