POST Quote a Transaction

POST /disbursement/v1/transactions/quote

Development Guide

The Quote a Transaction endpoint creates an array of transaction quotes for a given destination country. Each transaction quote will include the unique service option, send amount, receive amount, currencies, fees and fx. A unique transactionId resource will be created for each transaction quote.



1. Prepare headers & authentication:

Call the 'Quote a transaction' endpoint with a POST HTTP method, providing the OAuth access_token in the header and all other required header values


Note: MoneyGram uses the OAuth 2.0 framework. The application must use their OAuth client credentials to generate an accessToken by calling the Get access token endpoint. The token is valid for **1 hour ** and must be passed as a header value in all subsequent API HTTP calls. Learn More


🚀

Launch Code Example:




2. Provide Request Body: "Quote by send amount" OR "Quote by receive amount":

The Quote API uses the oneOf Keyword to allow the application to either quote a transaction by send or receive amount:


  • Quote by send amount: The application must provide at a minimum the targetAudience, agentPartnerId, destinationCountryCode, beneficiaryTypeCode and the sendAmount.value fields in the request.
    OR

  • Quote by receive amount: The application must provide the at a minimum the targetAudience, agentPartnerId, destinationCountryCode , beneficiaryTypeCode and the receiveAmount.value fields in the request.

Note: The Quote API uses ISO Standards for country and currency values. MoneyGram provide Reference Data APIs which can be queried to understand and list the supported values and associated metadata.


🚀

Launch Code Example:

.




3. Provide serviceOptionCode in the request body (optional):

The Quote API allows the application to specify one or all service options to be returned to the given destination country:


  • **Quote all service options: **If the serviceOptionCode is not provided in the request body, the quote endpoint will return _all _service options in an array of quoted transactions (i.e. the API will return all cash pickup, bank, wallet & card deposit options available to the destination country). Learn More
    OR

  • Quote a single service option: If the serviceOptionCode is provided in the request body, the quote endpoint will only return an array of quoted transactions for that specified code. (e.g. if "serviceOptionCode": "Bank_Deposit" is passed in the request, the endpoint will only quote the bank deposit options available to the destination country) Learn More

🚀

Launch Code Example:

.




4. Provide discounts to the request body (optional):

The Quote API also allows the application to apply promotional discounts and participate in the MoneyGram Plus Rewards program to accrue/redeem loyalty discounts.


  • If a promotionCodes is passed a discount will be applied to the fee quote.

  • If a rewardsNumber is passed a discount the will be applied to the quote. This is only for eligible transactions.

🚀

Launch Code Example:




5. Make a request and handle the response:

The application must call 'Quote a transaction' endpoint with a POST HTTP method. The endpoint will respond with a HTTP 200 OK status. The Quote API response will provide an array of quoted transactions, each with a unique transactionId resource. The consumer must choose one quote to continue with and the application must persist the associated transactionId to use when calling the subsequent Update API.


  • Success | Parse the Response | 200 OK HTTP Status
    For each transactionId resource generated, the endpoint will typically respond with the following fields serviceOptionCode, serviceOptionName, estimatedDelivery, sendAmount, sendCurrency, fees, taxes, additionalCharges, fxRate, discountsApplied, and the receiveAmount. In some cases send or receive side taxes are applied.

  • Failed | Handle the Error | 400 Bad Request HTTP Status
    When the 'Quote a transaction' endpoint responds with 400 HTTP Status, specific error code/s will be returned with an array of offending fields. The application will need to resolve these errors and resubmit the quote.

Note: The list of transactions returned on the Quote API is priced uniquely by the service options and receive currency. The Fee and FX rate is guaranteed for 30 minutes from the time of the quote. However, the FX rate may change if the transaction is not committed within 30 minutes of the quote.


🚀

Launch Code Example:

.




6. You're Done! Proceed to 'Update a Transaction API':

Once the consumer has selected their quoted transaction, the application must persist the associated transactionId and provide it on the subsequent Update API as a path parameter.




Business Rules to Code


🔍

  1. Retrieving country data: For the destinationCountryCode field, the application must check reference data countries API endpoint and display the name of the countries for which receiveActive: "true". Learn More

  2. Handling FX Rate: Depending on the regulatory and market environment, MoneyGram may provide foreign exchange rates for cross-currency transactions that will be guaranteed at the time of send, or rates that are only estimated at the time of sending. Learn More

  3. UI Disclaimers: If amounts are given to the consumer in writing prior to the update a transaction, the application must display a disclaimer stating the amounts are not guaranteed until the update a transaction is complete. Learn More

  4. Prepayment Disclosure: The amounts returned in the quote a transaction response must **not **be used to print the Pre-Payment Disclosure. Learn More



Code Examples

const axios = require('axios');
const { v4: uuidv4 } = require('uuid');

const quoteTransaction = async () => {

    // Step 1: Read configuration values with upmost security
    const token = "your_access_token_from_oauth_response"
    // For production - api.moneygram.com & For test - sandboxapi.moneygram.com
    const host = "sandboxapi.moneygram.com";
    const url = 'https://' + host + '/disbursement/v1/transactions/quote';

    // Step 2: Create the POST request headers & body
    const headers = {
        'Content-Type': 'application/json',
        'X-MG-ClientRequestId': uuidv4(), // New UUID for each request tracing
        'Authorization': 'Bearer ' + token,
    };
    const request = {
        agentPartnerId: "your_partner_id",
        targetAudience: "AGENT_FACING",
        userLanguage: "en-US",
        destinationCountryCode: "USA",
        destinationCountrySubdivisionCode: "US-MN",
        serviceOptionCode: "WILL_CALL",
        beneficiaryTypeCode: "Consumer",
        sendAmount: {
            currencyCode: "USD",
            value: 500
        },
        receiveCurrencyCode: "USD",
    }

    try {
        // Step 3: Send the request and obtain the response
        axios.post(url, request, { headers })
            .then(function (response) {
                // Step 4: Parse the success response and process further
                console.log(JSON.stringify(response.data, null, 2))
            })
            .catch(function (error) {
                // Step 5: Parse the error response and handle the errors
                if (error.response) {
                    console.log('Response status:', error.response.status);
                    console.log('Response body:', error.response.data);
                } else {
                    // TODO: handle generic errors
                    console.error('Error:', error.message);
                }
            });
    } catch (error) {
        // TODO: handle exception
        console.error('Error:', error.message);
    }
};

quoteTransaction();

import requests
import uuid
import json

def quote_transaction():

    # Step 1: Read configuration values with upmost security
    token = "your_access_token_from_oauth_response"
    # For production - api.moneygram.com & For test - sandboxapi.moneygram.com
    host = "sandboxapi.moneygram.com";
    url = 'https://' + host + '/disbursement/v1/transactions/quote';

    # Step 2: Create the POST request headers & body
    headers = {
        'Content-Type': 'application/json',
        'X-MG-ClientRequestId': str(uuid.uuid4()), # New UUID for each request tracing
        'Authorization': 'Bearer ' + token,
    }
    request = {
        'agentPartnerId': 'your_partner_id',
        'targetAudience': 'AGENT_FACING',
        'userLanguage': 'en-US',
        'destinationCountryCode': 'USA',
        'destinationCountrySubdivisionCode': 'US-MN',
        'serviceOptionCode': 'WILL_CALL',
 				'beneficiaryTypeCode': "Consumer",     
        'sendAmount': {
            'currencyCode': 'USD',
            'value': 500
        },
        'receiveCurrencyCode': 'USD',
    }

    try:
        # Step 3: Send the request and obtain the response
        response = requests.post(url, json=request, headers=headers)

        # Step 4: Parse the success response and process further
        if response.status_code == 200:
            parsed_response = json.dumps(json.loads(response.text), indent=2)
            print(parsed_response)
        else:
            # Print the error message if request fails
            # TODO: handle exception
            print("Request failed with status code:", response.status_code)
            print(json.loads(json.dumps(response.text, indent=4)))

    except requests.exceptions.RequestException as e:
        # Print any error that occurred during the request
        # TODO: handle exception
        print("An error occurred:", e)

quote_transaction()
package disbursement;

import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonWriter;
import java.io.StringWriter;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.UUID;

public class QuoteTransaction {

    public static void main(String[] args) {
        // Step 1: Read configuration values with upmost security
        String token = "your_access_token_from_oauth_response";

        // For production - api.moneygram.com & For test - sandboxapi.moneygram.com
        String host = "sandboxapi.moneygram.com";
        String tokenEndpoint = "https://" + host + "/disbursement/v1/transactions/quote";

        // Step 2: Create the POST request headers & body
        // Create a JSON object
        JsonObjectBuilder sendAmountBuilder = Json.createObjectBuilder()
                .add("currencyCode", "USD")
                .add("value", 500);
        JsonObjectBuilder requestBuilder = Json.createObjectBuilder()
                .add("agentPartnerId", "your_partner_id")
                .add("targetAudience", "AGENT_FACING")
                .add("userLanguage", "en-US")
                .add("destinationCountryCode", "USA")
                .add("destinationCountrySubdivisionCode", "US-MN")
                .add("serviceOptionCode", "WILL_CALL")
          			.add("beneficiaryTypeCode", "Consumer")
                .add("sendAmount", sendAmountBuilder)
                .add("receiveCurrencyCode", "USD");

        JsonObject jsonObject = requestBuilder.build();
        // Create a StringWriter to write the JSON string
        StringWriter stringWriter = new StringWriter();
        try (JsonWriter jsonWriter = Json.createWriter(stringWriter)) {
            jsonWriter.writeObject(jsonObject);
        }
        // Get the JSON string from the StringWriter
        String jsonString = stringWriter.toString();

        HttpClient httpClient = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(tokenEndpoint))
                .POST(HttpRequest.BodyPublishers.ofString(jsonString))
                .setHeader("Authorization", "Bearer " + token)
                .setHeader("X-MG-ClientRequestId", String.valueOf(UUID.randomUUID()))
                .build();

        try {
            // Step 3: Send the request and obtain the response
            HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());

            // Retrieve the status code and body from the response
            int statusCode = response.statusCode();

            // Step 4: Parse the success response and process further
            if (statusCode == 200) {
                String responseBody = response.body();
                System.out.println(responseBody);
            } else {
                // Step 5: Parse the error response and handle the errors
                String responseBody = response.body();
                System.out.println(responseBody);
            }
        } catch (Exception e) {
            e.printStackTrace();
            // TODO: handle exception
        }
    }
}



Support APIs

The Reference Data APIs Module makes your development easier by providing a list of supported fields, values and associated meta-data to use in your integration.

NameHTTP MethodEndpointsDescription
Retrieve CountriesGET/reference-data/v1/CountryRetrieves supported values and metadata for countries
Retrieve Countries ISO3GET/reference-data/v1 /countries/{iso3Code}Retrieves supported values and metadata for countries by ISO 3 Code
Retrieve CurrenciesGET/reference-data/v1/currenciesRetrieves supported values and metadata for currencies
Retrieve EnumerationsGET/reference-data/v1/enumerationsRetrieves enumerated values for fields
Retrieve Service OptionsGET/reference-data/v1/payout-optionsRetrieves supported values and metadata for Service Options



API Structure


Header Parameters

Name Required
/Optional
Type Description

X-MG-ClientRequestId

Required

String

Client Request ID that can be passed by the client application. Client request ID must be unique within a single session for unique requests. This attribute can be used for ensuring idempotent request processing for some APIs. MoneyGram recommends using a UUID for the value of this field.

X-MG-ConsumerIPAddress

Optional

String

IP Address of the system initiating the session




Request Body Parameters

Body ParameterDescription
quoteBySendAmountRequestTo quote by send amount
quoteByRequestAmountRequestTo quote by receive amount



Request Body Fields

Field Type Required
/Optional
Description

targetAudience

String

Required

Tailors MoneyGram’s error messages and field metadata to an in-store, digital or crypto customer. (Enumerated value)

_NOTE: For a full list of accepted target audience values. See the TARGET_AUDIENCE enumeration from the Reference Data Enumerations endpoint _

agentPartnerId

String
Max length: 8

Required

Unique identifier for the agent or partner

userLanguage

String
Max length: 6

Optional

Language used by the user/operator

destinationCountryCode

String
Min length: 3
Max length: 3

Required

Transaction Destination Country (ISO alpha-3 code)

NOTE: For a full list of accepted destination countries and supported destination country subdivision ISO codes see the Reference Data API Module: Retrieve Countries ISO3 endpoint

destinationCountrySubdivisionCode

String
Max length: 6

Optional

Destination state/province is conditionally required when transacting to certain destination countries. (ISO alpha-3 code)

NOTE: For a full list of accepted destination countries and supported destination country subdivision codes see Reference Data API Module: Retrieve Countries ISO3 endpoint

serviceOptionCode

String
Max length: 21

Optional

Unique category code to identify the transaction method

NOTE: For a full list of accepted service option codes per destination country see the Reference Data API Module: service-options endpoint

beneficiaryTypeCode

String

Required

Specifies the type of beneficiary. This parameter will affect processing rules. (Enumerated Values)[Business, Consumer]

sendAmount.value

String

Required

Transaction send amount excluding fees and exchange rate for a quoteBySendAmount Request

NOTE: For Crypto partners this is the fiat currency for the Buy/Sell or Ramp-on/Ramp-off

sendAmount.currencyCode

String
Max length: 3

Required

Transaction'ssendAmount.value currency code. (ISO alpha-3 code)

receiveCurrencyCode

String
Max length: 3

Required

Receive currency is needed when transacting to a destination country that supports more than one currency for a quoteBySendAmount Request (ISO alpha-3 code)

receiveAmount.value

String

Required

Transaction receive amount excluding fees and exchange rate for a quoteByReceiveAmountRequest request.

NOTE: For Crypto partners this is the fiat currency for the Buy/Sell or Ramp-on/Ramp-off

receiveAmount.currencyCode

String
Max length: 3

Required

Transaction'sreceiveAmount.value currency code for a quoteByReceiveAmountRequest request.. (ISO alpha-3 code)

sendCurrencyCode

String
Max length: 3

Required

Send Currency's ISO alpha-3 code for a quoteByReceiveAmountRequest request.

promotionCodes

String
Max length: 20

Optional

Unique code to apply a promotional discount

additionalDetails

Dynamic

Optional

Dynamic field key/values



Response Fields

Field Type Required
/Optional
Description

transactions.transactionId

String
Max length: 36

Required

Unique identifier for the transaction resource

transactions.serviceOptionCode

String
Max length: 21

Required

Unique category code to identify the transaction method

NOTE: For a full list of accepted service option codes per destination country see the Reference Data API Module: service-options endpoint

transactions.serviceOptionName

String
Max length: 40

Required

Consumer-facing name to identify the transaction method

NOTE: For a full list of accepted service option display names per destination country see the Reference Data API Module: service-options endpoint

transactions.serviceOptionRoutingCode

String

Optional

Unique identifier of the individual banking, wallet, or card provider for the service option.

NOTE: For a full list of accepted service option routine codes per destination country see the Reference Data API Module: service-options endpoint

transactions.serviceOptionRoutingName

String
Max length: 50

Optional

Unique name to identify the individual transaction method

transactions.sendAmount.amount.value

String
Min length: 0

Max length: 14

Max decimal Value: 3

Required

Transaction amount and currency excluding fees and exchange rate.

NOTE: For Crypto partners this is the fiat currency for the BUY/Sell or Ramp-on/Ramp-off

For a full list of transaction currency codes see the API Reference Data Module: currencies endpoint

transactions.sendAmount.amount.currencyCode

String

Required

The sendAmount.amount.value currency code (ISO alpha-3 code)

transactions.sendAmount.fees.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Required

Fee Amount and Fee Currency applied to transaction (Fee Currency uses ISO alpha-3 code)

transactions.sendAmount.fees.currencyCode

String

Required

The sendAmount.fees.value currency code (ISO alpha-3 code)

transactions.sendAmount.taxes.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Optional

Tax amount and tax currency applied to the transaction by the the origin country (Tax Currency uses ISO alpha-3 code)

transactions.sendAmount.taxes.currencyCode

String

Optional

The sendAmount.taxes.value currency code (ISO alpha-3 code)

transactions.sendAmount.additionalCharges.typeCode

String

Optional

Code to indicate if the fee is to be collected by MoneyGram or the partner

transactions.sendAmount.additionalCharges.label

String

Optional

Consumer-facing name to identify the charge type

transactions.sendAmount.additionalCharges.value

String

Optional

Additional fee's amount

transactions.sendAmount.additionalCharges.currencyCode

String

Optional

The transactions.sendAmount.additionalCharges.value currency code (ISO alpha-3 code)

transactions.sendAmount.discountsApplied.totalDiscount

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Optional

Transaction discount amount applied and currency type excluding fees and exchange rate. Transaction Currency (ISO alpha-3 code)

transactions.sendAmount.discountsApplied.promotionDetails.code

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Optional

Discount code associated with a specific business promotion

transactions.sendAmount.discountsApplied.promotionDetails.discount.value

String

Optional

Discount amount

transactions.sendAmount.discountsApplied.promotionDetails.discount.currencyCode

String

Optional

The transactions.sendAmount.discountsApplied.promotionDetails.discount.value currency code (ISO alpha-3 code)

transactions.sendAmount.discountsApplied.promotionDetails.errorCode

String

Optional

Unique error code defined by MoneyGram

transactions.sendAmount.discountsApplied.promotionDetails.errorMessage

String

Optional

Error message associated with the errorCode

transactions.sendAmount.total.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Required

Transaction Total Amount and Transaction Total Currency including fees, taxes and discount. (Transaction Total Amount uses ISO alpha-3 code)

transactions.sendAmount.total.currencyCode

String

Required

The sendAmount.total.value currency code (ISO alpha-3 code)

transactions.receiveAmount.amount.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Required

Transaction Received Amount and Transaction Receive currency (Transaction Total Amount uses ISO alpha-3 code)

transactions.receiveAmount.amount.currencyCode

String

Required

The receiveAmount.amount.value currency code (ISO alpha-3 code)

transactions.receiveAmount.fees.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Optional

Received Fee and Receive Currency applied to the transaction by the destination country (Transaction Total Amount uses ISO alpha-3 code)

transactions.receiveAmount.fees.currencyCode

String

Optional

The receiveAmount.fees.value currency code (ISO alpha-3 code)

transactions.receiveAmount.taxes.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Optional

Tax amount and tax currency applied to the Transaction by the the

transactions.receiveAmount.taxes.currencyCode

String

Optional

The receiveAmount.taxes.value currency code (ISO alpha-3 code)

transactions.receiveAmount.additionalCharges.typeCode

String

Optional

Code to indicate if the fee is to be collected by MoneyGram or the partner

transactions.receiveAmount.additionalCharges.label

String

Optional

Consumer-facing name to identify the charge type

transactions.receiveAmount.additionalCharges.value

String

Optional

Additional fee's amount

transactions.receiveAmount.additionalCharges.currencyCode

String

Optional

The transactions.receiveAmount.additionalCharges.value currency code (ISO alpha-3 code)

transactions.receiveAmount.total.value

String
Min length: 0
Max length: 14
Max Decimal Value: 3

Required

Receive Amount Total and Receive Transaction Currency to be picked-up/deposited in destination country including fees, taxes and discount (Transaction Total Amount uses ISO alpha-3 code)

transactions.receiveAmount.total.currencyCode

String

Required

The receiveAmount.total.value currency code (ISO alpha-3 code)

transactions.receiveAmount.fxRate

Number

Max Decimal Value: 4

Required

Fx Rate applied to transaction

transactions.sendAmount.fxRateEstimated

Boolean

Optional

Indicates whether the Fx is “estimated” and amount, taxes and total cannot be guaranteed. The word “estimated” must appear before receiveAmount.amount, receiveAmount.taxes and receiveAmount.total only when true