Setting Up Notification Environments
In Ductape, you can set up credentials for each Environment. This means your sandbox, staging, and production environments can have different credentials, channels, and optionally exclude certain behavior from specific environments.
Example: Creating a Notification Environment
- TypeScript
- Java
- Go
- .NET
await ductape.notifications.create({
name: "Notify Users",
tag: "notify-users",
description: "Create Notifications",
envs: [
{
slug: 'prd',
push_notifications,
callbacks,
emails,
sms
},
{
slug: 'snd',
push_notifications,
callbacks,
emails,
sms
}
]
});
ductape.notifications.create(Map.of(
"name", "Notify Users",
"tag", "notify-users",
"description", "Create Notifications",
envs: [
Map.of(
"slug", "prd",
push_notifications,
callbacks,
emails,
sms
),
Map.of(
"slug", "snd",
push_notifications,
callbacks,
emails,
sms
)
]
));
client.notifications.create({
"name": "Notify Users",
"tag": "notify-users",
"description": "Create Notifications",
envs: [
{
"slug": "prd",
push_notifications,
callbacks,
emails,
sms
},
{
"slug": "snd",
push_notifications,
callbacks,
emails,
sms
}
]
});
await ductape.notifications.create({
["name"] = "Notify Users",
["tag"] = "notify-users",
["description"] = "Create Notifications",
envs: [
{
["slug"] = "prd",
push_notifications,
callbacks,
emails,
sms
},
{
["slug"] = "snd",
push_notifications,
callbacks,
emails,
sms
}
]
});
Notification Credential Interfaces
Push Notifications
| Field | Type | Required | Description |
|---|---|---|---|
type | Notifiers.EXPO or Notifiers.FIREBASE | Yes | Type of push notifier. |
credentials | object | Optional for Expo, Required for Firebase | Firebase service account details. |
databaseUrl | string | Required for Firebase | Firebase realtime database URL. |
Expo Example
- TypeScript
- Java
- Go
- .NET
const push_notifications = {
type: Notifiers.EXPO
};
Map<String, Object> push_notifications = Map.of(
type: Notifiers.EXPO
);
push_notifications := map[string]any{
type: Notifiers.EXPO
};
var push_notifications = new Dictionary<string, object?>
{
type: Notifiers.EXPO
};
Firebase Example
- TypeScript
- Java
- Go
- .NET
const push_notifications = {
type: Notifiers.FIREBASE,
credentials: {
type: "service_account",
project_id: "...",
// other service account fields
},
databaseUrl: "https://project.firebaseio.com"
};
Map<String, Object> push_notifications = Map.of(
type: Notifiers.FIREBASE,
credentials: Map.of(
"type", "service_account",
"project_id", "...",
// other service account fields
),
"databaseUrl", "https://project.firebaseio.com"
);
push_notifications := map[string]any{
type: Notifiers.FIREBASE,
credentials: {
"type": "service_account",
"project_id": "...",
// other service account fields
},
"databaseUrl": "https://project.firebaseio.com"
};
var push_notifications = new Dictionary<string, object?>
{
type: Notifiers.FIREBASE,
credentials: {
["type"] = "service_account",
["project_id"] = "...",
// other service account fields
},
["databaseUrl"] = "https://project.firebaseio.com"
};
Email Notifications
Ductape supports 5 email providers: SMTP, SendGrid, Mailgun, Postmark, and Brevo. Configure them by setting the provider field and providing the corresponding provider configuration.
Configuration Structure
| Field | Type | Required | Description |
|---|---|---|---|
provider | EmailProvider | Yes | Email service provider (smtp, sendgrid, etc.). |
smtp | object | When provider is 'smtp' | SMTP configuration. |
sendgrid | object | When provider is 'sendgrid' | SendGrid configuration. |
mailgun | object | When provider is 'mailgun' | Mailgun configuration. |
postmark | object | When provider is 'postmark' | Postmark configuration. |
brevo | object | When provider is 'brevo' | Brevo configuration. |
SMTP Configuration
| Field | Type | Required | Description |
|---|---|---|---|
smtp.host | string | Yes | SMTP server host. |
smtp.port | string | Yes | SMTP port. |
smtp.sender_email | string | Yes | From email address. |
smtp.auth.user | string | Yes | SMTP auth username. |
smtp.auth.pass | string | Yes | SMTP auth password. |
smtp.secure | boolean | Optional | Use SSL/TLS. |
smtp.tls | object | Optional | TLS configuration. |
SMTP Example
- TypeScript
- Java
- Go
- .NET
const emails = {
provider: 'smtp',
smtp: {
host: 'smtp.elasticemail.com',
port: '2524',
sender_email: 'noreply@ductape.app',
auth: {
user: 'fikayo@ductape.app',
pass: '***'
},
secure: false,
tls: {
rejectUnauthorized: false
}
}
};
Map<String, Object> emails = Map.of(
"provider", "smtp",
smtp: Map.of(
"host", "smtp.elasticemail.com",
"port", "2524",
"sender_email", "noreply@ductape.app",
auth: Map.of(
"user", "fikayo@ductape.app",
"pass", "***"
),
"secure", false,
tls: Map.of(
"rejectUnauthorized", false
)
)
);
emails := map[string]any{
"provider": "smtp",
smtp: {
"host": "smtp.elasticemail.com",
"port": "2524",
"sender_email": "noreply@client.app",
auth: {
"user": "fikayo@client.app",
"pass": "***"
},
"secure": false,
tls: {
"rejectUnauthorized": false
}
}
};
var emails = new Dictionary<string, object?>
{
["provider"] = "smtp",
smtp: {
["host"] = "smtp.elasticemail.com",
["port"] = "2524",
["sender_email"] = "noreply@ductape.app",
auth: {
["user"] = "fikayo@ductape.app",
["pass"] = "***"
},
["secure"] = false,
tls: {
["rejectUnauthorized"] = false
}
}
};
SendGrid Configuration
| Field | Type | Required | Description |
|---|---|---|---|
sendgrid.apiKey | string | Yes | SendGrid API key. |
sendgrid.sender_email | string | Yes | From email address. |
SendGrid Example
- TypeScript
- Java
- Go
- .NET
const emails = {
provider: 'sendgrid',
sendgrid: {
apiKey: 'SG.xxxxxxxxxxxxxxxxxxxxx',
sender_email: 'noreply@ductape.app'
}
};
Map<String, Object> emails = Map.of(
"provider", "sendgrid",
sendgrid: Map.of(
"apiKey", "SG.xxxxxxxxxxxxxxxxxxxxx",
"sender_email", "noreply@ductape.app"
)
);
emails := map[string]any{
"provider": "sendgrid",
sendgrid: {
"apiKey": "SG.xxxxxxxxxxxxxxxxxxxxx",
"sender_email": "noreply@client.app"
}
};
var emails = new Dictionary<string, object?>
{
["provider"] = "sendgrid",
sendgrid: {
["apiKey"] = "SG.xxxxxxxxxxxxxxxxxxxxx",
["sender_email"] = "noreply@ductape.app"
}
};
Mailgun Configuration
| Field | Type | Required | Description |
|---|---|---|---|
mailgun.apiKey | string | Yes | Mailgun API key. |
mailgun.domain | string | Yes | Mailgun domain. |
mailgun.sender_email | string | Yes | From email address. |
mailgun.region | string | Optional | 'us' or 'eu' (default: 'us'). |
Mailgun Example
- TypeScript
- Java
- Go
- .NET
const emails = {
provider: 'mailgun',
mailgun: {
apiKey: 'key-xxxxxxxxxxxxxxxxxxxxx',
domain: 'mg.ductape.app',
sender_email: 'noreply@ductape.app',
region: 'eu' // Optional - for EU region
}
};
Map<String, Object> emails = Map.of(
"provider", "mailgun",
mailgun: Map.of(
"apiKey", "key-xxxxxxxxxxxxxxxxxxxxx",
"domain", "mg.ductape.app",
"sender_email", "noreply@ductape.app",
"region", "eu" // Optional - for EU region
)
);
emails := map[string]any{
"provider": "mailgun",
mailgun: {
"apiKey": "key-xxxxxxxxxxxxxxxxxxxxx",
"domain": "mg.client.app",
"sender_email": "noreply@client.app",
"region": "eu" // Optional - for EU region
}
};
var emails = new Dictionary<string, object?>
{
["provider"] = "mailgun",
mailgun: {
["apiKey"] = "key-xxxxxxxxxxxxxxxxxxxxx",
["domain"] = "mg.ductape.app",
["sender_email"] = "noreply@ductape.app",
["region"] = "eu" // Optional - for EU region
}
};
Postmark Configuration
| Field | Type | Required | Description |
|---|---|---|---|
postmark.serverToken | string | Yes | Postmark server token. |
postmark.sender_email | string | Yes | From email address. |
Postmark Example
- TypeScript
- Java
- Go
- .NET
const emails = {
provider: 'postmark',
postmark: {
serverToken: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
sender_email: 'noreply@ductape.app'
}
};
Map<String, Object> emails = Map.of(
"provider", "postmark",
postmark: Map.of(
"serverToken", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"sender_email", "noreply@ductape.app"
)
);
emails := map[string]any{
"provider": "postmark",
postmark: {
"serverToken": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"sender_email": "noreply@client.app"
}
};
var emails = new Dictionary<string, object?>
{
["provider"] = "postmark",
postmark: {
["serverToken"] = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
["sender_email"] = "noreply@ductape.app"
}
};
Brevo Configuration
| Field | Type | Required | Description |
|---|---|---|---|
brevo.apiKey | string | Yes | Brevo API key. |
brevo.sender_email | string | Yes | From email address. |
brevo.sender_name | string | Optional | Sender display name. |
Brevo Example
- TypeScript
- Java
- Go
- .NET
const emails = {
provider: 'brevo',
brevo: {
apiKey: 'xkeysib-xxxxxxxxxxxxxxxxxxxxx',
sender_email: 'noreply@ductape.app',
sender_name: 'Ductape Notifications'
}
};
Map<String, Object> emails = Map.of(
"provider", "brevo",
brevo: Map.of(
"apiKey", "xkeysib-xxxxxxxxxxxxxxxxxxxxx",
"sender_email", "noreply@ductape.app",
"sender_name", "Ductape Notifications"
)
);
emails := map[string]any{
"provider": "brevo",
brevo: {
"apiKey": "xkeysib-xxxxxxxxxxxxxxxxxxxxx",
"sender_email": "noreply@client.app",
"sender_name": "Ductape Notifications"
}
};
var emails = new Dictionary<string, object?>
{
["provider"] = "brevo",
brevo: {
["apiKey"] = "xkeysib-xxxxxxxxxxxxxxxxxxxxx",
["sender_email"] = "noreply@ductape.app",
["sender_name"] = "Ductape Notifications"
}
};
EmailProvider Enum Values
| Enum Value | Description |
|---|---|
smtp | Traditional SMTP email server |
sendgrid | SendGrid email service |
mailgun | Mailgun email service |
postmark | Postmark email service |
brevo | Brevo (formerly Sendinblue) service |
Callback Notifications
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Callback URL (use :param for dynamic segments). |
method | HttpMethods | Yes | HTTP method. |
auth.headers | object | Optional | Key-value headers. |
auth.body | object | Optional | Key-value body values. |
auth.query | object | Optional | Query parameters. |
auth.params | object | Optional | URL params. |
Example
- TypeScript
- Java
- Go
- .NET
const callbacks = {
url: 'https://test.apicall.com/send-message',
method: HttpMethods.POST,
auth: {
headers: { Authorization: "Bearer token" },
body: {},
query: {},
params: {}
}
};
Map<String, Object> callbacks = Map.of(
"url", "https://test.apicall.com/send-message",
method: HttpMethods.POST,
auth: Map.of(
headers: Map.of( "Authorization", "Bearer token" ),
body: Map.of(),
query: Map.of(),
params: Map.of()
)
);
callbacks := map[string]any{
"url": "https://test.apicall.com/send-message",
method: HttpMethods.POST,
auth: {
headers: { "Authorization": "Bearer token" },
body: {},
query: {},
params: {}
}
};
var callbacks = new Dictionary<string, object?>
{
["url"] = "https://test.apicall.com/send-message",
method: HttpMethods.POST,
auth: {
headers: { ["Authorization"] = "Bearer token" },
body: {},
query: {},
params: {}
}
};
SMS Notifications
Ductape supports 3 SMS providers: Twilio, Plivo, and Vonage (Nexmo). You configure them by setting the appropriate fields based on the provider.
| Field | Type | Required | Description |
|---|---|---|---|
provider | SmsProvider | Yes | SMS service provider. |
accountSid | string | For Twilio | Twilio Account SID. |
authToken | string | For Twilio | Twilio Auth Token. |
apiSecret | string | For Nexmo | Nexmo API Secret. |
apiKey | string | For Plivo/Nexmo | API Key for provider. |
sender | string | Yes | Sender phone number or ID. |
Example
- TypeScript
- Java
- Go
- .NET
const sms = {
provider: 'twilio',
accountSid: 'ACxxxxxxxxxx',
authToken: 'xxxxxxxx',
sender: '+1415xxxxxxx'
};
Map<String, Object> sms = Map.of(
"provider", "twilio",
"accountSid", "ACxxxxxxxxxx",
"authToken", "xxxxxxxx",
"sender", "+1415xxxxxxx"
);
sms := map[string]any{
"provider": "twilio",
"accountSid": "ACxxxxxxxxxx",
"authToken": "xxxxxxxx",
"sender": "+1415xxxxxxx"
};
var sms = new Dictionary<string, object?>
{
["provider"] = "twilio",
["accountSid"] = "ACxxxxxxxxxx",
["authToken"] = "xxxxxxxx",
["sender"] = "+1415xxxxxxx"
};
SmsProvider Enum Values
| Enum Value | Description |
|---|---|
twilio | Twilio SMS service |
nexmo | Nexmo (Vonage) SMS service |
plivo | Plivo SMS service |
Notes
- You can configure one or all notification channels in each environment.
- Push Notifications support only one type per environment either Expo or Firebase.
- SMS providers require specific credential fields ensure you supply what's needed based on your chosen provider.