文档目录

OAuth — API reference

该文档正文目前仅提供英文版本;导航栏、搜索框和按钮已适配您的当前语言。

The person’s side of AI-agent connections (OAuth 2.1). An agent starts at GET /oauth/authorize on this host (metadata: /.well-known/oauth-authorization-server); the dashboard’s consent page reads the request, the person chooses permissions, spend limits and expiry, and connected agents are listed, limited or revoked here.

MethodPathSummary
GET/v1/oauth/requests/{requestId}An agent’s authorization request, for the consent page
POST/v1/oauth/requests/{requestId}/decisionApprove or deny an agent’s authorization request
GET/v1/oauth/grantsConnected agents
PATCH/v1/oauth/grants/{grantId}Change a connected agent’s limits or expiry
DELETE/v1/oauth/grants/{grantId}Disconnect an agent

Base URL https://api.tenergy.me/v1, or https://api-nile.tenergy.me/v1 on Nile (Environments). Every request below is signed as in Authentication unless its Auth line says otherwise.

GET /v1/oauth/requests/{requestId} · getOAuthRequest

Auth: Dashboard session cookie + X-CSRF-Token.

What an AI agent asked for through GET /oauth/authorize: the client (name, host, where its metadata came from), the requested permissions, the resource the token is for, and the defaults the page pre-fills. api_keys.manage and webhooks.manage are opt-in (opt_in: true, unchecked). Live for ten minutes and until decided. Dashboard session only.

Parameters

NameInTypeRequiredDescription
requestIdpathstringyes

Responses

StatusMeaning
200OK
401Missing, malformed or rejected credentials.
4043029 oauth_request_not_found: unknown, decided, or expired.

Response fields (OAuthRequest)

FieldTypeRequiredDescription
idstringyes
expires_atstring (date-time)yes
clientobjectyes
client.client_idstringyesA registered id, or the URL of the client’s metadata document.
client.namestringyes
client.hoststringyes
client.sourceenum: dcr, cimdyes
client.client_uristring | nullyes
client.logo_uristring | nullyes
redirect_uristringyes
resourcestringyesThe API or MCP URL the token will be for.
scopesarray of objectyes
scopes[].scopeenum: prices.read, balance.read, balance.topup_address, orders.read, orders.create, orders.reclaim, subscriptions.read, api_keys.manage, webhooks.manageyesA permission an agent may be granted. The first seven are the API key scopes of the same name; api_keys.manage (list, create, revoke API keys) and webhooks.manage (read and change webhook endpoints) are opt-in. Withdrawals, members and sign-in methods are never grantable.
scopes[].opt_inbooleanyes
scopes[].checkedbooleanyesPre-checked on the consent page.
defaultsobjectyes
defaults.spend_limit_day_sunintegeryes
defaults.spend_limit_month_sunintegeryes
defaults.expires_in_daysintegeryes
step_upenum: off, email, telegram, walletyesThe person’s 2-step channel.

Approve or deny an agent’s authorization request

POST /v1/oauth/requests/{requestId}/decision · decideOAuthRequest

Auth: Dashboard session cookie + X-CSRF-Token.

approve: true creates the grant with the chosen scopes (a subset of the requested ones) and a one-time code, and answers the client URL to send the browser to (code, state, iss). approve: false answers the client URL with error=access_denied. Granting orders.create needs both spend limits (omitted = 100 TRX a day and 1,000 TRX a month; null is refused). expires_in_days omitted = 30, null = no expiry. With 2-step on, a grant holding orders.create, api_keys.manage or webhooks.manage answers 1020 step_up_required first. Ordering and managing keys or webhooks need the editor role. Dashboard session only.

Parameters

NameInTypeRequiredDescription
requestIdpathstringyes
X-Step-UpheaderstringA 2-step approval: details.step_up_id of a 1020 step_up_required answer, approved with POST /v1/step-up/{id}/approve. Sent on the repeat of the identical request; used once. Only a dashboard session whose person switched 2-step on is ever asked for it.

Request body

JSON (OAuthDecisionRequest), required.

FieldTypeRequiredDescription
approvebooleanyes
scopesarray of enum: prices.read, balance.read, balance.topup_address, orders.read, orders.create, orders.reclaim, subscriptions.read, api_keys.manage, webhooks.manageRequired when approving; a subset of the requested scopes.
spend_limit_day_suninteger | null
spend_limit_month_suninteger | null
expires_in_daysinteger | null

Responses

StatusMeaning
200Decided; send the browser to redirect_to.
400Malformed request — bad JSON, unknown field, wrong type.
401Missing, malformed or rejected credentials.
4031020 step_up_required, 1021 step_up_invalid, 1005 insufficient_scope (role), 1014 csrf_token_invalid.
4043029 oauth_request_not_found.

Response fields

FieldTypeRequiredDescription
redirect_tostring (uri)yes

Connected agents

GET /v1/oauth/grants · listOAuthGrants

Auth: Dashboard session cookie + X-CSRF-Token.

The account’s live agent grants (not revoked, not expired), newest first. Dashboard session only.

Responses

StatusMeaning
200OK
401Missing, malformed or rejected credentials.

Response fields

FieldTypeRequiredDescription
dataarray of object (OAuthGrant)yes
data[].idstringyes
data[].client_idstringyes
data[].client_namestringyes
data[].client_hoststringyes
data[].resourcestringyes
data[].scopesarray of enum: prices.read, balance.read, balance.topup_address, orders.read, orders.create, orders.reclaim, subscriptions.read, api_keys.manage, webhooks.manageyes
data[].spend_limit_day_suninteger | nullyes
data[].spend_limit_month_suninteger | nullyes
data[].expires_atstring (date-time) | nullyes
data[].created_atstring (date-time)yes
data[].last_used_atstring (date-time) | nullyes
data[].last_ipstring | nullyes
data[].user_idstringyesThe member who connected the agent.

Change a connected agent’s limits or expiry

PATCH /v1/oauth/grants/{grantId} · updateOAuthGrant

Auth: Dashboard session cookie + X-CSRF-Token.

Lowering a limit or shortening the expiry applies at once; raising a limit, extending the expiry or removing it needs a step-up when 2-step is on. Spend limits exist only on a grant holding orders.create and cannot be removed. The person who connected the agent or the account owner. Dashboard session only.

Parameters

NameInTypeRequiredDescription
grantIdpathstringyes
X-Step-UpheaderstringA 2-step approval: details.step_up_id of a 1020 step_up_required answer, approved with POST /v1/step-up/{id}/approve. Sent on the repeat of the identical request; used once. Only a dashboard session whose person switched 2-step on is ever asked for it.

Request body

JSON (OAuthGrantPatch), required.

FieldTypeRequiredDescription
spend_limit_day_suninteger
spend_limit_month_suninteger
expires_in_daysinteger | nullFrom now; null = no expiry.

Responses

StatusMeaning
200Saved.
400Malformed request — bad JSON, unknown field, wrong type.
401Missing, malformed or rejected credentials.
4031020 step_up_required, 1021 step_up_invalid, 1005 insufficient_scope, 1014 csrf_token_invalid.
4043030 oauth_grant_not_found.
4222002 empty_patch.

Response fields (OAuthGrant)

FieldTypeRequiredDescription
idstringyes
client_idstringyes
client_namestringyes
client_hoststringyes
resourcestringyes
scopesarray of enum: prices.read, balance.read, balance.topup_address, orders.read, orders.create, orders.reclaim, subscriptions.read, api_keys.manage, webhooks.manageyes
spend_limit_day_suninteger | nullyes
spend_limit_month_suninteger | nullyes
expires_atstring (date-time) | nullyes
created_atstring (date-time)yes
last_used_atstring (date-time) | nullyes
last_ipstring | nullyes
user_idstringyesThe member who connected the agent.

Disconnect an agent

DELETE /v1/oauth/grants/{grantId} · revokeOAuthGrant

Auth: Dashboard session cookie + X-CSRF-Token.

Revokes the grant and every token it issued, at once. Dashboard session only.

Parameters

NameInTypeRequiredDescription
grantIdpathstringyes

Responses

StatusMeaning
204Revoked.
401Missing, malformed or rejected credentials.
4031005 insufficient_scope (not yours and not the owner), 1014 csrf_token_invalid.
4043030 oauth_grant_not_found.

    ↑ ↓ 切换 · Enter 打开 · Esc 关闭