POST Quote a Transaction

POST: /disbursement/v1/transactions/quote

Overview

The Quote API creates a transactionId resource and determines the service options, currencies and pricing available to a destination country.

Make a Request

  1. Prepare headers & authentication:

    The application must 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 access_token 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


  2. Provide Body Payload - "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:

    • To quote by send amount: The application must provide the destinationCountryCode and thesendAmount.value in the request.

      OR

    • To quote by receive amount: The application must provide the destinationCountryCode and receiveAmount 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.


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

    The Quote API also allows the application to apply promotional discounts.

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

  2. 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 also provide an array of quoted transactions, each with a unique transactionId resource. The customer must choose one quote to continue with and the application must persist the associated transactionId to use when calling the subsequent Update API.

    • For each transactionId resource generated, the endpoint will typically respond with the serviceOption, sendAmount, sendCurrency, fees, taxes, fxRate, discountsApplied and the receiveAmount. In some cases send or receive side taxes are applied.

    NOTE: The list of transactions returned on the Quote API is priced uniquely by the service options and receive currency. The fee and fx are only estimated at the point of quote.


  3. Once the customer has selected their quoted transaction, the application must persist the associated transactionId and provide 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",
        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',
        '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("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
        }
    }
}




API Request & Response Examples

curl --request POST \
     --url https://sandboxapi.moneygram.com/disbursement/v1/transactions/quote \
     --header 'X-MG-ClientRequestId: 4c79b06f-a2af-4859-82c8-28cbb0bf361b' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer ***************************' \
     --header 'content-type: application/json' \
     --data '
{
  "targetAudience": "AGENT_FACING",
  "agentPartnerId": 30151518,
  "destinationCountryCode": "USA",
  "destinationCountrySubdivisionCode": "US-MN",
  "serviceOptionCode": "WILL_CALL",
  "sendAmount": {
    "value": 100,
    "currencyCode": "USD"
  },
  "receiveCurrencyCode": "USD"
}
'
{
  "transactions": [
    {
      "transactionId": "**********-**-****-****-************",
      "serviceOptionCode": "string",
      "serviceOptionName": "**********-**-****-****-************",
      "sendAmount": {
        "amount": {
          "value": 100,
          "currencyCode": "USD"
        },
        "fees": {
          "value": 3,
          "currencyCode": "USD"
        },
        "taxes": {
          "value": 0,
          "currencyCode": "USD"
        },
        "total": {
          "value": 103,
          "currencyCode": "USD"
        }
      },
      "receiveAmount": {
        "amount": {
          "value": 100,
          "currencyCode": "USD"
        },
        "fees": {
          "value": 0,
          "currencyCode": "USD"
        },
        "taxes": {
          "value": 0,
          "currencyCode": "USD"
        },
        "total": {
          "value": 100,
          "currencyCode": "USD"
        },
        "fxRate": 1,
        "fxRateEstimated": false
      }
    }
  ]
}



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

NameRequired
/Optional
TypeDescription
X-MG-ClientRequestIdRequiredStringClient 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-ConsumerIPAddressOptionalStringIP Address of the system initiating the session



Request Body Parameters

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



Request Body Fields

FieldTypeRequired
/Optional
Description
targetAudienceStringRequiredTailors 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
agentPartnerIdString
Max length: 8
RequiredUnique identifier for the agent or partner
userLanguageString
Max length: 6
OptionalLanguage used by the user/operator
destinationCountryCodeString
Min length: 3
Max length: 3
RequiredTransaction 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
destinationCountrySubdivisionCodeString
Max length: 6
OptionalDestination 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
serviceOptionCodeString
Max length: 21
OptionalUnique 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 Transaction Amount is to be inclusive of the Transaction Fee

NOTE: Only available for a quote by send amount
sendAmount.valueStringRequiredTransaction send amount excluding fees and exchange rate for a quoteByTransactionSendAmount Request

NOTE: For Crypto partners this is the fiat currency for the Buy/Sell or Ramp-on/Ramp-off
sendAmount.currencyCodeString
Max length: 3
RequiredTransaction send currency code for a quoteByTransactionSendAmount Request (ISO alpha-3 code)
receiveCurrencyCodeString
Max length: 3
RequiredReceive currency is needed when transacting to a destination country that supports more than one currency for a quoteByTransactionSendAmount Request (ISO alpha-3 code)
promotionCodesString
Max length: 20
OptionalUnique code to apply a promotional discount
additionalDetailsDynamicOptionalDynamic field key/values



Response Fields

FieldTypeRequired
/Optional
Description
transactions.transactionIdString
Max length: 36
RequiredUnique identifier for the transaction resource
transactions.serviceOptionCodeString
Max length: 21
RequiredUnique 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: 40
RequiredConsumer 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.serviceOptionRoutingCodeStringOptionalUnique code to identify the individual transaction method

NOTE: For a full list of accepted service option routine codes per destination country see the Reference Data API Module: service-options endpoint
transactions.sendAmount.amountString
Min length: 0

Max length: 14

Max decimal Value: 3
RequiredTransaction 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.feesString
Min length: 0
Max length: 14
Max Decimal Value: 3
RequiredFee Amount and Fee Currency applied to transaction (Fee Currency uses ISO alpha-3 code)
transactions.sendAmount.taxesString
Min length: 0
Max length: 14
Max Decimal Value: 3
OptionalTax Amount and Tax Currency applied to the Transaction by the the origin country (Tax Currency uses ISO alpha-3 code)
transactions.sendAmount.discountsApplied.totalDiscountString
Min length: 0
Max length: 14
Max Decimal Value: 3
OptionalTransaction 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: 3
OptionalDiscount code associated with a specific business promotion
transactions.sendAmount.totalString
Min length: 0
Max length: 14
Max Decimal Value: 3
RequiredTransaction Total Amount and Transaction Total Currency including fees, taxes and discount. (Transaction Total Amount uses ISO alpha-3 code)
transactions.receiveAmount.amountString
Min length: 0
Max length: 14
Max Decimal Value: 3
requiredTransaction Received Amount and Transaction Receive currency (Transaction Total Amount uses ISO alpha-3 code)
transactions.receiveAmount.feesString
Min length: 0
Max length: 14
Max Decimal Value: 3
OptionalReceived Fee and Receive Currency applied to the transaction by the destination country (Transaction Total Amount uses ISO alpha-3 code)
transactions.receiveAmount.taxesString
Min length: 0
Max length: 14
Max Decimal Value: 3
OptionalTax Amount and Tax Currency applied to the Transaction by the the
transactions.receiveAmount.totalString
Min length: 0
Max length: 14
Max Decimal Value: 3
RequiredReceive 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: 4
RequiredFx Rate applied to transaction
transactions.sendAmount.fxRateEstimatedbooleanOptionalIndicates 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