账户与访问凭证
渠道伙伴门户的登录、注册、验证码、找回密码、子账户(成员账户)、测试账户、沙盒令牌与开发者应用(API 令牌)管理接口。
本页所有接口均为 POST,请求与响应均为 JSON。成功响应为 { code, msg, data, timestamp };错误响应为 { code, msg, timestamp },不含 data 字段。code = 200 表示成功,其余为业务错误码。
认证模型
平台同时使用三类不透明随机串,作用域互不相同:
| 凭证 | 传递方式 | 签发方 | 有效期 | 适用范围 |
|---|---|---|---|---|
| 会话令牌(session token) | Authorization: Bearer <token> | auth/login、auth/code/login、auth/password/change、auth/password/reset/confirm | 7 天 | 账户、测试账户、沙盒、开发者、对账等全部登录态接口 |
| 开发者令牌(request-token) | request-token: <secret> | developer/create、developer/regenerate,或管理员在后台创建 | 长期,直到停用或重置 | 订单、出库、库存、对账、Webhook 等业务接口;不能用于开发者管理接口 |
| 沙盒环境令牌 | Authorization: Bearer <token> 或 request-token: <token> | 由 sandbox/init 在测试环境创建 | 由测试环境决定 | 指向测试环境(tapi)的业务接口 |
补充约定:
- 账户、测试账户、沙盒、开发者管理与对账接口需要有效会话令牌;业务接口可使用
request-token。 - 客户端不能自报会员 ID。
- 账户类与对账类接口不校验能力;出库、库存、Webhook 等接口缺少能力返回
606。 - 验证码为 6 位数字,有效期 120 秒,一次性使用。
认证(auth)
密码登录
/channel/api/v1/auth/loginAuth: public (no token)
使用邮箱 + 密码登录。成功后返回会话令牌与用户信息。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 是 | 登录邮箱,不区分大小写 |
password | string | 是 | 登录密码 |
响应
{
"code": 200,
"msg": "success",
"data": {
"token": "5f1c0e...64位十六进制串",
"user": {
"id": 42,
"member_id": 42,
"email": "buyer@example.com",
"name": "Example Trading",
"role": "admin",
"is_primary": true,
"user_type": "buyer",
"capabilities": ["outbound_submit"]
}
}
}说明:user.user_type 仅在子账户 / 成员账户场景、且该会员存在业务身份时可能返回,可能缺失;客户端不应假定该字段必然存在。
错误码
| code | 含义 |
|---|---|
| 400 | email 或 password 缺失;邮箱或密码错误(Invalid email or password) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/login' \
-H 'Content-Type: application/json' \
-d '{
"email": "buyer@example.com",
"password": "secret123"
}'发送登录验证码
/channel/api/v1/auth/code/sendAuth: public (no token)
向邮箱发送 6 位登录验证码。验证码通过邮件通道发送,不会出现在响应中。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 是 | 接收验证码的邮箱 |
响应
{ "code": 200, "msg": "success", "data": { "sent": true, "expires_in": 120 } }错误码
| code | 含义 |
|---|---|
| 400 | 邮箱为空或格式非法 |
| 500 | 邮件发送失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/code/send' \
-H 'Content-Type: application/json' \
-d '{
"email": "buyer@example.com"
}'验证码登录
/channel/api/v1/auth/code/loginAuth: public (no token)
使用邮箱 + 邮件验证码登录,返回会话令牌与用户信息(结构同密码登录)。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 是 | 登录邮箱 |
code | string | 是 | 6 位验证码,一次性使用 |
响应
{
"code": 200,
"msg": "success",
"data": {
"token": "5f1c0e...64位十六进制串",
"user": {
"id": 42,
"member_id": 42,
"email": "buyer@example.com",
"name": "Example Trading",
"role": "admin",
"is_primary": true,
"user_type": "buyer",
"capabilities": ["outbound_submit"]
}
}
}说明:user.user_type 仅在子账户 / 成员账户场景、且该会员存在业务身份时可能返回,可能缺失。
错误码
| code | 含义 |
|---|---|
| 400 | 验证码错误或已过期;该邮箱没有启用的账户(account not found) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/code/login' \
-H 'Content-Type: application/json' \
-d '{
"email": "buyer@example.com",
"code": "123456"
}'注册
/channel/api/v1/auth/registerAuth: public (no token)
该接口暂不可用,请联系管理员开通账户。
当前用户
/channel/api/v1/auth/meAuth: Authorization: Bearer <session token>
返回当前登录用户的档案。无请求体。
响应
{
"code": 200,
"msg": "success",
"data": {
"id": 42,
"member_id": 42,
"email": "buyer@example.com",
"name": "Example Trading",
"role": "admin",
"is_primary": true,
"user_type": "buyer,warehouse",
"capabilities": ["outbound_submit", "inventory_view"]
}
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 账户 ID |
member_id | integer | 所属渠道伙伴会员 ID |
email | string | 登录邮箱 |
name | string | 显示名称 |
role | string | admin / operator / viewer |
is_primary | boolean | 是否主账户 |
user_type | string | 业务身份,逗号分隔多值;仅在有业务身份时返回 |
capabilities | string[] | 已启用的伙伴能力列表 |
说明:
- 该接口不返回菜单或权限树(没有
menu字段)。前端菜单由门户自身配置,接口只提供role与capabilities。 - 该接口返回当前登录账户的基本信息。
错误码
| code | 含义 |
|---|---|
| 909 | 未携带 Authorization 或令牌无效 / 已过期 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/me' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'修改姓名
/channel/api/v1/auth/profile/updateAuth: Authorization: Bearer <session token>
修改当前会员的显示名称。邮箱为只读,不可通过此接口修改。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 新名称,去空格后 1–100 字符 |
响应
{ "code": 200, "msg": "success", "data": { "name": "New Name" } }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | 名称为空或超过 100 字符 |
| 404 | 会员不存在 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/profile/update' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"name": "New Name"
}'修改密码(登录态)
/channel/api/v1/auth/password/changeAuth: Authorization: Bearer <session token>
校验旧密码后设置新密码,并签发新的会话令牌。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
old_password | string | 是 | 当前密码 |
new_password | string | 是 | 新密码,至少 8 位,且必须与旧密码不同 |
响应
{ "code": 200, "msg": "success", "data": { "token": "新的会话令牌" } }说明:
- 修改成功后旧会话令牌不会立即失效,仍可用到其 7 天 TTL 到期;客户端应丢弃旧令牌。
- 该接口用于修改当前登录账户的密码。
错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | 旧密码错误;新密码少于 8 位;新旧密码相同 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/password/change' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"old_password": "secret123",
"new_password": "secret456"
}'发送找回密码验证码
/channel/api/v1/auth/password/reset/sendAuth: public (no token)
向已存在的启用账户邮箱发送重置验证码。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 是 | 账户邮箱 |
响应
{ "code": 200, "msg": "success", "data": { "sent": true, "expires_in": 120 } }错误码
| code | 含义 |
|---|---|
| 400 | 邮箱为空 / 格式非法;该邮箱没有启用的登录账户(account not found) |
| 500 | 邮件发送失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/password/reset/send' \
-H 'Content-Type: application/json' \
-d '{
"email": "buyer@example.com"
}'重置密码确认
/channel/api/v1/auth/password/reset/confirmAuth: public (no token)
验证邮箱验证码并设置新密码,成功后直接签发会话令牌。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
email | string | 是 | 账户邮箱 |
code | string | 是 | 6 位验证码 |
password | string | 是 | 新密码,至少 8 位 |
响应
{ "code": 200, "msg": "success", "data": { "token": "新的会话令牌" } }错误码
| code | 含义 |
|---|---|
| 400 | 验证码错误或已过期;密码少于 8 位;账户不存在 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/password/reset/confirm' \
-H 'Content-Type: application/json' \
-d '{
"email": "buyer@example.com",
"code": "123456",
"password": "secret456"
}'子账户列表
/channel/api/v1/auth/accounts/listAuth: Authorization: Bearer <session token>
列出当前会员下的全部成员账户,按主账户优先、id 升序排列。无请求体。
响应
{
"code": 200,
"msg": "success",
"data": [
{
"id": 42,
"member_id": 42,
"email": "owner@example.com",
"name": "Owner",
"role": "admin",
"is_primary": 1,
"active": 1,
"created_at": "2026-01-01 10:00:00",
"updated_at": "2026-01-01 10:00:00"
},
{
"id": 57,
"member_id": 42,
"email": "ops@example.com",
"name": "Ops",
"role": "operator",
"is_primary": 0,
"active": 1,
"created_at": "2026-02-01 09:00:00",
"updated_at": "2026-02-01 09:00:00"
}
]
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 成员账户 ID |
member_id | integer | 所属渠道伙伴会员 ID |
email | string | 登录邮箱 |
name | string | 显示名称 |
role | string | admin / operator / viewer |
is_primary | integer | 1 为主账户 |
active | integer | 1 启用,0 已停用 |
created_at / updated_at | string | 创建 / 更新时间 |
说明:响应返回账户信息(不含密码)。
错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/accounts/list' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'新增 / 编辑子账户
/channel/api/v1/auth/accounts/saveAuth: Authorization: Bearer <session token>
id = 0 时新增子账户;id > 0 时编辑。仅 admin 角色或主账户可操作。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 否 | 0 / 省略为新增,否则为待编辑账户 ID |
email | string | 是 | 登录邮箱,转为小写并去空格;不可与其它账户或其它会员重复 |
name | string | 否 | 显示名称 |
role | string | 否 | admin / operator / viewer,默认 operator |
password | string | 新增必填 | 至少 8 位;编辑时留空表示不修改 |
active | boolean | 否 | 是否启用;新增默认 0,编辑时按传入值 |
说明:
- 编辑为全量覆盖:服务端每次都先构造
name = ''、role = 'operator'、active = 0,再整体写入。因此编辑时省略name会清空名称、省略role会降为operator、省略active会停用账户。客户端编辑时应回传完整字段。 - 主账户行会被强制设为
role = admin、active = 1,并同步更新会员的邮箱、名称与密码。 - 邮箱重复(
账户或member)返回400 email already used。
响应
{ "code": 200, "msg": "success", "data": { "id": 57 } }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 606 | 非 admin 且非主账户(admin role required) |
| 400 | 邮箱格式非法 / 角色非法 / 邮箱已被使用 / 新增时未填密码 / 密码少于 8 位 |
| 404 | 编辑的账户不存在或不属于当前会员 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/accounts/save' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 57,
"email": "ops@example.com",
"name": "Ops",
"role": "operator",
"password": "secret123",
"active": true
}'停用子账户
/channel/api/v1/auth/accounts/deleteAuth: Authorization: Bearer <session token>
软停用子账户(active = 0),不物理删除。仅 admin 或主账户可操作。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 成员账户 ID;不能是当前登录账户,也不能是主账户 |
响应
{ "code": 200, "msg": "success", "data": null }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 606 | admin role required |
| 400 | id 非法、等于当前账户,或目标为主账户(primary account cannot be disabled) |
| 404 | 账户不存在或不属于当前会员 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/accounts/delete' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 57
}'发送子账户重置密码验证码
/channel/api/v1/auth/accounts/send-resetAuth: Authorization: Bearer <session token>
向指定子账户的邮箱发送密码重置验证码。随后由该账户调用 auth/password/reset/confirm 完成重置。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 成员账户 ID |
响应
{ "code": 200, "msg": "success", "data": { "sent": true } }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 606 | admin role required |
| 404 | 账户不存在或不属于当前会员 |
| 500 | 邮件发送失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/auth/accounts/send-reset' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 57
}'测试账户(test-account)
本组接口仅接受 Authorization: Bearer <会话令牌>;不接受开发者密钥(包括沙盒开发者密钥),否则返回 909。测试账户绑定属于正式环境数据。
创建 / 获取测试账户
/channel/api/v1/test-account/provisionAuth: Authorization: Bearer <session token>
为当前会员创建(或返回已存在的)沙盒测试邮箱。每个会员只有一个测试账户绑定,重复调用幂等。无请求体。
响应
{
"code": 200,
"msg": "success",
"data": {
"id": 42,
"tapi_email": "test_1a2b3c4d@e2c-energy.com",
"remark": "",
"is_current": true,
"created_at": "2026-11-11 10:00:00"
}
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 绑定 ID,与会员 ID 相同 |
tapi_email | string | 测试环境登录邮箱 |
remark | string | 备注 |
is_current | boolean | 当前绑定恒为 true |
created_at | string | 最近更新时间(取自会员 updated_at) |
错误码
| code | 含义 |
|---|---|
| 909 | 未携带会话令牌或令牌无效 |
| 400 | 会员不存在 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/test-account/provision' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'列出测试账户
/channel/api/v1/test-account/listAuth: Authorization: Bearer <session token>
返回当前会员的测试账户绑定列表;未创建时返回空数组。无请求体。
响应
{ "code": 200, "msg": "success", "data": [] }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/test-account/list' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'读取沙盒令牌
/channel/api/v1/test-account/tokenAuth: Authorization: Bearer <session token>
返回 sandbox/init 写入的测试环境令牌。无请求体(请求中的其它字段会被忽略)。
响应
{ "code": 200, "msg": "success", "data": { "token": "测试环境令牌" } }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | 当前会员尚未初始化沙盒环境(sandbox environment is not initialized for this member) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/test-account/token' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'解绑测试账户
/channel/api/v1/test-account/unbindAuth: Authorization: Bearer <session token>
解除当前会员的测试账户绑定,并清空测试邮箱与备注。
说明:该操作不会撤销已保存的 sandbox_token;解绑后测试环境令牌仍可能有效。如需让令牌失效,需在测试环境或后端单独处理。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 绑定 ID,必须等于当前会员 ID |
响应
{ "code": 200, "msg": "success", "data": null }错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | id 缺失;绑定不存在(test account binding not found) |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/test-account/unbind' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 42
}'沙盒环境(sandbox)
初始化沙盒环境
/channel/api/v1/sandbox/initAuth: Authorization: Bearer <session token>
在测试环境创建或确保当前会员的测试账户与测试令牌。调用者必须是 admin 角色。无请求体。
响应
{
"code": 200,
"msg": "sandbox environment initialized",
"data": { "member_id": 42, "sandbox_token": "测试环境令牌" }
}错误码
| code | 含义 |
|---|---|
| 909 | 未认证;或调用者不是 admin 角色(admin role required) |
| 400 | 沙盒环境初始化失败,请稍后重试或联系管理员 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/sandbox/init' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'读取沙盒令牌
/channel/api/v1/sandbox/tokenAuth: Bearer or request-token (channel_partner)
读取当前会员已保存的沙盒令牌。无请求体。未初始化时 sandbox_token 为 null,不报错。
响应
{ "code": 200, "msg": "success", "data": { "member_id": 42, "sandbox_token": null } }错误码
| code | 含义 |
|---|---|
| 909 | 未认证或不属于渠道伙伴 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/sandbox/token' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'开发者应用(developer)
本组接口要求 Authorization: Bearer <会话令牌>。开发者管理不接受 request-token,因为控制器只从 Authorization 头解析会员(且只按会话令牌解析,不认开发者密钥)。
developer/create、developer/state、developer/regenerate 暂不可用,请联系管理员。developer/list 可用。
创建应用
/channel/api/v1/developer/createAuth: Authorization: Bearer <session token>
创建一个类型为 channel_partner 的应用并返回完整令牌。令牌仅在本次响应中返回一次。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
name | string | 是 | 应用名称 |
响应
该接口暂不可用。
返回字段(开通后)
| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 应用 ID |
name | string | 应用名称 |
token | string | 完整令牌,仅本次返回 |
token_preview | string | 掩码后的令牌 |
state | integer | 1 启用 |
created_at | string | 创建时间 |
错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | name 缺失 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/developer/create' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"name": "My ERP integration"
}'当前不可用。
应用列表
/channel/api/v1/developer/listAuth: Authorization: Bearer <session token>
列出当前会员的应用,令牌只返回掩码预览。无请求体。
响应
{
"code": 200,
"msg": "success",
"data": [
{
"id": 12,
"name": "My ERP integration",
"token_preview": "abcd************wxyz",
"state": 1,
"created_at": "2026-11-11 10:00:00",
"last_used_at": "2026-11-11 12:30:00"
}
]
}| 字段 | 类型 | 说明 |
|---|---|---|
id | integer | 应用 ID |
name | string | 应用名称 |
token_preview | string | 掩码后的令牌 |
state | integer | 1 启用,0 停用 |
created_at | string | 创建时间 |
last_used_at | string/null | 最近一次以该令牌调用接口的时间 |
错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/developer/list' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'启用 / 停用应用
/channel/api/v1/developer/stateAuth: Authorization: Bearer <session token>
修改应用状态。停用后该令牌立即无法通过认证。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 应用 ID |
state | integer | 是 | 1 启用,0 停用 |
当前响应
该接口暂不可用。
错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | id 缺失或 state 非 0/1 |
| 404 | 应用不存在或不属于当前会员 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/developer/state' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 12,
"state": 1
}'当前不可用。
重置应用令牌
/channel/api/v1/developer/regenerateAuth: Authorization: Bearer <session token>
生成新的应用令牌并立即生效;旧令牌即刻失效。新令牌仅在本次响应中返回一次。
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | integer | 是 | 应用 ID |
当前响应
该接口暂不可用。
错误码
| code | 含义 |
|---|---|
| 909 | 未认证 |
| 400 | id 缺失 |
| 404 | 应用不存在或不属于当前会员 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/developer/regenerate' \
-H 'Authorization: Bearer YOUR_SESSION_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"id": 12
}'当前不可用。