---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/vi/api-reference/security

Tài liệu API

# Bảo mật

Xem vì sao đăng nhập thất bại và gỡ chặn IP ngay từ code của bạn. Một route, POST /v1/security, cùng định dạng lệnh với các route /v1 khác.

- POST /v1/security
- smtp:read
- smtp:create

## Xác thực

smtp:read

Danh sách: `list_auth_errors` và `list_blocked_ips`.

smtp:create

Gỡ chặn: `unblock_ip`.

Gửi API key dưới dạng `Authorization: Bearer <key>`. Body là `{ "commands": [ { "command", "args", "id" } ] }`, giống mọi route /v1.

## Lệnh

`list_auth_errors` smtp:read

Các lần đăng nhập SMTP, API và MCP thất bại trong 30 ngày qua, mới nhất trước. Lỗi giống nhau được gộp thành một dòng kèm số lần.

**Tham số**
`cursor`, `limit` (1–200, mặc định 50), `source` (`smtp`, `api`, `mcp`, `api_v1`), `reason`, `ip`. Tất cả đều không bắt buộc.

**Trả về**
`items` (`id`, `at`, `first_at`, `count`, `source`, `credential`, `ip`, `reason`, `message`) và `next_cursor`.

`credential` là username SMTP hoặc `api_key …ab12`: mật khẩu hay key đầy đủ không bao giờ xuất hiện. `message` là phản hồi chính xác mà client nhận được. Cursor không hợp lệ sẽ bắt đầu lại danh sách.

Request

```
curl -s -X POST https://g.sendcorex.com/v1/security \
  -H "Authorization: Bearer $SENDCOREX_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"commands":[{"command":"list_auth_errors","args":{"source":"smtp","limit":50},"id":"1"}]}'
```

Response

```
{
  "type": "SUCCESS",
  "results": [{
    "command": "list_auth_errors", "id": "1", "type": "SUCCESS",
    "data": {
      "items": [{
        "id": "ae_01JE7Q…",
        "at": "2026-12-02T10:14:09Z",
        "first_at": "2026-12-02T09:58:41Z",
        "count": 7,
        "source": "smtp",
        "credential": "user-8f2k1",
        "ip": "203.0.113.24",
        "reason": "wrong_password",
        "message": "535 5.7.8 Authentication failed: wrong username or password. https://docs.sendcorex.com/errors#smtp_wrong_password"
      }],
      "next_cursor": "eyJ0IjoxNzMz…"
    }
  }]
}
```

`list_blocked_ips` smtp:read

Các IP đang bị chặn trên tài khoản của bạn, số lần gỡ chặn còn lại và các ngưỡng.

**Tham số**
Không có.

**Trả về**
`items` (`ip`, `reason`, `until`, `level`, `pair_blocked`, `wrong_password_count`, `can_unblock`), `quota` (`used`, `max`, `left`, `resets_at`) và `thresholds`.

`reason` là `wrong_password`, `daily_limit`, `too_many_connections` hoặc `abuse`; chỉ `abuse` có `can_unblock: false`. `level` từ 1 đến 5 (5 phút, 10 phút, 30 phút, 1 giờ, 6 giờ). Khi chỉ một username trên IP đó bị chặn (`pair_blocked: true`), `level` và `until` là `null` và chặn tự hết trong vòng 1 giờ.

Request

```
curl -s -X POST https://g.sendcorex.com/v1/security \
  -H "Authorization: Bearer $SENDCOREX_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"commands":[{"command":"list_blocked_ips","args":{},"id":"1"}]}'
```

Response

```
{
  "type": "SUCCESS",
  "results": [{
    "command": "list_blocked_ips", "id": "1", "type": "SUCCESS",
    "data": {
      "items": [{
        "ip": "203.0.113.24",
        "reason": "wrong_password",
        "until": "2026-12-02T10:44:09Z",
        "level": 3,
        "pair_blocked": false,
        "wrong_password_count": 5,
        "can_unblock": true
      }],
      "quota": { "used": 1, "max": 3, "left": 2, "resets_at": "2026-12-28T00:00:00Z" },
      "thresholds": {
        "wrong_password_per_ip": "…",
        "wrong_password_many_ips": "…",
        "failed_logins_progressive": "…",
        "self_unblocks_per_30_days": 3,
        "unblock_takes_effect_within": "10 seconds"
      }
    }
  }]
}
```

`unblock_ip` smtp:create

Gỡ chặn một IP của bạn.

**Tham số**
`ip` (bắt buộc).

**Trả về**
Giống `list_blocked_ips`, kèm `message`.

Request

```
curl -s -X POST https://g.sendcorex.com/v1/security \
  -H "Authorization: Bearer $SENDCOREX_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"commands":[{"command":"unblock_ip","args":{"ip":"203.0.113.24"},"id":"1"}]}'
```

Response

```
{
  "type": "SUCCESS",
  "results": [{
    "command": "unblock_ip", "id": "1", "type": "ERROR",
    "code": "UNBLOCK_QUOTA",
    "message": "You already used 3 of 3 unblocks in the last 30 days.",
    "fix": "Wait until quota.resets_at, or contact support.",
    "docs_url": "https://docs.sendcorex.com/errors#unblock_quota",
    "retryable": false
  }]
}
```

## Quy tắc gỡ chặn

1

Chỉ các chặn do bạn gây ra

Sai mật khẩu, giới hạn hằng ngày và quá nhiều kết nối có thể gỡ chặn tại đây. Chặn do lạm dụng cần liên hệ support.

2

3 lần gỡ chặn mỗi 30 ngày

Giới hạn áp dụng cho cả tài khoản, không theo từng IP.

3

Hoạt động lại sau ~10 giây

Gỡ chặn có hiệu lực sau khoảng 10 giây.

4

Sửa nguyên nhân trước

Cập nhật mật khẩu trong mọi ứng dụng trước khi gỡ chặn, nếu không IP sẽ bị chặn lại.

## Khi nào IP hoặc thông tin đăng nhập bị chặn

Sai mật khẩu, một IP

5 lần sai mật khẩu từ một IP cho một username trong 1 giờ sẽ chặn IP đó.

Sai mật khẩu, nhiều IP

Sai mật khẩu từ 5 IP khác nhau trong 1 giờ sẽ chặn thông tin đăng nhập.

Đăng nhập thất bại, một IP

5 lần đăng nhập thất bại từ một IP trong 2 phút sẽ chặn IP, mỗi lần lâu hơn.

## Lý do trong list_auth_errors

| Lý do | Cần làm gì |
| --- | --- |
| `wrong_password` Sai mật khẩu | Sao chép lại mật khẩu từ SMTP > Thông tin đăng nhập, hoặc đặt lại, rồi cập nhật trong ứng dụng email. |
| `invalid_username_format` Sai tên người dùng | Dùng tên người dùng SMTP (user-…), không phải địa chỉ email của bạn. |
| `ip_locked_after_failures` IP bị khóa (5 lần sai mật khẩu) | Sửa mật khẩu, rồi bỏ chặn IP. |
| `credential_locked` Thông tin đăng nhập bị khóa | Mật khẩu sai đến từ nhiều IP. Đặt lại mật khẩu của thông tin đăng nhập này. |
| `credential_temporarily_blocked` Bị chặn tạm thời | Quá nhiều lần đăng nhập thất bại. Sửa mật khẩu và chờ vài phút. |
| `ip_not_allowed` IP không được phép | Thêm IP này vào danh sách IP được phép của thông tin đăng nhập/key, hoặc bỏ giới hạn. |
| `account_blocked` Tài khoản bị tạm ngưng | Liên hệ hỗ trợ. |
| `api_key_expired` API key hết hạn | Tạo API key mới. |
| `api_key_missing_scope` Thiếu quyền | Sửa API key và thêm quyền cần thiết. |
| `api_key_invalid` API key không hợp lệ | Kiểm tra key hoặc tạo key mới. |

## Lỗi

Mỗi mã dẫn tới cách khắc phục trên trang Lỗi.

Trước khi lệnh chạy (mã HTTP)

- [MISSING_AUTH_HEADER](https://docs.sendcorex.com/vi/errors#missing_auth_header) 401
- [INVALID_API_KEY](https://docs.sendcorex.com/vi/errors#invalid_api_key) 401
- [API_KEY_EXPIRED](https://docs.sendcorex.com/vi/errors#api_key_expired) 401
- [ACCOUNT_BLOCKED](https://docs.sendcorex.com/vi/errors#account_blocked) 403
- [IP_NOT_ALLOWED](https://docs.sendcorex.com/vi/errors#ip_not_allowed) 403
- [MISSING_SCOPE](https://docs.sendcorex.com/vi/errors#missing_scope) 403
- [RATE_LIMITED](https://docs.sendcorex.com/vi/errors#rate_limited) 429
- [AUTH_UNAVAILABLE](https://docs.sendcorex.com/vi/errors#auth_unavailable) 503

Trong kết quả của lệnh

- [MISSING_SCOPE](https://docs.sendcorex.com/vi/errors#missing_scope)
- [INVALID_ARGS](https://docs.sendcorex.com/vi/errors#invalid_args) `list_auth_errors`
- [NOT_BLOCKED](https://docs.sendcorex.com/vi/errors#not_blocked) `unblock_ip`
- [NOT_SELF_SERVICE](https://docs.sendcorex.com/vi/errors#not_self_service) `unblock_ip`
- [UNBLOCK_QUOTA](https://docs.sendcorex.com/vi/errors#unblock_quota) `unblock_ip`
- [INTERNAL](https://docs.sendcorex.com/vi/errors#internal)

## Trong ứng dụng AI (MCP)

MCP tài khoản có cùng các lệnh dưới dạng tools, với cùng tham số và scope:

`security_list_auth_errors`

= `list_auth_errors`

Liệt kê các lần đăng nhập SMTP, API và MCP thất bại trong 30 ngày qua (mới nhất trước), kèm lý do và phản hồi chính xác; lọc theo nguồn, lý do hoặc IP.

`security_list_blocked_ips`

= `list_blocked_ips`

Liệt kê các IP bị chặn của tài khoản kèm lý do và thời hạn, cùng số lần tự gỡ chặn còn lại.

`security_unblock_ip`

= `unblock_ip`

Gỡ chặn một IP của tài khoản bị chặn do sai mật khẩu, giới hạn hằng ngày hoặc quá nhiều kết nối (3 lần mỗi 30 ngày; chặn do lạm dụng cần support).

[Công cụ tài khoản](https://docs.sendcorex.com/vi/api-reference/mcp/account-tools)
