TRUST API
Stayloop Trust API
v1 · build-2026-04-28开发者文档。在一次 API 调用中验证租客身份、收入、信用和驱逐历史。
概览
Stayloop Trust API 提供统一接口来验证租客凭证。所有请求需使用 API 密钥进行身份认证。
基础 URL: https://api.stayloop.ai/v1
身份认证
所有 API 请求都需在 Authorization 标头中使用 Bearer 令牌。你可从 Stayloop 仪表盘生成 API 密钥。
curl -X POST https://api.stayloop.ai/v1/screen \
-H "Authorization: Bearer sk_test_abcd1234..." \
-H "Content-Type: application/json" \
-d '{...}'测试密钥以 sk_test_ 开头;生产密钥以 sk_live_ 开头。
POST /v1/screen
通过提交申请人详情、房源信息和支持文件来筛查租户申请人。返回综合风险评分(0–100)、取证、法院记录和 AI 评估。
请求
{
"applicant": {
"name": "John Smith",
"email": "[email protected]",
"monthly_income": 4500
},
"listing": {
"rent": 1800,
"address": "123 King St W, Toronto, ON M5H 2R2"
},
"documents": [
{
"path": "path/to/id.pdf",
"type": "government_id"
},
{
"path": "path/to/paystub.pdf",
"type": "pay_stub"
}
]
}响应
{
"score": 87,
"tier": "approve",
"reason": "Strong income-to-rent ratio (2.5×), clear rental history, no court records.",
"forensics": {
"document_authenticity": 0.98,
"payment_ability": 0.95,
"court_records": 0,
"stability": 0.92,
"behavior_signals": 0.88,
"info_consistency": 0.91
},
"court_records": []
}| Code | Description |
|---|---|
| 200 | 成功 |
| 400 | 缺少必需字段 |
| 401 | 无效 API 密钥 |
| 429 | 超过速率限制 |
| 500 | 服务器错误 |
POST /v1/passport/verify
验证已验证的 Passport 令牌。护照在租客完成筛查后签发,在网络中所有房东间有效期为 12 个月。
请求
{
"passport_id": "SL-2026-XXXXX-XXX"
}响应
{
"verified": true,
"tenant_id": "tnr_abc123",
"claims": {
"income_3x": true,
"no_evictions": true,
"credit_approved": true,
"identity_verified": true
},
"expires_at": "2027-04-28T00:00:00Z",
"issued_at": "2026-04-28T00:00:00Z"
}| Code | Description |
|---|---|
| 200 | 护照有效 |
| 401 | 护照已过期或无效 |
| 429 | 超过速率限制 |
GET /v1/listings/{id}/compliance
检查房源是否符合 OHRC(安省人权法)。返回通过/失败状态,以及对保护基础(家庭状况、宗教、收入来源等)的警告。
请求
curl -X GET https://api.stayloop.ai/v1/listings/lst_abc123/compliance \
-H "Authorization: Bearer sk_test_abcd1234..."响应
{
"passes": true,
"warnings": [
{
"code": "pet_policy_note",
"severity": "low",
"field": "description",
"matched_text": "no pets",
"rationale_en": "Pet restrictions may conflict with assistance animal rights",
"rationale_zh": "宠物限制可能与辅助动物权利冲突"
}
]
}| Code | Description |
|---|---|
| 200 | 检查完成 |
| 404 | 房源未找到 |
| 401 | 无效 API 密钥 |
POST /v1/disputes/mediate
提交纠纷以进行 AI 驱动的调解。调解员代理提供基于安省《住宅租赁法》的中立建议。14 天解决期限。
请求
{
"dispute_id": "dsp_abc123",
"party": "tenant",
"message": "Landlord has not returned my damage deposit after 30 days."
}响应
{
"mediator_response": "Under RTA §106, landlord must return deposit within 30 days + interest, or provide written itemization.",
"suggested_settlement": "Landlord returns deposit + interest within 5 business days.",
"days_remaining": 10,
"rta_citations": [
"§106",
"§104"
]
}| Code | Description |
|---|---|
| 200 | 调解已开始 |
| 400 | 纠纷 ID 无效 |
| 429 | 超过速率限制 |
Webhooks
Stayloop 会针对关键生命周期事件发送 webhook 事件。所有 webhook 使用 HMAC-SHA256 签名。
Webhook events:
- application.scored
- passport.verified
- compliance.warning
- dispute.settled
在 API 仪表盘中配置 webhook 端点。Stayloop 会使用指数退避重试失败的交付,最多重试 5 次。
SDKs
官方 Stayloop SDK 可用于 JavaScript、Python 和 Go。
npm install @stayloop/trust-api
import { TrustAPI } from '@stayloop/trust-api'
const client = new TrustAPI({ apiKey: 'sk_test_...' })
const result = await client.screen({...})速率限制
| 等级 | 请求/分钟 |
|---|---|
| Free | 60 |
| Pro | 600 |
| Enterprise | 自定义 |
速率限制标头:X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Reset(Unix 时间戳)。
错误处理
所有 API 错误都返回一致的 JSON 结构,包含错误代码和消息。
{
"error": {
"code": "invalid_api_key",
"message": "The provided API key is invalid or expired.",
"type": "authentication_error"
}
}