POST /send_application_invite - Send Application Invite
Send an application invite email to a potential customer. Requires user authentication.
Authentication Required: This endpoint requires a valid access token.
Endpoint URL
POST /api/send_application_invite?api_token=your_api_access_token
Request Headers
Authorization: Bearer your_access_token
Content-Type: application/json
Request Body
{
"email": "customer@example.com",
"company_name": "ABC Corporation",
"contact_name": "John Smith",
"message": "Optional custom message for the invite"
}
Response
Success (200 OK):
{
"status": "success",
"message": "Application invite sent successfully",
"invite_id": "inv_123456789",
"expires_at": "2023-12-01T23:59:59Z"
}
Error (401 Unauthorized):
{
"status": "error",
"message": "Authentication required"
}
Error (400 Bad Request):
{
"status": "error",
"message": "Invalid email address",
"errors": {
"email": ["The email field must be a valid email address"]
}
}
Example Usage
curl -X POST "https://api.creditrisk.co.za/api/send_application_invite?api_token=your_api_token" \
-H "Authorization: Bearer your_access_token" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"company_name": "ABC Corporation",
"contact_name": "John Smith",
"message": "We would like to offer you credit terms."
}'
async function sendApplicationInvite(inviteData) {
const accessToken = localStorage.getItem('access_token');
try {
const response = await fetch('https://api.creditrisk.co.za/api/send_application_invite?api_token=your_api_token', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: inviteData.email,
company_name: inviteData.companyName,
contact_name: inviteData.contactName,
message: inviteData.message || ''
})
});
const result = await response.json();
if (response.ok) {
alert('Application invite sent successfully!');
return result;
} else {
throw new Error(result.message || 'Failed to send invite');
}
} catch (error) {
console.error('Error sending invite:', error);
alert('Failed to send application invite: ' + error.message);
}
}
// Usage example
sendApplicationInvite({
email: 'customer@example.com',
companyName: 'ABC Corporation',
contactName: 'John Smith',
message: 'We would like to offer you credit terms.'
});
Warning: Undefined variable $accessToken in /var/www/cr_api/pages/send-application-invite.php on line 178
Warning: Undefined variable $apiToken in /var/www/cr_api/pages/send-application-invite.php on line 178
Error: Unknown error
Field Descriptions
| Field | Type | Required | Description |
|---|---|---|---|
email |
String | Yes | Valid email address of the invite recipient |
company_name |
String | Yes | Name of the company being invited |
contact_name |
String | Yes | Name of the contact person |
message |
String | No | Optional custom message to include in the invite email |
Important Notes
Features
- Automatic email delivery
- Invite tracking and expiry
- Custom message support
- Email validation
Limitations
- Rate limiting: 10 invites per hour
- Invites expire after 7 days
- Requires valid access token
- Email must be unique per invite