Skip to main content
The Web SDK exposes Meld buy, sell, and transfer crypto through portal.ramps.meld. Each method sends a message to the embedded Portal iframe, which calls Portal’s Meld integration on the Client API using your client credentials. You do not call Meld’s servers directly from the browser.
For one-time dashboard setup and webhook configuration, see Meld integration overview. For the end-to-end widget flow using raw HTTP calls, see the White-Label API guide.

Prerequisites

Architecture

Prefer portal.ramps.meld over lower-level APIs. The SDK types for requests and responses live in @portal-hq/web (see the Web SDK reference section portal.ramps.meld (Meld)).

Types and responses

Successful Client API responses use an envelope { data: T, metadata?: Record<string, unknown> }. Methods on portal.ramps.meld return Promise of that envelope (for example MeldCreateRetailWidgetResponse is { data: { widgetUrl: string, ... } }). Throwing or rejected promises usually indicate network errors, iframe timeouts, or API error payloads surfaced by the SDK — handle them with try/catch like other async Portal calls.

Customer methods

createCustomer

Creates a Meld customer record for the current Portal client. This is optional — the widget collects identity inline. Pre-creating is useful when you want to pre-fill KYC fields or track multiple sessions against a persistent customer record.
Signature
ReturnsMeldCreateCustomerResponse: { data: MeldCustomer }.
If a customer already exists for the current Portal client, the Portal API returns 409 Conflict with the existing customer ID at details.meldCustomerId. Retrieve the full record with searchCustomer() instead.

searchCustomer

Returns the Meld customer record(s) associated with the current Portal client.
Signature
ReturnsMeldSearchCustomerResponse: { data: { customers: MeldCustomer[]; count: number; remaining: number } }. data.customers will be empty if no customer has been created for this Portal client yet.

Retail methods

getRetailQuote

Fetches live pricing across Meld’s provider network before opening the widget. Returns one MeldQuote per available provider.
Signature
ReturnsMeldGetRetailQuoteResponse: { data: { quotes: MeldQuote[]; message?: string; error?: string; timestamp?: string } }. Each MeldQuote includes required fields: serviceProvider, transactionType, sourceAmount, sourceCurrencyCode, destinationAmount, destinationCurrencyCode, exchangeRate, transactionFee, totalFee, paymentMethodType; and optional nullable fields: sourceAmountWithoutFees, destinationAmountWithoutFees, networkFee, partnerFee, fiatAmountWithoutFees, countryCode, customerScore, institutionName, isNativeAvailable, rampIntelligence.

createRetailWidget

Creates a Meld widget session and returns a widgetUrl. Open the URL in a new browser tab to let the user complete the buy/sell/transfer flow.
Signature
MeldSessionData fields ReturnsMeldCreateRetailWidgetResponse: { data: { id: string; token: string; customerId: string; externalCustomerId: string; externalSessionId: string; widgetUrl: string } }.
widgetUrl embeds a single-use session token. Do not persist or reuse it. Refer to Meld’s Provider UI Launch Implementation guide for iframe sizing guidance and supported lockFields values.

searchRetailTransactions

Lists Meld retail transactions for the current Portal client with optional filtering.
Signature
ReturnsMeldSearchRetailTransactionsResponse: { data: { transactions: MeldTransaction[]; count: number; remaining: number; totalCount: number } }.

getRetailTransaction

Fetches a single retail transaction by its Meld transaction ID.
Signature
ReturnsMeldGetRetailTransactionResponse: { data: { transaction: MeldTransaction } }.

getRetailTransactionBySession

Fetches the retail transaction associated with a widget session ID.
Signature
ReturnsMeldGetRetailTransactionResponse: { data: { transaction: MeldTransaction } }.
Prefer Meld webhooks over polling for transaction lifecycle updates. Configure them in Meld Dashboard — see Webhooks.

Discovery methods

Discovery endpoints return Meld’s current catalog of supported countries, currencies, payment methods, and limits. Call them at startup or lazily before populating dropdowns.
Cache discovery responses client-side — countries, currencies, and payment methods change rarely and re-querying on every page load adds unnecessary latency.
All discovery methods accept an optional MeldDiscoveryParams object. It accepts countryCode and any additional filter keys Meld documents.

getServiceProviders

Signature
ReturnsMeldGetServiceProvidersResponse: { data: MeldServiceProvider[] }. Each MeldServiceProvider includes: serviceProvider, name, status, categories, categoryStatuses, websiteUrl, customerSupportUrl, and logos (dark/light variants).

getCountries

Signature
ReturnsMeldGetCountriesResponse: { data: MeldCountry[] }. Each MeldCountry includes: countryCode, name, flagImageUrl, and optional regions: { regionCode, name }[].

getFiatCurrencies

Signature
ReturnsMeldGetFiatCurrenciesResponse: { data: MeldFiatCurrency[] }. Each MeldFiatCurrency includes: currencyCode, name, symbolImageUrl.

getCryptoCurrencies

Signature
ReturnsMeldGetCryptoCurrenciesResponse: { data: MeldCryptoCurrency[] }. Each MeldCryptoCurrency includes: currencyCode, name, chainCode, chainName, chainId, contractAddress, symbolImageUrl.
Meld doesn’t accept a separate chain parameter — each token has a distinct currencyCode per chain (a “Meld Code”). Pass the same code from the quote into the widget session so pricing and settlement match.

getPaymentMethods

Signature
ReturnsMeldGetPaymentMethodsResponse: { data: MeldPaymentMethod[] }. Each MeldPaymentMethod includes: paymentMethod, name, paymentType, and optional logos.

getDefaults

Returns the default fiat currency and payment methods per country.
Signature
ReturnsMeldGetDefaultsResponse: { data: MeldCountryDefault[] }. Each MeldCountryDefault includes: countryCode, defaultCurrencyCode, defaultPaymentMethods: string[].

getBuyLimits

Returns minimum, maximum, and default purchase amounts per fiat currency.
Signature
ReturnsMeldGetBuyLimitsResponse: { data: MeldFiatCurrencyPurchaseLimit[] }. Each MeldFiatCurrencyPurchaseLimit includes: currencyCode, defaultAmount, minimumAmount, maximumAmount.

getSellLimits

Returns minimum, maximum, and default sell amounts per crypto currency.
Signature
ReturnsMeldGetSellLimitsResponse: { data: MeldCryptoCurrencySellLimit[] }. Each MeldCryptoCurrencySellLimit includes: currencyCode, chainCode, defaultAmount, minimumAmount, maximumAmount.

getKycLimits

Returns transaction limits per KYC tier and fiat currency.
Signature
ReturnsMeldGetKycLimitsResponse: { data: MeldKycFiatLevel[] }. Each MeldKycFiatLevel includes: currencyCode and optional level1, level2, level3 of type MeldKycLimitTier, each containing dailyLimit, weeklyLimit, monthlyLimit, yearlyLimit, and transactionLimit.

End-to-end example

The following example shows the recommended buy flow: discover, quote, create a widget session, and look up the result.

Error handling

Wrap calls in try/catch. Portal forwards Meld’s HTTP status codes (4xx/5xx) and preserves the upstream error message. Common Portal-side errors:
  • 400 Meld integration is not enabled — turn on the Meld integration for the current Portal environment in the Portal Dashboard.
  • 400 Meld API key is not configured for this environment — paste a valid Meld API key into the integration config.
  • 409 Conflict (on createCustomer) — a Meld customer already exists for this Portal client. Call searchCustomer() to retrieve it.