Skip to content

Examples

Copy-paste recipes for common notification patterns.

Welcome Email

Send a welcome message when a user signs up.

Event: welcome

Template variables: contact.name, contact.email

bash
curl -X POST https://api.sendivent.com/v1/send/welcome \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": {
      "email": "alice@example.com",
      "name": "Alice"
    }
  }'
typescript
await sendivent
  .event('welcome')
  .to({ email: 'alice@example.com', name: 'Alice' })
  .send()
python
sendivent \
  .event('welcome') \
  .to({ 'email': 'alice@example.com', 'name': 'Alice' }) \
  .send()
php
$sendivent
  ->event('welcome')
  ->to(['email' => 'alice@example.com', 'name' => 'Alice'])
  ->send();

Template:

handlebars
Hi {{contact.name}}, welcome to Acme!

Notes:

  • Contact is created automatically if it doesn't exist
  • name is stored on the contact for future sends

Email Verification

Send a magic link to verify an email address.

Event: verify-email

Template variables: link, expires

bash
curl -X POST https://api.sendivent.com/v1/send/verify-email \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "payload": {
      "link": "https://app.example.com/verify?token=abc123",
      "expires": "24 hours"
    }
  }'
typescript
await sendivent
  .event('verify-email')
  .to('user@example.com')
  .payload({
    link: 'https://app.example.com/verify?token=abc123',
    expires: '24 hours'
  })
  .send()
python
sendivent \
  .event('verify-email') \
  .to('user@example.com') \
  .payload({
    'link': 'https://app.example.com/verify?token=abc123',
    'expires': '24 hours'
  }) \
  .send()
php
$sendivent
  ->event('verify-email')
  ->to('user@example.com')
  ->payload([
    'link' => 'https://app.example.com/verify?token=abc123',
    'expires' => '24 hours'
  ])
  ->send();

Template:

handlebars
Click to verify your email: {{link}}

This link expires in {{expires}}.

Notes:

  • Generate a unique token server-side before sending
  • Set a short expiration (15-60 min) for security

Password Reset

Send a password reset link.

Event: password-reset

Template variables: link, expires

bash
curl -X POST https://api.sendivent.com/v1/send/password-reset \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "payload": {
      "link": "https://app.example.com/reset?token=xyz789",
      "expires": "1 hour"
    }
  }'
typescript
await sendivent
  .event('password-reset')
  .to('user@example.com')
  .payload({
    link: 'https://app.example.com/reset?token=xyz789',
    expires: '1 hour'
  })
  .send()
python
sendivent \
  .event('password-reset') \
  .to('user@example.com') \
  .payload({
    'link': 'https://app.example.com/reset?token=xyz789',
    'expires': '1 hour'
  }) \
  .send()
php
$sendivent
  ->event('password-reset')
  ->to('user@example.com')
  ->payload([
    'link' => 'https://app.example.com/reset?token=xyz789',
    'expires' => '1 hour'
  ])
  ->send();

Template:

handlebars
Reset your password: {{link}}

This link expires in {{expires}}.

Notes:

  • Always verify the user exists before generating a reset token
  • Invalidate the token after use

2FA Code via SMS

Send a verification code over SMS.

Enable keyboard auto-fill

Configure your OTP domain in Settings → General to enable mobile keyboard auto-fill. See OTP Auto-Fill for details.

Event: verification

Template variables: code

bash
curl -X POST https://api.sendivent.com/v1/send/verification/sms \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+14155551234",
    "payload": {
      "code": "847291"
    }
  }'
typescript
await sendivent
  .event('verification')
  .channel('sms')
  .to('+14155551234')
  .payload({ code: '847291' })
  .send()
python
sendivent \
  .event('verification') \
  .channel('sms') \
  .to('+14155551234') \
  .payload({ 'code': '847291' }) \
  .send()
php
$sendivent
  ->event('verification')
  ->channel('sms')
  ->to('+14155551234')
  ->payload(['code' => '847291'])
  ->send();

Template:

Your code is {{code}}. Valid for 10 minutes.

Notes:

  • Forces SMS channel, bypassing auto-routing
  • Phone must be E.164 format (+ and country code)

Invoice Email

Send an invoice with custom subject and reply-to.

Event: invoice

Template variables: invoice_id, amount, due_date

bash
curl -X POST https://api.sendivent.com/v1/send/invoice \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "customer@example.com",
    "payload": {
      "invoice_id": "INV-2024-001",
      "amount": "$299.00",
      "due_date": "January 15, 2025"
    },
    "overrides": {
      "email": {
        "subject": "Invoice INV-2024-001 - $299.00 due",
        "reply_to": "billing@yourcompany.com"
      }
    }
  }'
typescript
await sendivent
  .event('invoice')
  .to('customer@example.com')
  .payload({
    invoice_id: 'INV-2024-001',
    amount: '$299.00',
    due_date: 'January 15, 2025'
  })
  .overrides({
    email: {
      subject: 'Invoice INV-2024-001 - $299.00 due',
      reply_to: 'billing@yourcompany.com'
    }
  })
  .send()
python
sendivent \
  .event('invoice') \
  .to('customer@example.com') \
  .payload({
    'invoice_id': 'INV-2024-001',
    'amount': '$299.00',
    'due_date': 'January 15, 2025'
  }) \
  .overrides({
    'email': {
      'subject': 'Invoice INV-2024-001 - $299.00 due',
      'reply_to': 'billing@yourcompany.com'
    }
  }) \
  .send()
php
$sendivent
  ->event('invoice')
  ->to('customer@example.com')
  ->payload([
    'invoice_id' => 'INV-2024-001',
    'amount' => '$299.00',
    'due_date' => 'January 15, 2025'
  ])
  ->overrides([
    'email' => [
      'subject' => 'Invoice INV-2024-001 - $299.00 due',
      'reply_to' => 'billing@yourcompany.com'
    ]
  ])
  ->send();

Template:

handlebars
Invoice {{invoice_id}}

Amount: {{amount}}
Due: {{due_date}}

Notes:

  • overrides.email.subject replaces the template's default subject
  • Also supports cc and bcc

Slack Deployment Alert

Notify a channel when a deployment completes.

Event: deployment

Template variables: service, version, status, url

bash
curl -X POST https://api.sendivent.com/v1/send/deployment/slack \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "#engineering",
    "payload": {
      "service": "api-gateway",
      "version": "2.4.1",
      "status": "success",
      "url": "https://github.com/acme/api/releases/tag/v2.4.1"
    }
  }'
typescript
await sendivent
  .event('deployment')
  .channel('slack')
  .to('#engineering')
  .payload({
    service: 'api-gateway',
    version: '2.4.1',
    status: 'success',
    url: 'https://github.com/acme/api/releases/tag/v2.4.1'
  })
  .send()
python
sendivent \
  .event('deployment') \
  .channel('slack') \
  .to('#engineering') \
  .payload({
    'service': 'api-gateway',
    'version': '2.4.1',
    'status': 'success',
    'url': 'https://github.com/acme/api/releases/tag/v2.4.1'
  }) \
  .send()
php
$sendivent
  ->event('deployment')
  ->channel('slack')
  ->to('#engineering')
  ->payload([
    'service' => 'api-gateway',
    'version' => '2.4.1',
    'status' => 'success',
    'url' => 'https://github.com/acme/api/releases/tag/v2.4.1'
  ])
  ->send();

Template:

*{{service}}* deployed to {{version}} - {{status}}
<{{url}}|View release>

Notes:

  • Forces Slack channel, bypassing auto-routing
  • Public channels work immediately; private channels require app invite
  • Send to #channel or channel ID (C12345678)

Support Reply via SMS

Send an SMS that appears to come from a support agent's phone.

Event: support-reply

Template variables: message

bash
curl -X POST https://api.sendivent.com/v1/send/support-reply/sms \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+14155551234",
    "from": "+46701234567",
    "payload": {
      "message": "Hi! Just following up on your request. Let me know if you need anything."
    }
  }'
typescript
await sendivent
  .event('support-reply')
  .channel('sms')
  .to('+14155551234')
  .from('+46701234567')
  .payload({
    message: 'Hi! Just following up on your request. Let me know if you need anything.'
  })
  .send()
python
sendivent \
  .event('support-reply') \
  .channel('sms') \
  .to('+14155551234') \
  .from_('+46701234567') \
  .payload({
    'message': 'Hi! Just following up on your request. Let me know if you need anything.'
  }) \
  .send()
php
$sendivent
  ->event('support-reply')
  ->channel('sms')
  ->to('+14155551234')
  ->from('+46701234567')
  ->payload([
    'message' => 'Hi! Just following up on your request. Let me know if you need anything.'
  ])
  ->send();

Template:

{{message}}

Notes:

  • Forces SMS channel, bypassing auto-routing
  • Uses custom sender — the from number must be verified

Multi-Language Welcome

Send welcome emails in the user's preferred language.

Event: welcome

Languages configured: en, sv, de

bash
curl -X POST https://api.sendivent.com/v1/send/welcome \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "anders@example.com",
    "language": "sv",
    "payload": {
      "name": "Anders"
    }
  }'
typescript
await sendivent
  .event('welcome')
  .to('anders@example.com')
  .language('sv')
  .payload({ name: 'Anders' })
  .send()
python
sendivent \
  .event('welcome') \
  .to('anders@example.com') \
  .language('sv') \
  .payload({ 'name': 'Anders' }) \
  .send()
php
$sendivent
  ->event('welcome')
  ->to('anders@example.com')
  ->language('sv')
  ->payload(['name' => 'Anders'])
  ->send();

Notes:

  • Create language variants for your event in the dashboard first
  • Uses ISO 639-1 codes: en, sv, de, fr, etc.
  • Falls back to default language if the requested variant doesn't exist

See Also

  • Events — Create events in the dashboard
  • Templates — Handlebars syntax and helpers
  • Contacts — User data and the to field
  • Routing — Channel selection logic

Released under the MIT License.