Skip to navigation

Agent Java SDK

Agent Java SDK: 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.

Documentation baseline: SDK v0.3.0, commit 54aa3c1. Webhook receiving rules additionally follow WEBHOOKS.md at fa6c7b6; this is a documentation-only update, without a new SDK artifact containing warning helper methods.

Version and installation

ItemValue
Stable source tagv0.3.0
JavaJava 8+
MavenMaven 3.9+
Coordinatescom.sixmm.exchange.sdk:agent:0.3.0

GitHub hosts source; it does not make these coordinates resolvable from Maven Central. Use the tagged local installation or your approved artifact repository.

What The SDK Covers

CategoryScenarioSDK APIDescription
User bindingBind userbindCreate or fetch the binding between a partner user and a 6MM platform user
Asset queriesQuery partner accountqueryAccountQuery the partner margin or funding account
Asset queriesQuery user assetsqueryUserAssetsQuery Contract assets; use withFunding() to include Funding balances
TransfersFixed amount transfertransferTransfer funds into or out of 6MM
TransfersTransfer all outtransferAllOutMove all withdrawable user balance back to the partner platform
TransfersReverse orderreverseReverse a successful transfer when the backend supports a compensation flow
TransfersQuery orderqueryOrderQuery one transfer order by partner order number
TransfersList orderslistOrdersPage through transfer orders for reconciliation
WebhookSignature verificationWebhookVerifier.verifyVerify raw funds-event and liquidation-warning bodies; merchant code handles time, ownership, and persistent deduplication checks. See Webhook Events & Liquidation Warnings.
Funding walletFunding transferwalletTransferPartner ↔ Funding or Funding ↔ Contract; confirm the returned status
Funding walletFunding transfer statusqueryWalletTransferRecover a Funding operation using its original partner order number
Trading entryDirect entry URLcreateEntryUrlCreate a one-time SSO URL for redirect mode
Trading entryEmbed tokencreateEmbedTokenCreate a short-lived token for Trading Widget tokenProvider mode
Perpetual dataCurrent perpetual orderslistCurrentPerpetualOrdersQuery current NORMAL or CONDITIONAL orders
Perpetual dataPerpetual order historylistPerpetualOrderHistoryQuery terminal NORMAL or CONDITIONAL orders
Perpetual dataPerpetual tradeslistPerpetualTradesQuery trade fills for an explicit public player list
Perpetual dataCurrent perpetual positionslistCurrentPerpetualPositionsQuery current positions
Perpetual dataPerpetual position historylistPerpetualPositionHistoryQuery closed positions
Perpetual dataPerpetual account ledgerlistPerpetualLedgerQuery individual Contract balance-change records
Fiat reference ratesList supported fiat currencieslistSupportedFiatCurrenciesList fiat currencies currently convertible to USDT
Fiat reference ratesQuery FX reference ratesqueryExchangeRatesQuery daily fiat-to-USDT reference ratios for all or selected currencies
Service informationService versionversionQuery Agent service version information

Configuration

Obtain the following values from 6MM before integrating.

ItemExampleDescription
baseUrlhttps://agent-api.6mm.comAgent API base URL, without a trailing slash
agentCodeAGENT001Partner code
apiSecretyour-api-secretAPI signing secret. Keep it on the backend only
defaultCurrencyUSDTDefault currency, usually USDT
webhookUrlhttps://partner.example.com/6mm/webhookMerchant callback URL shared by all four event types; dispatch by body event, with no separate warning URL.

Production recommendations:

  • Use HTTPS for Agent API and webhook endpoints.
  • Store apiSecret in a secret manager, configuration center, or environment variable.
  • Keep server time synchronized, preferably with NTP.
  • Persist all partner order numbers and keep them globally unique.
  • Never send apiSecret to browsers, apps, mini programs, or frontend source code.

Automatic Signing Fields

For signed Agent API calls, the SDK automatically injects:

FieldSourceDescription
agentCodeAgentClientConfig.agentCodePartner code
timestampCurrent UTC Unix timestampSeconds
nonceSecure random generatorReplay protection
signHMAC-SHA256Request signature
currencydefaultCurrencyFilled when transfer/account requests omit currency

Signing rules:

  1. Exclude sign.
  2. Exclude empty values.
  3. Sort keys by ASCII order.
  4. Join as k=v&k2=v2.
  5. Calculate HMAC-SHA256 hex with apiSecret.

Array values are serialized as compact JSON before joining the signing payload. For example, platformUserIds signs as ["1188041528"], giving platformUserIds=["1188041528"] in the k=v payload. Preserve the array element order, double quotes and string IDs; do not insert formatting spaces or use Java List.toString() (such as [1188041528]). The SDK handles this serialization automatically.

Normal business code should not calculate signatures or manually set agentCode, timestamp, nonce, or sign.