Guides
How to push deals from your CRM into SmartMCA via the API
This guide walks through integrating your CRM (Salesforce, HubSpot, or custom) with SmartMCA to automatically submit new deals when they close.
The typical flow:
merchants:write, contacts:write, applications:writeCheck if the merchant already exists by searching, then create if needed.
// Search for existing merchant by EIN
const searchRes = await fetch(
'https://api.smartmca.com/api/public/v1/merchants?search=12-3456789',
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
const { data: merchants } = await searchRes.json();
let merchantId;
if (merchants.length > 0) {
merchantId = merchants[0].id;
} else {
// Create new merchant
const createRes = await fetch('https://api.smartmca.com/api/public/v1/merchants', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
legalName: crmDeal.companyName,
dba: crmDeal.dbaName,
ein: crmDeal.ein,
industry: crmDeal.industry,
address: crmDeal.address,
city: crmDeal.city,
state: crmDeal.state,
zip: crmDeal.zip,
}),
});
const merchant = await createRes.json();
merchantId = merchant.data.id;
}
const contactRes = await fetch(
`https://api.smartmca.com/api/public/v1/merchants/${merchantId}/contacts`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstName: crmDeal.contactFirstName,
lastName: crmDeal.contactLastName,
email: crmDeal.contactEmail,
phone: crmDeal.contactPhone,
title: crmDeal.contactTitle,
isPrimary: true,
}),
}
);
const appRes = await fetch('https://api.smartmca.com/api/public/v1/applications', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': `crm-deal-${crmDeal.id}`, // Prevent duplicates
},
body: JSON.stringify({
merchantId,
requestedAmount: crmDeal.amount,
useOfFunds: crmDeal.purpose,
sourceType: 'direct',
brokerName: crmDeal.referralPartner || undefined,
}),
});
const application = await appRes.json();
console.log(`Application created: ${application.data.id}`);
If your CRM has attached documents (bank statements, tax returns), upload them:
const form = new FormData();
form.append('file', fs.createReadStream(documentPath));
form.append('documentType', 'bankStatement');
await fetch(
`https://api.smartmca.com/api/public/v1/applications/${application.data.id}/documents`,
{
method: 'POST',
headers: { 'Authorization': `Bearer ${API_KEY}` },
body: form,
}
);
Use the Idempotency-Key header with a deterministic key (e.g., crm-deal-{crmDealId}) to prevent duplicate submissions if your webhook fires more than once. See the Idempotency guide for details.
Set up a webhook subscription for application.status_changed to receive updates as the application moves through your workflow:
await fetch('https://api.smartmca.com/api/public/v1/webhooks', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://your-crm-middleware.com/webhooks/smartmca',
events: ['application.status_changed', 'deal.funded'],
description: 'CRM sync webhook',
}),
});
| HTTP Status | Meaning | Action |
|---|---|---|
| 409 | Duplicate (idempotency) | Safe to ignore — original response returned |
| 422 | Validation error | Check field values, fix and retry |
| 429 | Rate limited | Back off and retry after Retry-After header |
| 500 | Server error | Retry with exponential backoff |