Register IOU
Request URL
POST /iou
Description
Create and register a new IOU and an IOU transaction representing an amount owed by one user (the borrower) to another (the lender). This may be a new IOU for this pair of users. Alternately, it may adjust the balance for an IOU that is already registered.
Schema
Property table for iou
Property | Description | Required | Schema |
---|---|---|---|
borrowerAFiUserId | ampliFi ID of the borrower (debtor) | Yes | { "type": "string" } |
lenderAFiUserId | ampliFi ID of the lender (creditor) | Yes | { "type": "string" } |
requesterAFiUserId | ampliFi ID of the requester | No | { "type": "string", "nullable": true } |
amount | Amount | Yes | { "type": "string" } |
currency | 3-letter ISO alphabetic code to identify the currency | Yes | { "type": "string", "pattern": "^[A-Z]{3}$" } |
narrativeDebit | A brief description, used if transaction is debit | No | { "type": "string", "nullable": true } |
narrativeCredit | A brief description, used if transaction is credit | No | { "type": "string", "nullable": true } |
narrative | A brief description | No | { "type": "string", "nullable": true } |
isPending | true if action is pending borrower approval | No | { "type": "boolean", "nullable": true, "default": false } |
attachments | An object containing additional properties, if any | No | { "additionalProperties": true, "type": "object", "required": [], "nullable": true } |
images | An array of binary image strings, if any | No | array of { "type": "string" } |
isTransactionToBeRecorded | true if transaction is to be recorded | No | { "type": "boolean", "nullable": true, "default": true } |
isTrensactionsClearoffNeeded | true if transaction clear off is needed | No | { "type": "boolean", "nullable": true, "default": true } |
isFromFrontEnd | true if request is from front end | No | { "type": "boolean", "nullable": true } |
Request Body
{
"borrowerAFiUserId": "qweaurl8kgtlv9pc",
"lenderAFiUserId": "qweaurl8kddma4is",
"amount": 1.01,
"currency": "USD"
}
Snippet Examples
javascript
const axios = require('axios');
const data = {
"borrowerAFiUserId": "qweaurl8kgtlv9pc",
"lenderAFiUserId": "qweaurl8kddma4is",
"amount": 1.01,
"currency": "USD"
};
const config = {
method: 'POST',
url: '${AMPLIFI_BASE_URL}/iou',
headers: {
'Content-Type': "application/json",
'token': "A long random string token received from /token request"
},
data
};
let result;
try {
result = await axios.request(config);
if (result.status === 200) {
console.log(JSON.stringify(result.data));
}
} catch (err) {
console.log({
errCode: err.code,
responseStatus: err.response && err.response.status,
data: err.response && JSON.stringify(err.response.data)
});
}
cURL
curl --location "AMPLIFI_BASE_URL/iou" --data "{ \"borrowerAFiUserId\":\"qweaurl8kgtlv9pc\", \"lenderAFiUserId\":\"qweaurl8kddma4is\", \"amount\":1.01, \"currency\":\"USD\"}" --header "Content-Type: application/json" --header "token: A long random string token received from /token request"
Successful Response Examples
200 IOU SUCCESSFUL RESPONSE REGISTER AN IOU
HEADERS
Header | Value |
---|---|
Content-Type | application/json |
token | A long random string token received from /token request |
REQUEST BODY
{
"borrowerAFiUserId": "qweaurl8kgtlv9pc",
"lenderAFiUserId": "qweaurl8t06royym",
"amount": 1.01,
"currency": "USD",
"narrativeDebit": "A short description, if transaction is debit",
"narrativeCredit": "A short description if transaction is credit",
"narrative": "A short description",
"attachments": {},
"images": []
}
RESPONSE BODY