postQuote

suspend fun postQuote(request: Sep38QuoteRequest, jwtToken: String): Sep38QuoteResponse

Requests a firm quote with binding commitment from the anchor.

Creates a quote that the anchor is committed to honor until expiration. Unlike indicative prices, firm quotes reserve liquidity at the quoted rate. The returned quote ID can be used with SEP-6, SEP-24, or SEP-31 transactions to execute the exchange at the guaranteed rate.

The request must provide either Sep38QuoteRequest.sellAmount or Sep38QuoteRequest.buyAmount, but not both. This is validated before sending the request.

Authentication is required. The JWT token must be obtained via SEP-10 WebAuth and the user must be properly KYC'ed (via SEP-12 or other mechanism) to prevent abuse of the quote system.

Return

Sep38QuoteResponse containing firm quote with unique ID

Parameters

request

Quote request parameters

jwtToken

Required JWT token from SEP-10 authentication

Throws

If both or neither amount parameters are provided in request

If request parameters are invalid (400)

If authentication is missing or invalid (403)

For unexpected HTTP status codes

Example:

val quoteRequest = Sep38QuoteRequest(
context = "sep6",
sellAsset = "iso4217:BRL",
buyAsset = "stellar:USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
sellAmount = "542",
sellDeliveryMethod = "PIX",
countryCode = "BR"
)

val quote = quoteService.postQuote(quoteRequest, jwtToken)

println("Quote ID: ${quote.id}")
println("Valid until: ${quote.expiresAt}")
println("Guaranteed exchange rate: ${quote.price}")
println("Total with fees: ${quote.totalPrice}")

// Use quote.id in SEP-6/24/31 transaction