Loans API
Endpoints for managing peer-to-peer loans.
Create Loan Request
Request a new loan based on your Trust Score.
curl -X POST "https://api.usmewe.com/v1/loans" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"amount": 50,
"duration": 14,
"purpose": "Emergency expense"
}'
Request Parameters
| Parameter | Type | Required | Description |
|---|
amount | number | Yes | USDC amount to borrow |
duration | number | Yes | Loan term in days (7-90) |
purpose | string | No | Reason for loan |
Get Loan Details
Retrieve details of a specific loan.
curl -X GET "https://api.usmewe.com/v1/loans/{loanId}" \
-H "Authorization: Bearer YOUR_TOKEN"
List User Loans
Get all loans for the authenticated user.
curl -X GET "https://api.usmewe.com/v1/loans?status=active&limit=10" \
-H "Authorization: Bearer YOUR_TOKEN"
Query Parameters
| Parameter | Type | Description |
|---|
status | string | Filter by status |
limit | number | Results per page (default: 20) |
offset | number | Pagination offset |
Loan Statuses
| Status | Description |
|---|
pending | Awaiting funding |
active | Loan is active |
repaid | Successfully repaid |
overdue | Past due date |
defaulted | Default declared |
cancelled | Cancelled before funding |
Check Eligibility
Check loan eligibility before requesting.
curl -X GET "https://api.usmewe.com/v1/loans/eligibility" \
-H "Authorization: Bearer YOUR_TOKEN"
Eligibility Restrictions
| Code | Description |
|---|
SCORE_TOO_LOW | Trust Score below minimum |
MAX_LOANS_REACHED | Already at loan limit |
OVERDUE_LOAN | Has overdue loan |
RECENT_DEFAULT | Defaulted within 90 days |
Repay Loan
Make a loan repayment.
curl -X POST "https://api.usmewe.com/v1/loans/{loanId}/repay" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"amount": 51.35
}'
Partial Repayment
curl -X POST "https://api.usmewe.com/v1/loans/{loanId}/repay" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"amount": 25}'
Calculate Early Payoff
Get early payoff amount with interest savings.
curl -X GET "https://api.usmewe.com/v1/loans/{loanId}/payoff" \
-H "Authorization: Bearer YOUR_TOKEN"
Cancel Loan Request
Cancel a pending loan request.
curl -X POST "https://api.usmewe.com/v1/loans/{loanId}/cancel" \
-H "Authorization: Bearer YOUR_TOKEN"
Only pending loans can be cancelled. Funded loans must be repaid.
Request Extension
Request a loan extension (if eligible).
curl -X POST "https://api.usmewe.com/v1/loans/{loanId}/extension" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"days": 7,
"reason": "Medical emergency"
}'
Webhook Events
// Loan funded
{
"event": "loan.funded",
"data": {
"loanId": "loan_xyz789",
"amount": 50,
"netAmount": 45
}
}
// Loan repaid
{
"event": "loan.repaid",
"data": {
"loanId": "loan_xyz789",
"totalPaid": 51.35
}
}
// Loan overdue
{
"event": "loan.overdue",
"data": {
"loanId": "loan_xyz789",
"daysOverdue": 1
}
}
Error Responses
| Code | Error | Description |
|---|
| 400 | INVALID_AMOUNT | Amount exceeds limit |
| 400 | INVALID_DURATION | Duration out of range |
| 403 | NOT_ELIGIBLE | User not eligible for loan |
| 404 | LOAN_NOT_FOUND | Loan does not exist |
| 409 | ALREADY_REPAID | Loan already repaid |