Building Integrations
Create custom integrations with the Delivami API.
Overview
This guide walks you through building custom integrations with Delivami. Connect your favorite tools or build custom workflows.
Integration Types
Webhook-Based
Receive real-time notifications:
- Delivery status changes
- Payment events
- Client activity
API-Based
Poll or query data:
- List deliveries
- Create invoices
- Manage clients
Hybrid
Combine both approaches:
- Webhooks for real-time events
- API for on-demand queries
Getting Started
Prerequisites
- Delivami Pro or Studio plan
- API key with appropriate permissions
- Development environment
Step 1: Get API Key
- Go to Settings > Integrations > API Keys
- Create a new key
- Save it securely
Step 2: Test Connection
curl -X GET "https://api.delivami.com/v1/me" \
-H "Authorization: Bearer YOUR_API_KEY"If successful, you'll receive your account information.
Common Integration Patterns
Slack Integration
Notify your team when deliveries are approved:
// Webhook handler
app.post('/webhooks/delivami', (req, res) => {
const event = req.body;
if (event.type === 'delivery.approved') {
slack.send({
channel: '#deliveries',
text: `✅ ${event.data.title} was approved!`
});
}
res.sendStatus(200);
});Google Drive Backup
Sync deliveries to Google Drive:
// Sync approved deliveries
async function syncToDrive(deliveryId) {
const delivery = await delivami.getDelivery(deliveryId);
for (const file of delivery.files) {
const driveFile = await googleDrive.upload({
name: file.name,
content: file.buffer
});
console.log(`Uploaded ${file.name} to Drive`);
}
}Custom Dashboard
Build a custom dashboard with delivery data:
// Fetch and display deliveries
async function loadDashboard() {
const deliveries = await delivami.getDeliveries({
status: 'in_review',
limit: 20
});
renderDashboard(deliveries);
}Authentication
OAuth 2.0
For user-facing integrations:
- Redirect to Delivami OAuth
- User authorizes your app
- Receive access token
- Use token for API calls
API Key Authentication
For server-side integrations:
const delivami = new Delivami({
apiKey: process.env.DELIVAMI_API_KEY
});Error Handling
Common Errors
| Error | Meaning | Solution |
|---|---|---|
| 401 | Invalid API key | Check your key |
| 403 | Insufficient permissions | Update key scopes |
| 404 | Resource not found | Check resource ID |
| 429 | Rate limited | Wait and retry |
| 500 | Server error | Contact support |
Retry Strategy
async function makeRequest(fn, retries = 3) {
try {
return await fn();
} catch (error) {
if (error.status === 429 && retries > 0) {
const wait = Math.pow(2, 4 - retries) * 1000;
await sleep(wait);
return makeRequest(fn, retries - 1);
}
throw error;
}
}Testing
Test Mode
Use test API keys for development:
- No real data affected
- Same API endpoints
- Test webhook delivery
Test Webhooks
- Create a test webhook
- Send test events
- Verify your handler works
Postman Collection
Download our Postman collection:
- Go to Settings > Integrations > API
- Click Download Postman Collection
- Import into Postman
Deployment
Environment Variables
Store sensitive data securely:
# Production
DELIVAMI_API_KEY=live_key_here
WEBHOOK_SECRET=your_secret_here
# Test
DELIVAMI_API_KEY=test_key_hereMonitoring
Set up monitoring for:
- API response times
- Error rates
- Webhook delivery success
Best Practices
- Start small - Build a simple integration first
- Handle errors gracefully - Always have fallbacks
- Log everything - Help with debugging
- Test thoroughly - Use test mode
- Document your code - Future you will thank you
