Skip to content

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_developer with type=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 ​

CredentialHeaderIssued byTypical use
Session tokenAuthorization: Bearer <token>auth/login, auth/code/login, auth/register, auth/password/*; cached 7 daysPartner portal
Developer secretrequest-token: <secret>Created with a channel application in the admin panelThird-party integration
Sandbox secretAuthorization: Bearer <sandbox_token>Created by sandbox/init in the test environment and persistedSandbox 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 909

If the request carries Authorization, the Bearer branch is used; when that branch fails the response is 909 and request-token is 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:

text
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/confirm

auth/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 * 7 seconds); 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) or auth/code/login (email + verification code) and read data.token.
  • Third-party systems: an e2c-energy administrator creates a channel application bound to your partner account and returns the request-token secret.
  • Sandbox: an admin account calls sandbox/init from the production portal; the response contains and persists sandbox_token, then requests to tapi use Authorization: Bearer <sandbox_token>.

Sandbox ​

text
POST https://apigate.e2c-energy.com/channel/api/v1/sandbox/init
Authorization: Bearer <production session token>
  • role=admin only, and it must be a production session token (Bearer); a developer secret is not accepted.
  • Syncs the member identity, user_type and partner_capability rows into the test environment.
  • Returns { member_id, sandbox_token } and stores it in t_member.sandbox_token.
  • POST /channel/api/v1/sandbox/token returns the stored sandbox_token at any time (null when never initialized).
  • Sandbox business calls go to https://tapi.e2c-energy.com with the credential in Authorization: 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 ​

codeMeaning
909No credential, invalid/expired credential, disabled app, or non-channel_partner type
606Credential 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.