Authentication
Channel Partner APIs accept two equivalent credential forms; use either one:
Authorization: Bearer <token>— a portal session token, or a developer secret issued by the sandbox (tapi) environment;request-token: <secret>— a channel partner developer secret (t_developerwithtype=channel_partner,state=1).
Both resolve to the same channel partner member id. The request context field channelPartnerMemberId is injected server-side only and cannot be overridden by request parameters.
Two Credential Forms
| Credential | Header | Issued by | Typical use |
|---|---|---|---|
| Session token | Authorization: Bearer <token> | auth/login, auth/code/login, auth/register, auth/password/*; cached 7 days | Partner portal |
| Developer secret | request-token: <secret> | Created with a channel application in the admin panel | Third-party integration |
| Sandbox secret | Authorization: Bearer <sandbox_token> | Created by sandbox/init in the test environment and persisted | Sandbox testing |
Resolution Order
Authorization: Bearer <token>
├─ first as a portal session token (cache: channel_user_token:<token> → member id)
└─ then as a developer secret (state=1 and type=channel_partner)
│
▼
valid: inject channelPartnerMemberId → check path capability → proceed
invalid: return 909 (request-token is NOT consulted)
request-token: <secret>
└─ developer secret only → check capability and proceed, otherwise 909If the request carries
Authorization, the Bearer branch is used; when that branch fails the response is909andrequest-tokenis never read.
Whitelist
Endpoints whose path contains api/v1/auth/ require no token, because login, registration, code sending and password reset happen before any developer identity exists:
POST /channel/api/v1/auth/login
POST /channel/api/v1/auth/code/send
POST /channel/api/v1/auth/code/login
POST /channel/api/v1/auth/register
POST /channel/api/v1/auth/password/reset/send
POST /channel/api/v1/auth/password/reset/confirmauth/me, auth/profile/update, auth/password/change and auth/accounts/* share the prefix but resolve Authorization: Bearer themselves and return 909 when the token is missing or invalid.
Token Lifecycle
- Session tokens are opaque random strings cached server-side for 7 days (
3600 * 24 * 7seconds); log in again after expiry. - Changing the password issues a new token; old tokens are not force-revoked and remain valid until their TTL ends.
- Developer secrets are managed in the admin panel; disabling the application or rotating the secret invalidates them immediately.
Obtaining a Token
- Portal users: call
auth/login(email + password) orauth/code/login(email + verification code) and readdata.token. - Third-party systems: an e2c-energy administrator creates a channel application bound to your partner account and returns the
request-tokensecret. - Sandbox: an admin account calls
sandbox/initfrom the production portal; the response contains and persistssandbox_token, then requests totapiuseAuthorization: Bearer <sandbox_token>.
Sandbox
POST https://apigate.e2c-energy.com/channel/api/v1/sandbox/init
Authorization: Bearer <production session token>role=adminonly, and it must be a production session token (Bearer); a developer secret is not accepted.- Syncs the member identity,
user_typeandpartner_capabilityrows into the test environment. - Returns
{ member_id, sandbox_token }and stores it int_member.sandbox_token. POST /channel/api/v1/sandbox/tokenreturns the storedsandbox_tokenat any time (nullwhen never initialized).- Sandbox business calls go to
https://tapi.e2c-energy.comwith the credential inAuthorization: Bearer;auth/*identity endpoints always use the production gateway.
Developer apps in the portal
Developer apps created in the portal belong to the current environment: the sandbox portal writes to the test environment, the live portal writes to production. Apps created by sandbox/init are internal credentials (t_developer.scope='member'); they are not listed in the portal and cannot be enabled, disabled or regenerated there.
Authentication Errors
| code | Meaning |
|---|---|
| 909 | No credential, invalid/expired credential, disabled app, or non-channel_partner type |
| 606 | Credential valid but the path capability is missing (see Capabilities) |
On 909, verify the token is correct, still enabled and issued as a channel partner application. On 606, ask e2c staff to grant the required capability.