POST Quote a Transaction

POST /transfer/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 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 , 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:

.





Business Rules to Code

🔍
  1. Start online, fund in store: For digital application wanting to fund the transactions in store, set the "fundInStore": true.





Video Tutorial




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 + '/transfer/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",
        sendAmount: {
            currencyCode: "USD",
            value: 500
        },
        receiveCurrencyCode: "USD",
        }
    }

    try {
        // Step 3: Send the request and obtain the response
        axios.put(url, request, { headers })
            .then(function (response) {
                // Step 4: Parse the success response and process further
                // Verify readyForCommit is true, if yes, transaction is ready to commit
                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 + '/transfers/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',
        'sendAmount': {
            'currencyCode': 'USD',
            'value': 500
        },
        'receiveCurrencyCode': 'USD',
        }
    }

    try:
        # Step 3: Send the request and obtain the response
        response = requests.put(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:
            # Step 5: Parse the error response and handle the errors
            print("Request failed with status code:", response.status_code)
            print(json.dumps(json.loads(response.text), indent=2))

    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 transfers;

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 + "/transfer/v1/transactions/quote";

        // Step 2: Create the PUT 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("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))
                .PUT(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

To make your development easier, MoneyGram has provided a Reference Data APIs Module that can be queried to provide 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 Identification DocumentsGET/reference-data/v1/identification-DocumentsRetrieves required fields for identification documents
Retrieve Service OptionsGET/reference-data/v1/payout-optionsRetrieves supported values and metadata for Service Options
Retrieve Fields for a TransferGET/reference-data/v1/transaction-fields-sendRetrieves all the required, and optional fields, and metadata for a send transaction based a service option, destination country, send amount, and send and receive currency.
Retrieve Fields for a PayoutRetrieve Fields for a PayoutGET/reference-data/v1/transaction-fields-receiveRetrieves all the required, and optional fields, and metadata for a send transaction based a service option, receive amount, and receive currency.


API Structure



Header Parameters

FieldTypeRequired /OptionalDescription
X-MG-ClientRequestIdStringRequiredClient 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-ConsumerIPAddressStringOptionalIP Address of the system initiating the session



Request Fields

FieldTypeRequired/OptionalDescription
targetAudienceStringRequiredTailors MoneyGram’s error messages and field metadata to an in-store, digital or crypto consumer. (Enumerated value) _NOTE: For a full list of accepted target audience values. See the TARGET_AUDIENCE enumeration from the Reference Data Enumerations endpoint _
agentPartnerIdString Max length: 5RequiredUnique code to identify the MoneyGram Partner
posIdStringOptionalPoint of sale identifier of the client performing the API Call. Will default to 01 if not provided.
operatorIdString Max length: 80RequiredOperator name or ID of the user performing the transaction. Name or ID must be populated from the agent/partner system and cannot be edited by the user.
userLanguageString Max Length: 6OptionalLanguage used by the user/operator
destinationCountryCodeString Length: 3RequiredISO alpha-3 country code identifying the destination country NOTE: For a full list of destination countries see the Reference Data API Module: countries endpoint
destinationCountrySubdivisionCodeString Max length: 6Conditionally RequiredDestination state/province is conditionally required when transacting to the United States or Canada. NOTE: For a full list of accepted destination Countries and supported destinationCountrySubdivisionCode see Reference Data API Module: Retrieve Countries ISO3 Endpoint
serviceOptionCodeString Max length: 21OptionalUnique 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
serviceOptionRoutingCodeString Max length: 21OptionalUnique 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
sendAmountIncludingFeeBooleanOptionalFlag to indicate the transaction amount is to be inclusive of the transaction fee and taxes. Default value is false.
sendAmount.valueNumber Min length: 0 Max length: 14 Max decimal Value: 3Required (Quote by Send)Quote by Send Amount value OR Quote by Receive Amount value
sendAmount.currencyCodeString Length: 3Required (Quote by Send)Send/Receive Currency ISO alpha-3 code NOTE: For a full list of transaction currency codes see the API Reference Data Module: currencies endpoint
receiveAmount.valueNumber Min length: 0 Max length: 14 Max decimal Value: 3Required (Quote by Receive)Quote by Send Amount value OR Quote by Receive Amount value
receiveAmount.currencyCodeString Length: 3Required (Quote by Receive)Send/Receive Currency ISO alpha-3 code NOTE: For a full list of transaction currency codes see the API Reference Data Module: currencies endpoint
receiverSameAsSenderBooleanOptionalFlag to indicate the receiver and sender are the same person. NOTE - If this flag is marked true, receiver.name fields are considered 'Optional' and are not needed to be passed on API request.
promotionCodeString Max length: 16OptionalDiscount code associated with a specific business promotion. NOTE: To receive the list of promotion codes contact your MoneyGram Relationship Manager
rewardsNumberString Max length: 16OptionalUnique code to apply Loyalty accrual/redemption (MoneyGram Plus Number)
fundInStoreBooleanOptionalFlag to indicate transaction is to be funded in store within a 24hour period
fundinstoreAgentPartnerIdstringOptionalUnique store identifier where transaction will be funded
fundingSource.paymentTenderTypestringOptionalFunding method, based on enumerations.
additionalDetailsDynamicOptionalDynamic field key/values



Response Fields

FieldTypeRequired/OptionalDescription
transactions.transactionIdString Max length: 36RequiredUnique identifier for the transaction resource
transactions.serviceOptionCodeString Max length: 21RequiredUnique 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.serviceOptionNameString Max length: 50RequiredConsumer facing name to identify the transaction method
transactions.serviceOptionRoutingCodeString Max length: 21OptionalUnique code to identify the individual transaction method NOTE: For a full list of accepted service option routing codes per destination country see the Reference Data API Module: service-options endpoint
transactions.serviceOptionRoutingNameString Max length: 50OptionalUnique name to identify the individual transaction method
transaction.estimatedDeliveryStringRequiredEstimated delivery time of the transaction
transactions.sendAmount.amountNumber Min length: 0 Max length: 14 Max decimal Value: 3RequiredTransaction amount value and currency type 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.feesNumber Min length: 0 Max length: 14 Max Decimal Value: 3RequiredFee Amount and Fee Currency applied to transaction (Fee Currency uses ISO alpha-3 code)
transactions.sendAmount.taxesNumber Min length: 0 Max length: 14 Max Decimal Value: 3Conditionally RequiredTax Amount and Tax Currency applied to the Transaction by the the origin country (Tax Currency uses ISO alpha-3 code)
transactions.sendAmount.additionalCharges.typeCodeStringConditionally RequiredCode to indicate if the fee is to be collected by MoneyGram or the partner
transactions.sendAmount.additionalCharges.labelStringConditionally RequiredConsumer facing name to identify the charge type
transactions.sendAmount.additionalCharges.valueNumberConditionally RequiredAdditional fee's amount
transactions.sendAmount.additionalCharges.currencyCodeStringConditionally RequiredAdditional fee's Currency (ISO alpha-3 code)
transactions.sendAmount.discountsApplied.totalDiscountString Min length: 0 Max length: 14 Max Decimal Value: 3OptionalTransaction discount amount applied and currency type excluding fees and exchange rate. Transaction Currency (ISO alpha-3 code)
transactions.sendAmount.discountsApplied.promotionDetailsString Min length: 0 Max length: 14 Max Decimal Value: 3OptionalDiscount code associated with a specific business promotion
transactions.sendAmount.totalNumber Min length: 0 Max length: 14 Max Decimal Value: 3RequiredTransaction Total Amount and Transaction Total Currency including fees, taxes and discount. (Transaction Total Amount uses ISO alpha-3 code)
transactions.receiveAmount.amountNumber Min length: 0 Max length: 14 Max Decimal Value: 3RequiredTransaction Received Amount and Transaction Receive currency (Transaction Total Amount uses ISO alpha-3 code)
transactions.receiveAmount.feesNumber Min length: 0 Max length: 14 Max Decimal Value: 3OptionalReceived Fee and Receive Currency applied to the transaction by the destination country (Transaction Total Amount uses ISO alpha-3 code)
transactions.receiveAmount.taxesNumber Min length: 0 Max length: 14 Max Decimal Value: 3OptionalTax Amount and Tax Currency applied to the Transaction by the the
transactions.receiveAmount.additionalCharges.typeCodeStringOptionalCode to indicate if the fee is to be collected by MoneyGram or the partner
transactions.receiveAmount.additionalCharges.labelStringOptionalConsumer facing name to identify the charge type
transactions.receiveAmount.additionalCharges.valueNumberOptionalAdditional fee's amount
transactions.receiveAmount.additionalCharges.currencyCodeStringOptionalAdditional fee's Currency (ISO alpha-3 code)
transactions.receiveAmount.discountsApplied.totalDiscountString Min length: 0 Max length: 14 Max Decimal Value: 3OptionalTransaction discount amount applied and currency type excluding fees and exchange rate. Transaction Currency (ISO alpha-3 code)
transactions.receiveAmount.discountsApplied.promotionDetailsString Min length: 0 Max length: 14 Max Decimal Value: 3OptionalDiscount code associated with a specific business promotion
transactions.receiveAmount.totalNumber Min length: 0 Max length: 14 Max Decimal Value: 3RequiredReceive 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.fxRateNumber Max Decimal Value: 6RequiredFX Rate applied to transaction
transactions.receiveAmount.fxRateEstimatedBooleanOptionalIndicates whether the Fx is "estimated" and amount, taxes and total cannot be guaranteed. The word "estimated" must appear before receiveAmount.amount, receiveAmount.fees, receiveAmount.taxes and receiveAmount.total only when true.