POST Create a Transaction with Auto Commit
POST /disbursement/v1/transactions
Development Guide
The_ Create a Transaction with Auto Commit_ endpoint accepts all data required for transaction from a business partner's system. It validates the data for compliance purposes and automatically executes (auto-commits) the transaction without calling the quote and update APIs. It responds with a transactionId resource, the referenceNumber and the quote information.
1. Prepare headers & authentication:
The application must call the Create a transaction with Auto-Commit' 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_tokenby 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: "Transact by send amount" OR "Transact by receive amount":
The application must use the oneOf Keyword to Create a transaction with auto-commit by send or receive amount. At this point the application also has the option to re-quote the transactionId by entering a different sendAmount.value, serviceOptionCode or destinationCountry.
- **Transact by send amount: **The application must provide the following required fields in the request body:
targetAudience,agentPartnerId,destinationCountryCode,serviceOptionCode,sendAmount.value,sendAmount.currencyCode, andreceiveCurrencyCode.
OR
- **Transact by receive amount: ** The application must provide the following required fields in the request body:
targetAudience,agentPartnerId,destinationCountryCode,serviceOptionCode,receiveAmount.value,receiveAmount.currencyCode, andsendCurrencyCode
Note:
- The Create a transaction with auto-commit API uses ISO Standards for country and currency values. MoneyGram provides Reference Data APIs which can be queried to understand the supported values and associated metadata.
- Additional data collection may be required based on the
sendAmountanddestinationCountryCode.
Launch Code Example
.
3. Provide "autoCommit": true in the request body:
"autoCommit": true in the request body:For batch transaction the application must provide the "autoCommit": true . This indicates the application wishes to execute the transaction to MoneyGram with out viewing the quote. This model is to be used when processing batch transactions.
Launch Code Example
4. Provide the sender information in the request body:
sender information in the request body:The the application must use the oneOf Keyword to provide the sender information. The application can use three oneOf options to provide sender information:
- Option 1 -
businessProfileId: For partner's using a MoneyGram business profile, the applications can provide the MoneyGrambusinessProfileId. To use this option, the application must first call the Create Business Profile API to create a business profile at MoneyGram and generate abusinessProfileId. ThebusinessProfileIdis a unique identifier of the business and will last the life time of the account.
OR
- Option 2 -
partnerBusinessProfileId: For partner's using their own business profile, the application can pass their unique profile identifier in thepartnerBusinessProfileId. The application must first call the Create Business Profile API to create a business profile at MoneyGram and pass their uniquepartnerBusinessProfileId. MoneyGram will associate the partner's identifier with our business profile creation.
OR
- Option 3 -
business: For partner's using an account-free model, the application can pass all the business sender fields in the business object.
Launch Code Example
.
.
5. Provide the required Beneficiary fields in the request body:
The the application must use the oneOf Keyword to provide the beneficiary information . The application can use two oneOf options to provide beneficiary information, depending on whether the application is performing a B2B or B2C transaction:
- Option 1 -
business: For partner's performing a Business-to-Business (B2B) transactions, the application can providebusinessdetails as the beneficiary.
OR
- Option 2 -
consumer: For partner's performing a Business-to-Consumer (B2C) transactions, the application can provideconsumerdetails as the beneficiary..
Launch Code Example
.
5. Provide the transactionInformation in the request body (optional):
transactionInformation in the request body (optional):Any required transaction information can be provided in the transactionInformation object.
Launch Code Example
6. Provide the targetAccount fields in the request body (optional)
targetAccount fields in the request body (optional)If the funds are to be deposited into the beneficiary's bank account, wallet, or card, the details must be provided through the targetAccount dynamic key/value pairs.
NOTE: To understand the which account deposit fields are required to collect from the consumer, see the Bank & Wallet Coverage guide, or the application can use the Retrieve Fields for a Transfer API to determine the list of account fields.
Launch Code Example
7. Make a request and handle response:
The application must call the 'Create a transaction with auto-commit' endpoint with a POST HTTP method. The application must build to handle the following response scenarios:
- Success | Parse the Response | 200 OK HTTP Status
When the 'Create Transaction with auto-commit' endpoint responds with a 200 HTTP Status the response will typically include thetransactionId,serviceOption,sendAmount,sendCurrency,fees,fxRate,discountsAppliedand thereceiveAmount. In some cases, send or receive side taxes are applied.
- Failed | Handle the Error | 400 Bad Request HTTP Status
When the 'Create a transaction with auto-commit' endpoint responds with 400 Bad Request HTTP Status the application cannot proceed. 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. The application can make repeated attempts on the 'Create a transaction with auto-commit' 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 Create a transaction with auto-commit API for further checks.
Launch Code Example
.
Code Examples
const axios = require('axios');
const { v4: uuidv4 } = require('uuid');
const updateTransaction = 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 transactionId = "current_transaction_id";
const url = 'https://' + host + '/disbursement/v1/transactions';
// Step 2: Create the PUT 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",
autoCommit: true,
sendAmount: {
value: 500,
currencyCode: "USD"
},
receiveCurrencyCode: "USD",
sender: {
business: {
businessName: "ACME",
legalEntityName: "ACME",
businessRegistrationNumber: "ACME2024",
businessCountryOfRegistration: "USA",
address: {
line1: "100 Main St",
city: "Springfield",
countryCode: "USA"
}
}
},
beneficiary: {
consumer: {
name: {
firstName: "Sally",
lastName: "Smith"
},
address: {
line1: "200 Main St",
city: "Springfield",
countryCode: "USA"
}
}
}
}
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);
}
};
updateTransaction();import requests
import uuid
import json
def update_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";
transactionId = "current_transaction_id";
url = 'https://' + host + '/disbursement/v1/transactions';
# Step 2: Create the PUT 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',
'autoCommit': true,
'sendAmount': {
'currencyCode': 'USD',
'value': 500
},
'receiveCurrencyCode': 'USD',
'sender': {
'business': {
'businessName': "ACME",
'legalEntityName': "ACME",
'businessRegistrationNumber': "ACME2024",
'businessCountryOfRegistration': "USA",
'address': {
'line1': "100 Main St",
'city': "Springfield",
'countryCode': "USA"
}
}
},
'beneficiary': {
'consumer': {
'name': {
'firstName': "Sally",
'lastName': "Smith"
},
'address': {
'line1': "200 Main St",
'city': "Springfield",
'countryCode': "USA"
}
}
}
}
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)
update_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 UpdateTransaction {
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 transactionId = "current_transaction_id";
String tokenEndpoint = "https://" + host + "/disbursement/v1/transactions"
// Step 2: Create the PUT request headers & body
// Create a JSON object
JsonObjectBuilder sendAmountBuilder = Json.createObjectBuilder()
.add("value", 500)
.add("currencyCode", "USD");
JsonObjectBuilder senderBuilder = Json.createObjectBuilder()
.add("sender", "business")
.add("businessName", "ACME")
.add("legalEntityName", "ACME")
.add("businessRegistrationNumber", "ACME2024")
.add("businessCountryOfRegistration", "USA");
JsonObjectBuilder beneficiaryBuilder = Json.createObjectBuilder()
.add("beneficiary", "consumer")
.add("name", Json.createObjectBuilder().add("firstName", "firstName").add("lastName", "lastName"))
.add("address",Json.createObjectBuilder().add("line1", "line1").add("city", "city").add("countryCode", "countryCode"));
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("autoCommit", true)
.add("sendAmount", sendAmountBuilder)
.add("receiveCurrencyCode", "USD")
.add("sender", senderInitiator)
.add("beneficiary", beneficiaryBuilder);
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.
| Name | HTTP Method | Endpoints | Description |
|---|---|---|---|
| Retrieve Account Deposit Fields | GET | /reference-data/v1/account-deposit | Retrieves required fields for account deposit delivery option |
| Retrieve Countries | GET | /reference-data/v1/Country | Retrieves supported values and metadata for countries |
| Retrieve Countries ISO3 | GET | /reference-data/v1 /countries/{iso3Code} | Retrieves supported values and metadata for countries by ISO 3 Code |
| Retrieve Currencies | GET | /reference-data/v1/currencies | Retrieves supported values and metadata for currencies |
| Retrieve Enumerations | GET | /reference-data/v1/enumerations | Retrieves enumerated values for fields |
| Retrieve Identification Documents | GET | /reference-data/v1/identification-Documents | Retrieves required fields for identification documents |
| Retrieve Service Options | GET | /reference-data/v1/payout-options | Retrieves supported values and metadata for Service Options |
API Structure
Header Parameters
| Name | Type | Required /Optional | Description |
|---|---|---|---|
X-MG-ClientRequestId | String | Required | 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 | String | Optional | IP address of the system initiating the session |
Request Body Parameters
| Body Parameter | Description |
|---|---|
| transactBySendAmountRequestAutoCommit | Transact by send amount |
| transactByReceiveAmountRequestAutoCommit | Transact by receive amount |
Request Body Fields
Partner Information, Service Option, Destination, Amounts
Field | Type | Required | Description |
|---|---|---|---|
| String | Required | Tailors MoneyGram’s error messages and field metadata to an in-store, digital, or crypto customer. (Enumerated value) |
| String | Required | Unique identifier for the agent or partner |
| String | Optional | Language used by the user/operator |
| String | Optional | Partner’s unique identifier for the transaction resource |
| String | Required | Transaction destination country (ISO alpha-3 code) |
| String | Optional | Destination state/province, conditionally required when transacting to certain destination countries (ISO alpha-3 code) |
| String | Required | Unique category code to identify the transaction method |
| String | Optional | Unique identifier of the individual banking, wallet, or card provider for the service option |
| Boolean | Required | Flag to indicate the transaction will be committed automatically after creation |
| Number | Required | Transaction amount and currency excluding fees and exchange rate |
| String | Required | The |
| String | Required | Receive currency required when transacting to a destination that supports multiple currencies for a transactBySendAmountRequest |
| Number | Required | Transaction receive amount excluding fees and exchange rate for a transactByReceiveAmountRequest |
| String | Required | The |
| String | Optional | Receive currency used when transacting to a destination country that supports more than one currency for a transactByReceiveAmountRequest (ISO alpha-3 code) |
| String | Optional | Unique code to apply a promotional discount |
Sender oneOf Options:
The sender target="_blank""> "oneOf" options allow the application to collect the business sender information for a transaction using one of three options businessProfileId, partnerBusinessProfileId, or business
Option 1: sender.businessProfileId
sender.businessProfileIdField | Type | Required | Description |
|---|---|---|---|
| String | Optional | A unique MoneyGram identifier for the business |
Option 2: sender.partnerBusinessProfileId
sender.partnerBusinessProfileId| Field | Type | Required /Optional | Description |
|---|---|---|---|
sender.partnerBusinessProfileId | String | Optional | The partner’s business profile ID that will be passed from the partner and mapped to the MoneyGram business profile ID |
Option 3: sender.business
sender.businessField | Type | Required | Description |
|---|---|---|---|
| String | Optional | Partner’s business profile ID that will be passed from the partner and mapped to the MoneyGram profile ID |
| String | Required | Name of the business |
| String | Required | The legal name of the business |
| String | Optional | Type of business |
| String | Required | Business registration number |
| String | Optional | Date of business formation |
| String | Required | Business’s country of registration |
| String | Required | Residence address line 1 |
| String | Optional | Residence address line 2 (if applicable) |
| String | Optional | Residence address line 3 (if applicable) |
| String | Required | Business city |
| String | Required | Country of residence (ISO Alpha-3 code) |
| String | Optional | State/province of business |
| String | Optional | Postal code/ZIP of business |
| String | Optional | Email address |
| String | Optional | Business phone number |
| String | Optional | Country calling code |
Beneficiary oneOf Options:
The beneficiary "oneOf" options allow the application to collect the beneficiary information for a transaction using one of two different options business, or consumer.
Option 1: beneficiary.business
beneficiary.businessField | Type | Required | Description |
|---|---|---|---|
| String | Optional | Partner’s business profile ID that will be passed from the partner and mapped to the MoneyGram profile ID |
| String | Required | Name of the business |
| String | Optional | The legal name of the business |
| String | Optional | Type of business |
| String | Required | Business registration number |
| String | Optional | Date of business formation |
| String | Required | Business’s country of registration |
| String | Required | Residence address line 1 |
| String | Optional | Residence address line 2 (if applicable) |
| String | Optional | Residence address line 3 (if applicable) |
| String | Required | City of residence |
| String | Optional | State/province of residence |
| String | Required | Country of residence (ISO Alpha-3 code) |
| String | Optional | Postal/ZIP code of residence |
| String | Optional | Email address |
| String | Optional | Phone number |
| String | Optional | Country calling code (ISO alpha-3 code) |
Option 2: beneficiary.consumer
beneficiary.consumerField | Type | Required | Description |
|---|---|---|---|
| String | Required | First Name |
| String | Optional | Middle Name (if applicable) |
| String | Required | Last Name |
| String | Optional | Second Last Name |
| String | Optional | Residence address line 1 |
| String | Optional | Residence address line 2 (if applicable) |
| String | Optional | Residence address line 3 (if applicable) |
| String | Required | City of residence |
| String | Optional | State/province of residence. |
| String | Required | Country of residence. |
| String | Optional | Postal code/ZIP of residence |
| String | Optional | Phone number |
| String | Optional | Country calling code (ISO alpha-3 code) |
Transactional Information
Field | Type | Required | Description |
|---|---|---|---|
| String | Optional | Explanation or reason for transferring funds (Enumerated Values) |
| String | Optional | Declaration of where the transaction funds were sourced. |
| String | Optional | Proof of where the transaction funds were sourced (Enumerated Values) |
| String | Optional | Explanation for using MoneyGram service (Enumerated Values) |
Account Deposit
Field | Type | Required | Description |
|---|---|---|---|
| String | Optional | Bank account type |
| String | Optional | A unique string of numbers, letters, or other characters which identify a specific bank account |
| String | Optional | A unique string of numbers, letters, or other characters which identify a specific bank account |
| String | Optional | Bank Identifier Code (BIC) — an 8 to 11-character code used to identify a specific bank during international transactions |
| String | Optional | For collecting the Indian Financial System Code (IFSC) or routing number for Bangladesh, with a lookup feature for these countries |
| String | Optional | Bank’s name |
| String | Optional | Manually entered bank name if not provided in the bank name list |
| String | Optional | Manually entered bank branch name |
| String | Optional | Bank’s routing number |
| String | Optional | Manually entered receiver bank branch code |
| String | Optional | Receiver identification number |
| String | Optional | Expiration month of the account |
| String | Optional | Expiration year of the account |
| String | Optional | Flag to indicate if the purpose of transaction is for emigration |
| String | Optional | Explanation or reason for transferring funds (Enumerated Values) |
| String | Optional | State/province of the receiver (Enumerated Values) |
| Dynamic | Optional | Dynamic field key/values for the target account |
| Dynamic | Optional | Dynamic field key/values for the transaction |
Attachments
Field | Type | Required | Description |
|---|---|---|---|
| String | Optional | Name of the attachment |
| String | Optional | Type of attachment (Enumerated Values) |
| String | Optional | Category of the attachment (Enumerated Values) |
| String | Optional | The file to be uploaded |
Additional Details
Field | Type | Required | Description |
|---|---|---|---|
| Dynamic | Optional | Dynamic field key/values for the transaction |
Response Fields
Field | Type | Required | Description |
|---|---|---|---|
| String | Optional | Unique identifier for the transaction resource |
| String | Optional | Partners Unique identifier for the transaction resource |
| String | Required | Business's unique MoneyGram identifier |
| String | Required | Consumer facing name to identify the transaction method |
| String | Required | Unique identifier of the individual banking, wallet, or card provider for the service option. |
| String | Required | MoneyGram's unique reference number, only for autoCommit=true |
| String | Required | Expected payout date (Example value - YYYY-MM-DD), only for autoCommit=true |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Required | Transaction amount and currency excluding fees and exchange rate. Transaction Currency (ISO alpha-3 code) |
| String | Required | The |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Required | Fee Amount and Fee Currency applied to transaction (Fee currencyCode uses ISO alpha-3 code) |
| String | Required | The |
| Number 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 currencyCode uses ISO alpha-3 code) |
| String | Optional | The |
| String | Optional | Code to indicate if the fee is to be collected by MoneyGram or the partner |
| String | Optional | Consumer facing name to identify the charge type |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Optional | Additional fee's amount |
| String | Optional | The |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Optional | Transaction discount amount applied and currency type excluding fees and exchange rate. Transaction discount currencyCode (ISO alpha-3 code) |
| String | Optional | The |
| String | Optional | Additional Details about the applied promotion to the transaction. currencyCode (ISO alpha-3 code) |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Optional | The transaction's total discount applied. |
| String | Optional | The |
| String | Optional | Error code defined by MoneyGram |
| String | Optional | Error message associated with the error code |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Required | Transaction Total Amount and Transaction Total Currency including fees, taxes and discount. (Total currencyCode uses ISO alpha-3 code) |
| String | Required | The |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Required | Transaction Received Amount and Transaction Receive currency. (Receive amount currencyCode uses ISO alpha-3 code) |
| String | Required | The |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Optional | Received Fee and Receive Currency applied to the transaction by the destination country. (Receve fee currencyCode uses ISO alpha-3 code) |
| String | Optional | The |
| String | Optional | Code to indicate if the fee is to be collected by MoneyGram or the partner |
| String | Optional | Consumer facing name to identify the charge type |
| Number Min length: 0 Max length: 14 Max decimal Value: 3 | Optional | Additional fee's amount |
| String | Optional | The |
| Number 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. (Receive taxes currencyCode uses ISO alpha-3 code) |
| String | Optional | The |
| Number 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 (Receive total currencyCode uses ISO alpha-3 code) |
| String | Required | The |
| Number | Required | Fx Rate applied to transaction |
| 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. |
| String | Optional | MoneyGram unique attachment Id |
| String | Optional | Uploaded file type (pdf, png, bmp, jpg, docx, xlsx) |
| String | Optional | Uploaded file Name |
| String | Optional | Attachment type category |
| String | Optional | Document type |
Updated 29 days ago
