PUT Update a Staged Transaction

PUT /transfer/v1/stagedtransactions/{transactionId}

Development Guide

The 'Update a Staged Transaction' endpoint determines the information to collect from the consumer, it also validates the data for compliance purposes and updates the transactionId resource with the data gathered. Use this endpoint after retrieving a staged transaction via the Search Staged Transactions endpoint.


1. Prepare headers & authentication:

The application must call the 'Update a Staged Transaction' endpoint with a PUT 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


🚀

Launch Code Example




2. Provide the transactionId resource as a path parameter

The application must pass the associated transactionId as a path parameter on the Update API. This will allow the application to update the transactionId resource with consumer and transactional information. The transactionId will have been previously generated from search staged transaction.


🚀

Launch Code Example



3. Provide request body.

The application must use the oneOfto select the appropriate request schema: TransfersStagedTranRequest or TransfersStagedTranWithAddlnDataRequestoneOf:



  • TransfersStagedTranRequestThe application can provide the following optional fields in the request body: targetAudience, agentPartnerId, posId , operatorId, userLanguage, receipt.primaryLanguage, and receipt.secondarylanguage receipt.image.

    OR


  • TransfersStagedTranWithAddlnDataRequest The application can provide the following optional fields in the request body: targetAudience, agentPartnerId, posId , operatorId, userLanguage, transactionInformation.purposeOfTransactionCode, transactionInformation.sourceOfFundsCode, transactionInformation.proofofFundsCode, transactionInformation.intendedUseOfMGIServicesCode, transactionInformation.relationshipToReceiver, transactionInformation.senderAnnaulIncome, receipt.primaryLanguage, receipt.secondarylanguage, additionalDetails.key, additionalDetails.value, documentImage.imageReferenceId, documentImage.imageVerification, and documentImage.imageTypeCode.

🚀

Launch Code Example

.


4. Make a request and handle response:

The application must call the 'Update a transaction' endpoint with a PUT HTTP method. The application must build to handle the following response scenarios:


  • Success | Parse the Response | 200 OK HTTP Status | "readyToCommit": true

    When the 'Update a staged transaction' endpoint responds with a 200 HTTP Status and the "readytoCommit": true, transactionId, serviceOption, sender, receiver, sendAmount, sendCurrency, fees, fxRate, discountsApplied , receiveAmount and the total. In some cases, send or receive side taxes and/or additional charges are applied. The application can proceed to "Commit a staged transaction" API and execute the transfer of funds.

  • Failed | Handle the Error | 400 Bad Request HTTP Status

    When the 'Update a staged transaction' endpoint responds with 400 Bad Request HTTP Status the application cannot proceed to the "Commit a staged transaction" endpoint. Specific error code/s will be returned with an array of offending fields. The application will need to resolve these errors and resubmit the transaction for validation. The application can make repeated attempts on the 'Update a transaction' endpoint until validation is successful.

Note: In some scenarios, enhanced due diligence needs to be undertaken on the consumer. Specific error code/s will be returned and an array of offending fields. The fields/values must to be provided and resubmitted on the Update API for further checks.



🚀

Launch Code Example

.



7. You're Done! Proceed to 'Commit a Staged Transaction API':

The application can call the 'Commit a staged transaction' endpoint to execute the transfer when a 200 HTTP Success Status and the boolean "readyForCommit": true is returned on the Update response. The application must use the associated transactionId on the subsequent Commit a Staged Transaction API by providing it as a path parameter. The Commit endpoint is the final API call and will execute the transaction to MoneyGram.


Note: the application cannot proceed until the "readyForCommit": true. The Application must correct and resubmit the data to until they get a "readyForCommit": true





Code Examples


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

const updateStagedTransaction = async () => {
  const token = "your_access_token_from_oauth_response";
  const transactionId = "transactionId"; 
  // Production: extapi.moneygram.com | Test: sandboxapi.moneygram.com
  const host = "sandboxapi.moneygram.com";
  const url = `https://${host}/transfer/v1/stagedtransactions/${transactionId}`;

  const headers = {
    'Content-Type': 'application/json',
    'X-MG-ClientRequestId': uuidv4(),
    'Authorization': `Bearer ${token}`,
  };

  const request = {
    agentPartnerId: "your_partner_id",
    targetAudience: "AGENT_FACING",
    userLanguage: "en-US",
    receipt: {
      primaryLanguage: "en-US",
      secondaryLanguage: "es-MX",
      image: "base64_receipt_image_string"
    },
    transactionInformation: {
      purposeOfTransactionCode: "FAMILY_SUPPORT",
      sourceOfFundsCode: "SALARY",
      relationshipToReceiver: "FAMILY"
    },
    additionalDetails: [
      { key: "customKey", value: "customValue" }
    ]
  };

  try {
    const response = await axios.put(url, request, { headers });
    // Check readyForCommit before proceeding to Commit API
    console.log(JSON.stringify(response.data, null, 2));
  } catch (error) {
    if (error.response) {
      console.log('Status:', error.response.status);
      console.log('Body:', error.response.data);
    } else {
      console.error('Error:', error.message);
    }
  }
};

updateStagedTransaction();
import requests, uuid

def update_staged_transaction():
    token = "your_access_token_from_oauth_response"
    transaction_id = "staged_tx_id"
    host = "sandboxapi.moneygram.com"
    url = f"https://{host}/transfer/v1/stagedtransactions/{transactionId}"

    headers = {
        "Content-Type": "application/json",
        "X-MG-ClientRequestId": str(uuid.uuid4()),
        "Authorization": f"Bearer {token}",
    }

    payload = {
        "agentPartnerId": "your_partner_id",
        "targetAudience": "AGENT_FACING",
        "userLanguage": "en-US",
        "receipt": {
            "primaryLanguage": "en-US",
            "secondaryLanguage": "es-MX",
            "image": "base64_receipt_image_string"
        },
        "transactionInformation": {
            "purposeOfTransactionCode": "FAMILY_SUPPORT",
            "sourceOfFundsCode": "SALARY",
            "relationshipToReceiver": "FAMILY"
        },
        "additionalDetails": [
            {"key": "customKey", "value": "customValue"}
        ]
    }

    resp = requests.put(url, json=payload, headers=headers)
    if resp.ok:
        print(resp.json())
    else:
        print(f"Error {resp.status_code}:", resp.json())

update_staged_transaction()
import java.net.http.*;
import java.net.URI;
import java.util.UUID;

public class UpdateStagedTransaction {
  public static void main(String[] args) throws Exception {
    String token = "your_access_token_from_oauth_response";
    String transactionId = "transactionId";
    String host = "sandboxapi.moneygram.com";
    String url = "https://" + host + "/transfer/v1/stagedtransactions/" + transactionId;

    String body = """
      {
        "agentPartnerId": "your_partner_id",
        "targetAudience": "AGENT_FACING",
        "userLanguage": "en-US",
        "receipt": {
          "primaryLanguage": "en-US",
          "secondaryLanguage": "es-MX",
          "image": "base64_receipt_image_string"
        },
        "transactionInformation": {
          "purposeOfTransactionCode": "FAMILY_SUPPORT",
          "sourceOfFundsCode": "SALARY",
          "relationshipToReceiver": "FAMILY"
        }
      }""";

    HttpClient client = HttpClient.newHttpClient();
    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create(url))
      .header("Content-Type", "application/json")
      .header("Authorization", "Bearer " + token)
      .header("X-MG-ClientRequestId", UUID.randomUUID().toString())
      .PUT(HttpRequest.BodyPublishers.ofString(body))
      .build();

    HttpResponse<String> response =
      client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.statusCode());
    System.out.println(response.body());
  }
}




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 EnumerationsGET/reference-data/v1/enumerationsRetrieves enumerated values for fieldsRetrieves enumerated values for fields




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



Path Parameters

Path ParameterTypeRequired /OptionalDescription
transactionIdString Max length: 36RequiredUnique id of the transaction resource
Pattern.compile("^[0-9a-fA-F]8-[0-9a-fA-F]4-[0-9a-fA-F]4-[0-9a-fA-F]4-[0-9a-fA-F]12$")



Request Body Parameters

Body ParameterDescription
TransferByStagedTranRequestBusiness details + receipt object. Basic update with receipt language and image.
TransferByStagedTranWithAddlnDataRequestExtends the base request with transactionInformation, additionalDetails, and documentImage.



Request Body Fields with TransfersStagedTranRequest

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: 8RequiredUnique identifier for the agent or partner
posIdStringOptionalPoint of sale identifier of the client performing the API Call
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
receipt.primaryLanguageStringOptionalPrimary receipt language of the transacting partner
receipt.secondaryLanguageStringOptionalSecondary receipt language of the transacting partner
receipt.imageStringOptionalReceipt image string of the transacting partner


Request Body Fields with TransfersStagedTranWithAddlnRequest

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: 8RequiredUnique identifier for the agent or partner
posIdStringOptionalPoint of sale identifier of the client performing the API Call
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
receipt.primaryLanguageStringOptionalPrimary receipt language of the transacting partner
receipt.secondaryLanguageStringOptionalSecondary receipt language of the transacting partner
receipt.imageStringOptionalReceipt image string of the transacting partner
transactionInformation.purposeofTransactionCodeStringOptionalExplanation or reason for transferring funds (Enumerated Values) Reference Data Enumerations endpoint _
transactionInformation.sourceOfFundsCodeStringOptionalDeclaration of where the transaction funds were sourced (Enumerated Values) Reference Data Enumerations endpoint _
transactionInformation.proofOfFundsCodeStringOptionalProof of where the transaction funds were sourced (Enumerated Values) NOTE: For a full list of accepted proof of funds values. See the PROOF_OF_FUNDS enumeration from the Reference Data Enumerations endpoint
transactionInformation.intendedUseOfMGIServicesCodeString Max length: 30OptionalExplanation for using MoneyGram service (Enumerated Values) NOTE: For a full list of accepted use of MGI services values. See the TYPICAL_USE_OF_MGI enumeration from the Reference Data Enumerations endpoint
transactionInformation.relationshipToReceiverString Max length: 30OptionalDeclaration of consumer's relationship to the counter party (Enumerated Values) NOTE: For a full list of relationships values. See the RLTIONSHP_TO_RECIVR enumeration from the Reference Data Enumerations endpoint
transactionInformation.senderAnnualIncomeString Enumerated ValueOptionalSender's annual income bracket
additionalDetailsDynamicOptionalDynamic field key/values
documentImage.imageReferenceIdStringOptionalDocument Reference ID from Upload
documentImage.imageVerificationStringOptionalVerification of ID on file with entering ID Number
documentImage.imageTypeCodeStringOptionalType of identification document (Enumerated Value)



Response Fields


FieldTypeRequired /OptionalDescription
readyForCommitBooleanRequiredIndicates whether the transaction can proceed to commit
transactionIdString Max Length: 36RequiredMoneyGram Rewards number
serviceOptionNameStringRequiredConsumer facing name to identify the transaction method
serviceOptionRoutingNameStringOptionalUnique name of the individual banking, wallet, or card provider
destinationCountryCodeString Max Length: 3RequiredTransaction Destination Country (ISO alpha-3 code) NOTE: For a full list of accepted destination Countries and supported destinationCountrySubdivisionCode see Reference Data API Module: Retrieve Countries ISO3 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
sender.name.firstNameString Min length: 1 Max length: 20RequiredFirst Name
sender.name.middleNameString Min length: 1 Max length: 20OptionalMiddle Name (if applicable)
sender.name.lastNameString Min length: 1 Max length: 30RequiredLast Name
sender.name.secondLastNameString Min length: 1 Max length: 30OptionalSecond Last Name
sender.address.line1String Min length: 5 Max length: 30RequiredResidence address line 1
sender.address.line2String Min length: 0 Max length: 80OptionalResidence address line 2 (if applicable)
sender.address.line3String Min length: 0 Max length: 80OptionalResidence address line 3 (if applicable)
sender.address.cityString Min length: 1 Max length: 40RequiredCity of residence
sender.address.countrySubdivisionCodeString Length: 6OptionalState/province of residence
sender.address.countryCodeString Length: 3RequiredCountry of residence (ISO Alpha-3 Code)
sender.address.postalCodeString Min length: 2 Max length: 6OptionalPostal code/ZIP of residence
sender.mobilePhone.numberString Min length: 5 Max length: 14RequiredPhone number
sender.mobilePhone.countryDialCodeString Min length: 1 Max length: 3RequiredCountry calling code NOTE: For country calling code see Reference Data API Module /countries endpoint phoneDialCodes
sender.emailString Min length: 1 Max length: 255OptionalEmail address
sender.personalDetails.genderCodeStringOptionalGender (Enumerated Value)
sender.personalDetails.dateOfBirthString Length: 10RequiredDate of birth (YYYY-MM-DD)
sender.personalDetails.birthCityString Min length: 0 Max length: 40OptionalCity of birth
sender.personalDetails.birthCountryCodeString Max Length: 3Conditionally
Required
Country of birth (ISO alpha-3 code) NOTE: For a full list of accepted birth.CountryCodes see ‘Reference Data API Module’ and the Retrieve Countries ISO3 endpoint: ]
sender.personalDetails.citizenshipCountryCodeString Max Length: 3OptionalCountry of birth. (ISO alpha-3 code)
sender.personalDetails.occupationCodeStringOptionalOccupation/Employment (Enumerated Value) NOTE: For a full list of accepted occupation codes see Reference Data Enumerations endpoint
sender.personalDetails.politicalExposedPersonBooleanOptionalFlag to declare a Politically Exposed Person (PEP)
sender.personalDetails.nationalityCountryCodeString Min Length: 3 Max Length: 3OptionalCountry of citizenship (ISO alpha-3 code)
sender.primaryIdentification.typeCodeString Max length: 3RequiredType of identification document (Enumerated Value) NOTE: For a full list of accepted Identification documents by country. see Reference Data Enumerations endpoint
sender.primaryIdentification.idString Max length: 30RequiredIdentification document number
sender.primaryIdentification.issueCountrySubdivisionCodeString Max length: 6OptionalIssuing state/province of identification document.
sender.primaryIdentification.issueCountryCodeString Max Length: 3RequiredIssuing country of identification document (ISO alpha-3 code)
sender.primaryIdentification.expirationYearString Length: 4 Format: YYYYOptionalExpiration year of identification document (YYYY)
sender.primaryIdentification.expirationMonthString Length: 2 Format: MMOptionalExpiration month of identification document (MM)
sender.primaryIdentification.expirationDayString Length: 2 Format: DDOptionalExpiration month of identification document (DD)
sender.primaryIdentification.issueAuthorityString Min length: 0 Max length: 30OptionalIssuing authority of identification document
sender.primaryIdentification.issueCityString Min length: 0 Max length: 40OptionalIssuing city of identification document
sender.primaryIdentification.issueYearString Length: 4 Format: YYYYOptionalIssuing year of identification document (YYYY)
sender.primaryIdentification.issueMonthString Length: 2 Format: MMOptionalIssuing month of identification document (MM)
sender.primaryIdentification.issueDayString Length: 2 Format: DDOptionalIssuing day of identification document (DD)
sender.secondaryIdentification.typeCodeString Max length: 3OptionalType of identification document (Enumerated Value)
sender.secondaryIdentification.idString Max length: 30OptionalIdentification document number
sender.secondaryIdentification.issueCountrySubdivisionCodeString Max length: 6OptionalIssuing state/province of identification document.
sender.secondaryIdentification.issueCountryCodeString Max length: 3RequiredIssuing country of identification document. (ISO alpha-3 code)
sender.secondaryIdentification.expirationYearString Length: 4 Format: YYYYOptionalExpiration year of identification document (YYYY)
sender.secondaryIdentification.expirationMonthString Length: 2 Format: MMOptionalExpiration month of identification document (MM)
sender.secondaryIdentification.expirationDayString Length: 2 Format: DDOptionalExpiration month of identification document (DD)
sender.secondaryIdentification.issueAuthorityString Min length: 0 Max length: 30OptionalIssuing authority of identification document
sender.secondaryIdentification.issueCityString Min length: 0 Max length: 40OptionalIssuing city of identification document
sender.secondaryIdentification.issueYearString Length: 4 Format: YYYYOptionalIssuing year of identification document (YYYY)
sender.secondaryIdentification.issueMonthString Length: 4 Format: MMOptionalIssuing month of identification document (MM)
sender.secondaryIdentification.issueDayString Length: 4 Format: DDOptionalIssuing day of identification document (DD)
receiver.name.firstNameString Min length: 1 Max length: 20RequiredFirst Name
receiver.name.middleNameString Min length: 0 Max length: 20OptionalMiddle Name (if applicable)
receiver.name.lastNameString Min length: 1 Max length: 30RequiredLast Name
receiver.name.secondLastNameString Min length: 1 Max length: 30OptionalSecond Last Name
sendAmount.amount.valueNumber Max length: 14RequiredTransaction amount and currency excluding fees and exchange rate. Transaction Currency (ISO alpha-3 code) For Crypto partners this is the fiat currency for the BUY/Sell or Ramp-on/Ramp-off
sendAmount.amount.currencyCodeStringRequiredThe sendAmount.amount.value currency code (ISO alpha-3 code)
sendAmount.fees.valueNumber Min length: 0 Max length: 14RequiredFee Amount and Fee Currency applied to transaction (Fee currencyCode uses ISO alpha-3 code)
sendAmount.fees.currencycodeStringRequiredValue's Currency code (ISO alpha-3 code)
sendAmount.taxes.valueNumber Min length: 0 Max length: 14Conditionally RequiredTax Amount and Tax Currency applied to the Transaction by the the origin country
sendAmount.taxes.currencyCodeStingConditionally RequiredValue's Currency code (ISO alpha-3 code)
sendAmount.additionalCharges.typeCodeStringConditionally RequiredType Code to indicate if the fee or tax is to be collected by MoneyGram or the partner
sendAmount.additionalCharges.labelStringConditionally RequiredConsumer facing label name to identify the charge type
sendAmount.additionalCharges.valueNumberConditionally RequiredAdditional fee or tax amount
sendAmount.additionalCharges.currencyCodeStringConditionally RequiredThe sendAmount.additionalCharges.value currency (ISO alpha-3 code)
sendAmount.discountApplied.totalDiscountStringOptionalTransaction discount amount applied and currency type excluding fees and exchange rate. Transaction discount currencyCode (ISO alpha-3 code)
sendAmount.discountApplied.promotionalDetailsStringOptionalAdditional Details about the applied promotion to the transaction. currencyCode (ISO alpha-3 code)
sendAmount.total.valueNumber Max length 14RequiredTransaction Total Amount including fees, taxes and discount.
sendAmount.total.currencyCodeStringRequiredthe sendAmount.total.value code (ISO alpha-3 code)
receiveAmount.amount.valueNumber Max length: 14RequiredTransaction receive amount
receiveAmount.amount.currencyCodeStringRequiredthe receiveAmount.amount.value currency code (ISO alpha-3 code)
receiveAmount.fees.valueNumber Max length: 14OptionalReceive fee by the destination country.
receiveAmount.fees.currencyCodeStringOptionalThe receiveAmount.fees.valuecurrency code (ISO alpha-3 code)
receiveAmount.taxes.valueNumber Max length: 14OptionalTax Amount applied to the Transaction by the the origin country
receiveAmount.taxes.currencyCodeStringOptionalThe receiveAmount.taxes.value currency code (ISO alpha-3 code)
receiveAmount.additionalCharges.typeCodeStringOptionalType code to indicate if the fee or tax is to be collected by MoneyGram or the partner
receiveAmount.additionalCharges.labelStringOptionalConsumer facing label name to identify the charge type
receiveAmount.additionalCharges.valueNumber Max length: 14OptionalAdditional fee or tax amount
receiveAmount.additionalCharges.currencyCodeStringOptionalThe receiveAmount.additionalCharges.value currency code (ISO alpha-3 code)
receiveAmount.total.valueNumber Max length: 14RequiredReceive Amount Total and Receive Transaction Currency to be picked-up/deposited in destination country including fees, taxes and discount
receiveAmount.total.currencyCodeStringRequiredThe receiveAmount.total.value currencyCode ( ISO alpha-3 code)
receiveAmount.fxRateNumber Max length: 6RequiredFx Rate applied to transaction
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.
additionalDetailsDynamicOptionalDynamic field key/values
targetAccountProfileIdStringOptionalUnique identifier for Target Account Resource
preCommitReceipt.consumerHyperLinkStringOptionalReceipt image string of the transacting partner
fundingSource.tenderTypeStringOptionalFunding method, based on enumerations
fundingSource.providerStringOptionalName of the payment provider
fundingSource.providerNetworkCodeStringOptionalProviders unique network identifier code
fundingSource.providerAccountNumberStringOptionalAccount number of payment source
fundingSource.accountIdentifierStringOptionalMoneyGrams unique identifier for the consumer account


Did this page help you?