Back to Ccxt

Agent SAPI API Reference

.agents/skills/p2p/references/agent-sapi-api.md

4.5.6525.0 KB
Original Source

Agent SAPI API Reference

Complete API reference for all C2C Agent SAPI endpoints used by the P2P Skill (Phase 3).

All endpoints require authentication (API Key + HMAC SHA256 signature). See authentication.md for signing details.

Base URL: https://api.binance.com

Common Headers:

X-MBX-APIKEY: {your_api_key}
User-Agent: binance-wallet/1.0.0 (Skill)

Common Response Wrapper:

json
{
  "code": "000000",
  "message": null,
  "data": { ... },
  "success": true
}

Paginated Response Wrapper:

json
{
  "code": "000000",
  "data": [ ... ],
  "total": 100,
  "success": true
}

1. Order Match APIs

1.1 Get Order Detail

Get detailed information for a specific order.

POST /sapi/v1/c2c/agent/orderMatch/getUserOrderDetail

Request Body (JSON):

FieldTypeRequiredDescription
orderNumberStringYesOrder number to query

Response (AgentOrderDetailResp):

FieldTypeDescription
orderNumberStringOrder number
advOrderNumberStringAdvertisement order number
tradeTypeStringBUY / SELL
orderStatusInteger1=Unpaid, 2=Paid, 3=Appealing, 4=Completed, 6=Cancelled, 7=CancelledBySystem
assetStringCrypto asset (e.g. USDT)
amountBigDecimalCrypto amount
priceBigDecimalUnit price
totalPriceBigDecimalTotal fiat amount
fiatUnitStringFiat currency code
fiatSymbolStringFiat symbol (e.g. ¥)
buyerNicknameStringBuyer nickname (not masked)
sellerNicknameStringSeller nickname (not masked)
createTimeDateOrder creation time
notifyPayTimeDateBuyer marked paid time
confirmPayTimeDateSeller confirmed time
cancelTimeDateOrder cancel time
notifyPayEndTimeDatePayment deadline
confirmPayEndTimeDateRelease deadline
isComplaintAllowedBooleanWhether complaint is allowed
complaintStatusIntegerComplaint status
commissionRateBigDecimalMaker commission rate
commissionBigDecimalMaker commission amount
takerCommissionRateBigDecimalTaker commission rate
takerCommissionBigDecimalTaker commission amount
takerAmountBigDecimalTaker net amount

Example:

bash
curl -X POST "https://api.binance.com/sapi/v1/c2c/agent/orderMatch/getUserOrderDetail?timestamp=${TIMESTAMP}&signature=${SIGNATURE}" \
  -H "X-MBX-APIKEY: ${API_KEY}" \
  -H "User-Agent: binance-wallet/1.0.0 (Skill)" \
  -H "Content-Type: application/json" \
  -d '{"orderNumber": "20260315123456789"}'

Note: See authentication.md for the complete Bash signing setup.


1.2 List Orders

List orders with rich filters and pagination.

POST /sapi/v1/c2c/agent/orderMatch/listOrders

Request Body (JSON):

FieldTypeRequiredDefaultDescription
advNoStringNoFilter by advertisement number
assetStringNoFilter by crypto asset
orderStatusIntegerNoFilter by single status
tradeTypeStringNo0=BUY, 1=SELL
payTypeIntegerNoFilter by payment method type
orderStatusListList<Integer>NoFilter by multiple statuses
startDateLongNoStart timestamp (ms)
endDateLongNoEnd timestamp (ms)
pageIntegerNo1Page number
rowsIntegerNo20Page size (max 20)

Response (Paginated List of AgentOrderListResp):

FieldTypeDescription
orderNumberStringOrder number
advNoStringAdvertisement number
tradeTypeStringTrade type
assetStringCrypto asset
fiatStringFiat currency
fiatSymbolStringFiat symbol
amountStringCrypto amount
totalPriceStringTotal fiat amount
orderStatusIntegerStatus code
createTimeDateCreation time
confirmPayEndTimeDateRelease deadline
notifyPayEndTimeDatePayment deadline
buyerNicknameStringBuyer nickname
sellerNicknameStringSeller nickname
commissionRateBigDecimalMaker commission rate
commissionBigDecimalMaker commission
takerCommissionRateBigDecimalTaker commission rate
takerCommissionBigDecimalTaker commission
takerAmountBigDecimalTaker net amount

1.3 List User Order History

List historical orders with pagination.

GET /sapi/v1/c2c/agent/orderMatch/listUserOrderHistory

Query Parameters:

FieldTypeRequiredDefaultDescription
startTimestampLongNo30 days agoStart timestamp (ms)
endTimestampLongNonowEnd timestamp (ms)
tradeTypeStringNoBUY / SELL
pageIntegerNo1Page number (min 1)
rowsIntegerNo100Page size (min 1, max 100)

Response (Paginated List of AgentOrderHistoryResp):

FieldTypeDescription
orderNumberStringOrder number
advNoStringAdvertisement number
tradeTypeStringTrade type
assetStringCrypto asset
fiatStringFiat currency
fiatSymbolStringFiat symbol
amountStringCrypto amount
totalPriceStringTotal fiat amount
unitPriceBigDecimalUnit price
orderStatusStringStatus name (e.g. COMPLETED)
createTimeDateCreation time
commissionBigDecimalCommission
takerCommissionRateBigDecimalTaker commission rate
takerCommissionBigDecimalTaker commission
takerAmountBigDecimalTaker net amount
counterPartNickNameStringCounterparty nickname (not masked)
payMethodNameStringPayment method name
advertisementRoleStringMAKER / TAKER

2. Complaint APIs

2.1 Query Complaints

Query complaint/appeal records with filters and pagination.

POST /sapi/v1/c2c/agent/complaint/query-complaints

Request Body (JSON):

FieldTypeRequiredDefaultDescription
roleIdentityStringNoCOMPLAINANT or RESPONDENT
orderNoListList<String>NoFilter by order numbers
complaintStatusListList<Integer>NoFilter by complaint statuses
orderStatusListWhenInitiateList<Integer>NoFilter by order status at complaint time
startTimeDateNo90 days agoQuery start time
endTimeDateNonowQuery end time
pageIntegerNo1Page number
rowsIntegerNo20Page size

Response (Paginated List of AgentComplaintQueryResp):

FieldTypeDescription
orderNoStringOrder number
complaintNoLongComplaint number
complaintStatusIntegerComplaint status
orderStatusWhenInitiateIntegerOrder status when complaint was filed
complaintCreateTimeDateComplaint creation time
reasonStringComplaint reason
roleIdentityStringCOMPLAINANT / RESPONDENT
orderFiatStringOrder fiat currency
orderAssetStringOrder crypto asset
orderAmountBigDecimalOrder amount
orderAmountInUsdtBigDecimalOrder amount in USDT
disputeAmountBigDecimalDispute amount

3. Ads APIs

3.1 Get Ad Detail By Number

POST /sapi/v1/c2c/agent/ads/getDetailByNo?advNo={advNo}

Query Parameters:

FieldTypeRequiredDescription
advNoStringYesAdvertisement number

Note: This endpoint only returns ads owned by the authenticated user. Querying another user's ad will return error -1002.

Response (AgentAdDetailResp):

FieldTypeDescription
advNoStringAdvertisement number
classifyStringmass / profession / block / cash
tradeTypeStringBUY / SELL
assetStringCrypto asset
fiatUnitStringFiat currency code
advStatusInteger1=Online, 3=Offline, 4=Closed
priceTypeInteger1=Fixed, 2=Floating
priceFloatingRatioBigDecimalFloating ratio %
priceBigDecimalUnit price
initAmountBigDecimalInitial amount
surplusAmountBigDecimalRemaining amount
tradableQuantityBigDecimalTradable quantity
maxSingleTransAmountBigDecimalMax fiat per order
minSingleTransAmountBigDecimalMin fiat per order
payTimeLimitIntegerPayment time limit (min)
remarksStringRemarks
autoReplyMsgStringAuto reply message
createTimeDateCreation time
tradeMethodsList<AgentTradeMethodResp>Payment methods
commissionRateBigDecimalCommission rate
buyerKycLimitIntegerBuyer KYC required
buyerRegDaysLimitIntegerBuyer min reg days
buyerBtcPositionLimitBigDecimalBuyer min BTC
takerAdditionalKycRequiredIntegerExtra verification

AgentTradeMethodResp:

FieldTypeDescription
identifierStringMethod identifier (e.g. ALIPAY)
tradeMethodNameStringDisplay name
iconUrlColorStringIcon URL

3.2 List Ads With Pagination

List current user's own advertisements.

POST /sapi/v1/c2c/agent/ads/listWithPagination

Request Body (JSON):

FieldTypeRequiredDefaultDescription
pageIntegerNo1Page number
rowsIntegerNo20Page size

Response: Paginated list of AgentAdDetailResp (same schema as 3.1).


3.3 Search Ads

Search market ads with rich filters.

POST /sapi/v1/c2c/agent/ads/search

Request Body (JSON):

FieldTypeRequiredDefaultDescription
publisherTypeStringNo"user" or "merchant"
fiatStringYesFiat currency
assetStringYesCrypto asset
tradeTypeStringYesBUY / SELL
payTypesList<String>NoPayment method filters
transAmountBigDecimalNoTransaction amount filter
countriesList<String>NoCountry filters
classifiesList<String>NoautoAd classifies filter
pageIntegerNo1Page number
rowsIntegerNo20Page size

Response (Paginated List of AgentAdSearchResp):

FieldTypeDescription
advAgentAdDetailRespAd detail (see 3.1)
advertiserAgentAdvertiserRespAdvertiser info

AgentAdvertiserResp:

FieldTypeDescription
userNoStringUser number
nickNameStringNickname (not masked)
orderCountIntegerTotal order count
monthOrderCountInteger30-day orders
monthFinishRateBigDecimal30-day completion rate
advConfirmTimeIntegerAvg release time (seconds)
userTypeStringuser / merchant
tagIconUrlsList<String>Tag icon URLs

3.4 Get Reference Price

Get market reference prices for pricing decisions.

POST /sapi/v1/c2c/agent/ads/getReferencePrice

Request Body (JSON):

FieldTypeRequiredDescription
assetsList<String>NoCrypto assets (max 3), e.g. ["BTC","ETH","USDT"]
fiatCurrencyStringYesFiat currency
tradeTypeStringYesBUY or SELL
payTypeStringNoPayment method filter

Response (List of AgentAdReferencePriceResp):

FieldTypeDescription
assetStringCrypto asset
currencyStringFiat currency
currencyScaleIntegerFiat decimal scale
currencySymbolStringFiat symbol
referencePriceBigDecimalReference exchange rate
assetScaleIntegerAsset decimal scale
priceScaleIntegerPrice decimal scale

3.5 Get Available Ads Category

Get ad categories the current user can publish.

GET /sapi/v1/c2c/agent/ads/getAvailableAdsCategory

No request body.

Response (AgentAdsCategoryResp):

FieldTypeDescription
advClassifiesList<String>Available classifies: mass, profession, block, cash

3.6 Get User Payment Methods

Get current user's configured payment methods (agent-safe: no account details).

GET /sapi/v1/c2c/agent/ads/getPayMethodByUserId

No request body.

Response (List of AgentPayMethodResp):

FieldTypeDescription
payIdLongPayment method ID (needed for SELL ads)
identifierStringMethod identifier (e.g. ALIPAY)
tradeMethodNameStringDisplay name

Note: For SELL ads, use payId in tradeMethods. For BUY ads, use identifier from system trade methods.


3.7 List All System Trade Methods

List all available trade methods in the system.

POST /sapi/v1/c2c/agent/ads/listAllTradeMethods

No request body.

Response (List of TradeMethodBaseInfoVO):

FieldTypeDescription
identifierStringTrade method identifier
tradeMethodNameStringDisplay name
(other fields)Additional method info

3.8 Post Ad (Write Operation)

Publish a new advertisement. Requires merchant permission.

POST /sapi/v1/c2c/agent/ads/post

Request Body (JSON):

FieldTypeRequiredDefaultDescription
classifyStringYes"mass"Ad category
tradeTypeStringYes0=BUY, 1=SELL
assetStringYesCrypto asset
fiatUnitStringYesFiat currency
priceTypeIntegerYes1=Fixed, 2=Floating
priceFloatingRatioBigDecimalConditionalRequired if priceType=2
rateFloatingRatioBigDecimalNoExchange rate floating
priceBigDecimalConditionalRequired if priceType=1
initAmountBigDecimalYesTotal crypto amount
maxSingleTransAmountBigDecimalYesMax fiat per order
minSingleTransAmountBigDecimalYesMin fiat per order
buyerKycLimitIntegerYes0=No, 1=Yes
buyerRegDaysLimitIntegerNoMin buyer reg days
buyerBtcPositionLimitBigDecimalNoMin buyer BTC
remarksStringNoMax 1000 chars
autoReplyMsgStringNoMax 1000 chars
onlineNowBooleanNoGo online immediately
payTimeLimitIntegerNoPayment time limit (min)
tradeMethodsList<TradeMethod>YesPayment methods
takerAdditionalKycRequiredIntegerNo0=No, 1=Yes
launchCountryList<String>NoTarget countries

TradeMethod object:

FieldTypeDescription
payIdLongUser's payment method ID (for SELL ads)
payTypeStringPayment type
identifierStringTrade method identifier (for BUY ads)

Response: CommonRet<String> where data is the new ad number (advNo).


3.9 Update Ad (Write Operation)

Update an existing advertisement. Requires merchant permission.

Important — full-object update: The downstream service validates the complete ad object, not just the changed fields. Sending only advNo + one field (e.g. price) will result in error -9000. The recommended workflow is:

  1. Call getDetailByNo?advNo={advNo} to fetch the current ad.
  2. Merge your changes into the full response object.
  3. Submit the merged object to this endpoint.
POST /sapi/v1/c2c/agent/ads/update

Request Body (JSON):

FieldTypeRequiredDescription
advNoStringYesAd number to update
tradeTypeStringNo0=BUY, 1=SELL
assetStringNoCrypto asset
fiatUnitStringNoFiat currency
priceTypeIntegerNo1=Fixed, 2=Floating
priceFloatingRatioBigDecimalNoFloating ratio
rateFloatingRatioBigDecimalNoRate floating
priceBigDecimalNoFixed price
initAmountBigDecimalNoTotal amount
maxSingleTransAmountBigDecimalNoMax fiat per order
minSingleTransAmountBigDecimalNoMin fiat per order
buyerKycLimitIntegerNo0=No, 1=Yes
buyerRegDaysLimitIntegerNoMin reg days
buyerBtcPositionLimitBigDecimalNoMin BTC
remarksStringNoRemarks
autoReplyMsgStringNoAuto reply
payTimeLimitIntegerNoPayment time limit
tradeMethodsList<TradeMethod>NoPayment methods
advStatusIntegerNo1=Online, 3=Offline, 4=Closed
takerAdditionalKycRequiredIntegerNo0=No, 1=Yes
launchCountryList<String>NoCountries

Response: CommonRet<Boolean> — true if update succeeded.


3.10 Update Ad Status (Write Operation)

Batch update advertisement status (online/offline/close).

POST /sapi/v1/c2c/agent/ads/updateStatus

Request Body (JSON):

FieldTypeRequiredDescription
advNosList<String>YesAd numbers to update (min 1)
advStatusIntegerYes1=Online, 3=Offline, 4=Closed

Response (AgentAdUpdateStatusResp):

FieldTypeDescription
statusBooleanOverall success/failure
failListList<StatusUpdateResult>Failed items (if any)

StatusUpdateResult:

FieldTypeDescription
advNoStringFailed ad number
errorCodeStringError code
errorMessageStringError description

4. Merchant APIs

4.1 Get Merchant Ad Details

Get merchant public profile with buy/sell ad listings.

GET /sapi/v1/c2c/agent/merchant/getAdDetails?merchantNo={merchantNo}

Query Parameters:

FieldTypeRequiredDescription
merchantNoStringYesMerchant number

Response (AgentMerchantAdsDetailResp):

FieldTypeDescription
merchantAgentMerchantDetailRespMerchant profile
buyListList<AgentAdDetailResp>Buy advertisements
sellListList<AgentAdDetailResp>Sell advertisements

AgentMerchantDetailResp:

FieldTypeDescription
merchantNoStringMerchant number
userTypeStringuser / merchant
nickNameStringNickname (not masked)
orderCountIntegerTotal order count
monthOrderCountInteger30-day orders
monthFinishRateBigDecimal30-day completion rate
advConfirmTimeIntegerAvg release time (s)
onlineStatusString0=Offline, 1=Online
registerDaysIntegerRegistration days
firstOrderDaysIntegerDays since first order
avgReleaseTimeOfLatest30dayDouble30-day avg release (s)
avgPayTimeOfLatest30dayDouble30-day avg payment (s)
completedOrderNumOfLatest30dayLong30-day completed orders

5. Support APIs

5.1 List Digital Currencies

POST /sapi/v1/c2c/agent/digitalCurrency/list

No request body.

Response: List<DigitalCurrencyResponse> — all supported digital currencies.


5.2 List Fiat Currencies

POST /sapi/v1/c2c/agent/fiatCurrency/list

No request body.

Response: List<FiatCurrencyResponse> — all supported fiat currencies.


Authentication Notes

All Agent SAPI endpoints share the same authentication mechanism:

  1. All requests require timestamp and signature query parameters
  2. SAPI signing: DO NOT sort parameters — keep insertion order
  3. Required headers: X-MBX-APIKEY + User-Agent
  4. See authentication.md for complete signing process

Privacy & Security

All Agent SAPI responses are pre-filtered at the DTO level:

  • Excluded: real names, phone numbers, emails, bank accounts, payment details, KYC info
  • Included: nicknames (not masked), order/ad data, trade statistics
  • The Agent field filter (AgentFieldFilter) handles any runtime masking needed

6. File Upload (AgentFileUploadController)

Base path: /sapi/v1/c2c/agent/file-upload

6.1 Get S3 Presigned URL

GET /sapi/v1/c2c/agent/file-upload/get-s3-presigned-url

Get a presigned S3 URL for uploading complaint evidence files. The URL is valid for 5 minutes.

Query Parameters:

ParameterTypeRequiredDescription
fileNameStringYesFile name with extension, e.g. proof.jpg
scenarioStringNoUpload scenario. Default: complaint. Agent only supports complaint.

Response: S3FileUrlInfo

FieldTypeDescription
uploadUrlStringS3 presigned upload URL (PUT to this URL with file binary)
filePathStringFinal file path in S3 (use this in submit-evidence fileUrls)

Supported file types (complaint scenario): txt, doc, xls, docx, xlsx, jpg, jpeg, png, pdf, mp3, mp4, avi, rm, rmvb, mov, wmv

Upload flow:

  1. Call this endpoint to get uploadUrl and filePath
  2. PUT the file binary to uploadUrl (must complete within 5 minutes)
  3. Use filePath in the submit-evidence request

7. Complaint Operations (AgentComplaintController — Extended)

These endpoints extend the existing complaint controller (Section 2).

7.1 Submit Appeal Evidence

POST /sapi/v1/c2c/agent/complaint/submit-evidence

Submit supplementary evidence for an existing complaint/appeal.

Request Body: AgentComplaintSupplementReq

FieldTypeRequiredDescription
orderNoStringYesOrder number
descriptionStringYesEvidence description (1-500 chars)
fileUrlsList<String>NoList of S3 file paths from presigned upload

Response: Booleantrue if evidence submitted successfully.

Error cases:

  • Order not found / not in appeal → error response
  • No active complaint for order → error response
  • File URLs not from valid S3 upload → may fail validation

7.2 Get Complaint Flows (Timeline)

POST /sapi/v1/c2c/agent/complaint/get-complaint-flows

Get the chronological timeline of a complaint process, including all actions, evidence submissions, and CS reviews.

Request Body: AgentComplaintFlowQueryReq

FieldTypeRequiredDescription
orderNoStringYesOrder number
complaintNoLongNoSpecific complaint number (optional; narrows to specific complaint)

Response: List<AgentComplaintFlowResp>

FieldTypeDescription
complaintNoLongComplaint number
orderNoStringOrder number
infoTypeIntegerFlow info type (1=Initiated, 2=Evidence, 3=CS Note, 4=Resolution)
descriptionStringFlow entry description
fileUrlsList<String>Evidence file URLs (CDN-assembled, directly accessible)
creatorNickNameStringCreator nickname
operatorNameStringOperator name (CS agent if applicable)
remarkStringRemark (plain text)
remarkHtmlStringRemark (HTML version; takes precedence over remark when available)
createTimeDateFlow entry creation time
sourceStringFlow info source

7.3 Cancel Complaint

POST /sapi/v1/c2c/agent/complaint/cancel-complaint

Cancel (withdraw) an existing complaint/appeal for an order. This is an irreversible action.

Request Body: AgentComplaintCancelReq

FieldTypeRequiredDescription
orderNoStringYesOrder number of the complaint to cancel

Response: Booleantrue if the complaint was successfully cancelled.

Error cases:

  • Order not found → error response
  • No active complaint for order → error response
  • Complaint already resolved/closed → error response
  • User not the complaint initiator → error response

Important: The agent MUST confirm with the user before calling this endpoint, as cancelling an appeal is irreversible and the user forfeits their dispute rights.


7.4 Get Complaint Reasons

POST /sapi/v1/c2c/agent/complaint/get-complaint-reasons

Get available complaint/appeal reasons for a given order. Returns localized reason descriptions.

Request Body: AgentComplaintCancelReq (reused — only needs orderNo)

FieldTypeRequiredDescription
orderNoStringYesOrder number to get complaint reasons for

Response: List<AgentComplaintReasonResp>

FieldTypeDescription
reasonCodeIntegerReason code identifier
reasonDescStringLocalized reason description

Error cases:

  • Order not found → error response
  • Order not in a state where complaints are applicable → error response