Skip to navigation

Create Embed Token

Create Embed Token: Agent Java SDK v0.3.0 integration, examples, parameters and response semantics.

View as Markdown

This guide targets Agent Java SDK v0.3.0, Java 8+, and the tagged public contract. Examples run in a partner backend after initializing client in Quick Start.

Example prerequisites

The Java snippets share these imports. Initialize client using Quick Start and obtain platformUserId from the saved binding. Example user/order IDs must be replaced with your own persisted values.

import com.sixmm.agent.*;
import com.sixmm.agent.model.*;
import java.util.*;

Trading Widget Embed Token

Embed token is for Trading Widget SDK partner-token + tokenProvider mode. The browser calls the partner backend, and the partner backend calls this Java SDK to create an embedToken.

import com.sixmm.agent.model.CreateEmbedTokenRequest;
import com.sixmm.agent.model.CreateEmbedTokenResponse;
CreateEmbedTokenResponse resp = client.createEmbedToken(
CreateEmbedTokenRequest.of("agent-user-001", "tw_abc123")
.withSymbol("ETHUSDT"));
System.out.println(resp.embedToken);
System.out.println(resp.expireAt);

Integration requirements:

  • channelId must use the value passed by the Trading Widget SDK.
  • symbol is optional and may carry the current initial symbol. It is not a token trading-pair permission restriction.
  • embedToken is short-lived and one-time. Do not put it into URL query strings.
  • The partner frontend must never hold apiSecret.
  • expireAt is a Unix timestamp in seconds, not a TTL.

Partner backend endpoint example:

@PostMapping("/api/trading/embed-token")
public EmbedTokenView createEmbedToken(@RequestBody EmbedTokenRequest request,
PartnerSession session) {
String agentUserId = session.getAgentUserId();
CreateEmbedTokenResponse resp = agentClient.createEmbedToken(
CreateEmbedTokenRequest.of(agentUserId, request.getChannelId())
.withSymbol(request.getSymbol()));
return new EmbedTokenView(resp.embedToken, resp.expireAt, request.getChannelId());
}

Partner endpoint contract

Authenticate the partner session and derive agentUserId server-side. Accept the current Widget channelId; return top-level embedToken, expireAt (Unix seconds), and the same channelId. Agent responses do not supply channelId: your backend echoes it. Fetch a fresh token on initialization and renewal; never reuse it. Token creation does not transfer funds or choose the wallet environment.

See Seconds trading for the complete frontend/backend flow.