POST Create Target Account Profile
POST /receiver-account/v1/targetAccountProfiles
Development Guide
The Receiver-Accounts API allows the application to create a profile for a receiver's bank or wallet account and returns a targetAccountProfileId
.
1. Prepare headers & authentication:
Call the 'Create a target account profile' 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:
👉Create Target Account Profile - HeadersOpen Recipe
2. Provide sender
, receiver
& targetAccount
information to the request body:
sender
, receiver
& targetAccount
information to the request body:The application at a minimum must provide the following fields: destinationCountryCode
, receiveCurrencyCode
, serviceOptionCode
, serviceOptionRoutingCode
, sender.name.firstName
, sender.name.lastName
, sender.mobilePhone.number
, sender.mobilePhone.countryDialCode
, receiver.name.firstName
, receiver.name.lastName
, receiver.address.line1
, receiver.address.city
, receiver.address.countryCode
, receiver.mobilePhone.number
, receiver.mobilePhone.countryDialCode
and the targetAccount
.
Note:
- The application can use the 'Retrieve Account Deposit Fields for Registration' to understand the necessary beneficiary account fields required to for the bank, wallet or card deposit
serviceOption
. This endpoint returns an array of service options and keys. The keys are account fields that need to be collected from the consumer to transfer funds to the corresponding bank, wallet or card. Learn More- The 'Create a target account profile' API uses ISO Standards for country values. MoneyGram provide Reference Data APIs which can be queried to understand the supported values and associated metadata.
Launch Code Example:
👉Create Target Account Profile - Request BodyOpen Recipe
3. Make the request and handle the response:
The application will call the 'Retrieve Account Deposit Fields for Registration' endpoint with a GET HTTP method. The 'Retrieve Countries' API will generate a response with an array of supported values and metadata for all countries. The application must build to handle the following response scenarios.
- Success | Parse the Response | 200 OK HTTP Status |
"targetAccountCheckedCode": "ACCOUNT_CHECKED
When the 'Create a Target Account Profile' endpoint responds with a 200 HTTP Status, atargetAccountProfileId
is created and the"targetAccountCheckedCode": "Account_Checked"
indicating the target account details have been validated. The application can continue.
- Success | Parse the Response | 200 OK HTTP Status |
"targetAccountCheckedCode": "ACCOUNT_NOT_CHECKED
When the 'Create a Target Account Profile' endpoint responds with a 200 HTTP Status, atargetAccountProfileId
is created and the"targetAccountCheckedCode": "Account_Not_Checked"
indicating the target account details have failed validation. The application must correct details and resubmit the request.
- Success | Parse the Response | 200 OK HTTP Status |
"targetAccountCheckedCode": "ACCOUNT_NOT_AVAILABLE
When the 'Create a Target Account Profile' endpoint responds with a 200 HTTP Status, atargetAccountProfileId
is created and the "targetAccountCheckedCode": "ACCOUNT_NOT_AVAILABLE"
indicating the destination country and clearing system do not offer validation of account details. The application can continue.
- Failed | Handle the Error | 400 Bad Request HTTP Status
When the 'Create a Target Account Profile' 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 request.
Launch Code Example:
👉Create Target Account Profile - 200 OK ACCOUNT_CHECKEDOpen Recipe.
👉Create Target Account Profile - 200 OK ACCOUNT_NOT_CHECKEDOpen Recipe.
👉Create Target Account Profile - 200 OK ACCOUNT_NOT_AVAILABLEOpen Recipe.
👉Create Target Account Profile - 400 Bad RequestOpen Recipe
4. You're Done! Proceed to Transfer API Module
Once the account data has been validated and the application can continue to make a transaction.
Code Examples
const axios = require('axios');
const { v4: uuidv4 } = require('uuid');
const createAccountProfile = 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 + '/receiver-account/v1/targetAccountProfiles';
// 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",
receiveCurrencyCode: "USD",
destinationCountrySubdivisionCode: "US-TX",
serviceOptionCode: "BANK_DEPOSIT",
serviceOptionRoutingCode: "74261037",
sender: {
name: {
firstName: "John",
middleName: "",
lastName: "Doe",
secondLastName: ""
},
address: {
line1: "100 Main ST",
line2: "",
line3: "",
city: "Dallas",
countrySubdivisionCode: "US-TX",
countryCode: "USA",
postalCode: "75001"
},
mobilePhone: {
number: "555551234",
countryDialCode: "1"
},
},
receiver: {
name: {
firstName: "Jane",
middleName: "",
lastName: "Doe",
secondLastName: ""
},
address: {
line1: "200 Second ST",
line2: "",
line3: "",
city: "Dallas",
countrySubdivisionCode: "US-MN",
countryCode: "USA",
postalCode: "55111"
},
mobilePhone: {
number: "555121234",
countryDialCode: "1"
},
dateOfBirth: "1998-10-01",
},
targetAccount: {
accountType: "22",
accountNumber: "987654321",
accountNumberVerification: "987654321",
bankCode: "123456789"
}
}
}
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
// 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);
};
createAccountProfile();
import requests
import uuid
import json
def create_account_profile():
# 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 + "/receiver-account/v1/targetAccountProfiles"
# 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",
"receiveCurrencyCode": "USD",
"destinationCountrySubdivisionCode": "US-TX",
"serviceOptionCode": "BANK_DEPOSIT",
"serviceOptionRoutingCode": "74261037",
"sender": {
"name": {
"firstName": "John",
"middleName": "",
"lastName": "Doe",
"secondLastName": "",
},
"address": {
"line1": "100 Main St",
"city": "Dallas",
"countrySubdivisionCode": "US-TX",
"countryCode": "USA",
"postalCode": "75001",
},
"mobilePhone": {"number": "555551234", "countryDialCode": "1"},
},
"receiver": {
"name": {
"firstName": "Jane",
"middleName": "",
"lastName": "Doe",
"secondLastName": "",
},
"address": {
"line1": "line 1 of address",
"city": "Dallas",
"countrySubdivisionCode": "US-TX",
"countryCode": "USA",
"postalCode": "75001",
},
"mobilePhone": {"number": "555551234", "countryDialCode": "1"},
"dateOfBirth": "1998-10-01",
},
"targetAccount": {
"accountType": "22",
"accountNumber": "987654321",
"accountNumberVerification": "987654321",
"bankCode": "123456789",
},
}
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:
# 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)
create_account_profile()
package receiveraccount;
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 CreateAccountProfile {
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 + "/receiver-account/v1/targetAccountProfiles";
// Step 2: Create the POST request headers & body
// Create a JSON object
JsonObjectBuilder senderBuilder = Json.createObjectBuilder()
.add("name", Json.createObjectBuilder().add("firstName", "firstName").add("lastName", "lastName"))
.add("mobilePhone", Json.createObjectBuilder().add("number", "6123456789").add("countryDialCode", "1"));
JsonObjectBuilder receiverBuilder = Json.createObjectBuilder()
.add("name", Json.createObjectBuilder().add("firstName", "firstName").add("lastName", "lastName"))
.add("address", Json.createObjectBuilder().add("line1", "line1 of address").add("city", "Dallas")
.add("countryCode", "USA").add("countrySubdivisionCode", "US-TX").add("postalCode", "75001"))
.add("mobilePhone", Json.createObjectBuilder().add("number", "6123456789").add("countryDialCode", "1"))
.add("dateOfBirth", "1980-01-15");
JsonObjectBuilder targetAccountBuilder = Json.createObjectBuilder()
.add("targetAccount", Json.createObjectBuilder().add("accountType", "22").add("accountNumber", "987654321")
.add("accountNumberVerification", "987654321").add("bankCode", "123456789"));
JsonObjectBuilder requestBuilder = Json.createObjectBuilder()
.add("agentPartnerId", "your_partner_id")
.add("targetAudience", "AGENT_FACING")
.add("userLanguage", "en-US")
.add("destinationCountryCode", "USA")
.add("destinationCountrySubdivisionCode", "US-TX")
.add("serviceOptionCode", "BANK_DEPOSIT")
.add("serviceOptionRoutingCode", "74261037")
.add("sender", senderBuilder)
.add("receiver", receiverBuilder);
.add("targetAccount", targetAccountBuilder);
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 Structure
Header Parameters
Field | 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 Fields
Field | Type | Required /Optional | Description |
---|---|---|---|
targetAudience | String | Optional | Tailors MoneyGram’s error messages and field metadata to an in-store, digital or crypto customer. (Enumerated value) NOTE: For a full list of accepted target audience values. See the TARGET_AUDIENCE enumeration from the Reference Data Enumerations endpoint |
agentPartnerId | String | Required | Unique identifier for the agent or partner |
userLanguage | String | Optional | Language used by the user/operator |
destinationCountryCode | String Max Length: 3 | Required | Transaction 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 |
serviceOptionCode | String Max length: 21 | Required | Unique category code to identify the transaction method NOTE: For a full list of accepted service option codes per destination country see the Reference Data API Module: service-options endpoint |
serviceOptionRoutingCode | String Max length: 21 | Required | Unique identifier of the individual banking, wallet, or card provider for the service option. NOTE: For a full list of accepted service option codes per destination country see the Reference Data API Module: service-options endpoint |
sender.name.firstName | String Min length: 1 Max length: 20 | Required | First Name |
sender.name.middleName | String Min length: 1 Max length: 20 | Optional | Middle Name (if applicable) |
sender.name.lastName | String Min length: 1 Max length: 30 | Required | Last Name |
sender.name.secondLastName | String Min length: 1 Max length: 30 | Optional | Second Last Name |
sender.mobilePhone.number | String Min length: 5 Max length: 14 | Required | Phone number |
sender.mobilePhone.countryDialCode | String Min length: 1 Max length: 3 | Required | Country dial code NOTE: For country calling code see Reference Data API Module /countries endpoint phoneDialCodes |
receiver.name.firstName | String Min length: 1 Max length: 20 | Required | First Name |
receiver.name.middleName | String Min length: 1 Max length: 20 | Optional | Middle Name (if applicable) |
receiver.name.lastName | String Min length: 1 Max length: 30 | Required | Last Name |
receiver.name.secondLastName | String Min length: 1 Max length: 30 | Optional | Second Last Name (if applicable) |
receiver.address.line1 | String Min length: 1 Max length: 80 | Required | Residence address line 1 |
receiver.address.line2 | String Min length: 1 Max length: 80 | Optional | Residence address line 2 (if applicable) |
receiver.address.line3 | String Min length: 1 Max length: 80 | Optional | Residence address line 3 (if applicable) |
receiver.address.city | String Min length: 1 Max length: 40 | Required | City of residence |
receiver.address.countrySubdivisionCode | String Max length: 6 | Optional | State/province of residence. NOTE: For a full list of accepted countries and supported destination country subdivision codes see Reference Data API Module: Retrieve Countries ISO3 endpoint |
receiver.address.countryCode | String Max length: 3 | Required | Country of residence. (ISO alpha-3 code) NOTE: For a full list of accepted countries and supported destination country subdivision codes see Reference Data API Module: Retrieve Countries ISO3 endpoint |
receiver.address.postalCode | String Min length: 2 Max length: 6 | Optional | Postal code/ZIP of residence |
receiver.mobilePhone.number | String Min length: 5 Max length: 14 | Optional | Phone number |
receiver.mobilePhone.countryDialCode | String Min length: 1 Max length: 3 | Optional | Country dial code |
Target Account Fields
Field | Type | Required /Optional | Description |
---|---|---|---|
targetAccount.accountType | String | Optional | Bank account type |
targetAccount.accountNumber | String | Optional | A unique string of numbers, letters, or other characters which identify a specific bank account |
targetAccount.accountNumberVerification | String | Optional | A unique string of numbers, letters, or other characters which identify a specific bank account |
targetAccount.bankIdentifier | String | Optional | Bank Identifier Code (BIC) an 8 to 11-character code that is used to identify a specific bank when you make an international transaction |
targetAccount.bankIdentifierWithLookup | String | Optional | For collecting the Indian Financial System Code (IFSC) or routing number for Bangladesh, with a lookup feature for these countries |
targetAccount.bankName | String | Optional | Bank's name |
targetAccount.bankNameText | String | Optional | Manually entered bank name if not provided in the bank name list |
targetAccount.bankBranchName | String | Optional | Manually entered bank branch name |
targetAccount.bankCode | String | Optional | Bank's routing number |
targetAccount.bankBranchCode | String | Optional | Manually entered receiver bank branch code |
targetAccount.benefIdNumber | String | Optional | Receiver identification number |
targetAccount.accountExpirationMonth | String | Optional | Expiration month of the account |
targetAccount.accountExpirationMonth | String | Optional | Expiration year of the account |
targetAccount.receiverPurposeOfTransactionEmigrationFlag | String | Optional | Flag to indicate if the purpose of transaction is for emigration |
targetAccount.sendPurposeOfTransactionPartnerField | String | Optional | Explanation or reason of the transferring funds (Enumerated Values) |
targetAccount.receiverAccountIssueStatePartnerField | String | Optional | State/province of the receiver (Enumerated Values) |
targetAccount.additionalDetails | Dynamic | Optional | Dynamic field key/values for the target account |
targetAccount.additionalDetails | Dynamic | Optional | Dynamic field key/values for the transaction |
Additional Details
Field | Type | Required /Optional | Description |
---|---|---|---|
additionalDetails | Dynamic | Optional | Dynamic field key/values for the transaction |
Response Fields
Field | Type | Required /Optional | Description |
---|---|---|---|
targetAccountProfileId | String | Required | Unique identifier for the target account profile |
targetAccountCheckedCode | String | Required | Code to indicate the target account details are confirmed with the downstream partner, or if account checking is not available for the downstream partner. (Enumerated Value) ACCOUNT_CHECKED, ACCOUNT_CHECK_NOT_AVAILABLE, ACCOUNT_CHECK_FAILED. |
additionalDetails | Dynamic | Optional | Dynamic field key/values for the transaction |
Updated 17 days ago