Integrating Sender Profiles into Your Application
This guide shows you how to route messaging traffic through Sender Profiles in your own app: send with a profile's API key, map customers to profiles in a multi-tenant platform, and attribute webhook events to the right profile. It assumes your organization already has at least one profile (create one in the dashboard or via the API) and that you can already send messages. For the inheritance model behind profiles, see Sender Profiles.
Send with a profile's API key
Each Sender Profile has its own API credentials. The API key you authenticate with determines which profile's resources (templates, contacts, numbers, and compliance settings) the request uses, so sending as a profile is just sending with that profile's key:
curl -X POST "https://api.sent.dm/v3/messages" \
-H "x-api-key: $PROFILE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": ["+1234567890"],
"template": {"id": "7ba7b820-9dad-11d1-80b4-00c04fd430c8"}
}'If you prefer to keep a single credential instead of one key per profile, send with your organization API key and scope each request with the x-profile-id header (a profile UUID belonging to your organization). Only organization keys can use this header; profile-scoped keys are rejected with 403. The Sender Profiles API guide covers this pattern in detail.
Map each customer to a profile
For platforms serving multiple customers, store the profile-to-customer mapping in your own database and resolve the credentials per request:
async function sendOnBehalfOfCustomer(customerId: string, message: MessageRequest) {
const profile = await db.senderProfiles.findByCustomer(customerId);
const client = new SentDm({ apiKey: profile.apiKey });
return client.messages.send({
to: message.recipients,
template: { id: message.templateId },
variables: message.variables
});
}Track usage per profile in webhooks
Every event names its account in payload.account_id: the Sender Profile for events its clones deliver, and your organization for your own events. Map that ID to your tenant, rather than storing each message_id and looking the message up when its event arrives. The samples skip your organization's own sends by comparing with its ID, ORGANIZATION_ID.
Receive every profile's events at one endpoint by selecting them under sender_profile on your organization's webhook. Sent clones the webhook onto each profile, including profiles you create later, so onboarding a tenant needs no webhook change. See Sender Profile Events for the request.
app.post('/webhooks/sent', async (req, res) => {
res.sendStatus(200);
const { field, payload } = req.body;
if (field === 'message' && payload.message_status === 'SENT') {
// Your organization's own sends carry its ID
const senderProfileId = payload.account_id;
if (senderProfileId !== ORGANIZATION_ID) {
await analytics.track('message_sent', {
senderProfileId,
messageId: payload.message_id,
channel: payload.channel,
outboundNumber: payload.outbound_number,
timestamp: new Date()
});
}
}
});Secure multi-tenant credentials
- Store each profile's API key in a separate secrets-management entry so one leaked key exposes one tenant, not all of them.
- Verify webhook signatures before trusting any event.
- Apply per-profile rate limiting in your own app so one tenant cannot consume another tenant's throughput.
Verify the integration
Send a test message with one profile's key, then confirm its delivery events carry that profile's ID in payload.account_id. If no events arrive at your endpoint, check that your organization's webhook selects them under sender_profile, and that the profile hasn't deleted its clone.
Related
- Sender Profiles explains inheritance, sharing, and isolation
- Creating a Sender Profile walks through the dashboard wizard
- Create and activate Sender Profiles via the API automates tenant onboarding
- Multi-Tenant Architectures compares shared and per-tenant setups
- Refer to the messages API reference for the full list of send options
Creating a Sender Profile
Create a Sender Profile in the Sent dashboard: identity, brand, campaign, billing and notification choices, channels, WhatsApp, number type, and 10DLC or alphasender registration.
Batch Operations
How to send messages in bulk with the Sent API: batches of up to 1000 recipients, rate limit management, idempotent retries, and bulk contact imports.