Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
    • URL shortener
    • Ingesting data into storage systems
    • Storing application runtime logs
    • Deploying a web application using the Java Servlet API
    • Developing a Slack bot
    • Developing a Telegram bot
    • Developing a Telegram bot with AI agent support
    • Developing a custom integration in API Gateway
    • Developing CRUD APIs for movie services
    • Building a CI/CD pipeline in GitLab
    • GitLab Runner execution in Serverless Containers
    • Configuring CI/CD between Cloud Functions and SourceCraft
    • Configuring CI/CD between Cloud Functions and GitHub
    • Setting up CI/CD in SourceCraft to deploy an application in Serverless Containers using GitHub Actions
    • Working with an API gateway via WebSocket
    • Building an interactive serverless application using WebSocket
    • Automatically copying objects from one Object Storage bucket to another
    • Visualizing logs in Grafana using the Cloud Logging plugin
    • Canary release of Cloud Functions
    • Interactive debugging of Cloud Functions
    • Creating a Node.js function using TypeScript
    • Running a containerized app in Serverless Containers
    • Streaming Yandex Cloud Postbox events to Data Streams and analyzing them with DataLens
    • Using API Gateway to set up speech synthesis in SpeechKit
    • Connecting to YDB from a Cloud Functions function in Python
    • Connecting to a YDB database from a Cloud Functions function in Node.js
    • API Gateway protection with Smart Web Security
    • Deploying a web app with JWT authorization in API Gateway and authentication in Firebase
    • Automatic data upload to Yandex SpeechSense using Yandex Workflows
    • Configuring responses in Cloud Logging and Yandex Cloud Functions
    • Setting up Workflows integration with Tracker, YandexGPT, and Yandex Cloud Postbox
    • Developing functions in Functions Framework and deploying them to Yandex Serverless Containers
    • Creating a Yandex Cloud Postbox address and checking domain ownership with Terraform
    • Creating an AI agent with Yandex Cloud Functions
    • Configuring Postfix to send emails via Yandex Cloud Postbox
    • Yandex Cloud Postbox integration with external systems via webhooks

In this article:

  • Get your cloud ready
  • Required paid resources
  • Create service accounts
  • Create a static access key
  • Create a database in Managed Service for YDB
  • Create a data stream in Data Streams
  • Create Yandex Cloud Postbox resources
  • Create a Yandex Cloud Postbox configuration
  • Create a Yandex Cloud Postbox address
  • Pass a domain ownership check
  • Create Cloud Functions resources
  • Create a function
  • Create a trigger
  • Test the solution
  • How to delete the resources you created
  1. Serverless technologies
  2. Yandex Cloud Postbox integration with external systems via webhooks

Integrating Yandex Cloud Postbox with external systems using webhooks

Written by
Yandex Cloud
Updated at November 24, 2025
  • Get your cloud ready
    • Required paid resources
  • Create service accounts
  • Create a static access key
  • Create a database in Managed Service for YDB
  • Create a data stream in Data Streams
  • Create Yandex Cloud Postbox resources
    • Create a Yandex Cloud Postbox configuration
    • Create a Yandex Cloud Postbox address
    • Pass a domain ownership check
  • Create Cloud Functions resources
    • Create a function
    • Create a trigger
  • Test the solution
  • How to delete the resources you created

In this tutorial, you will set up streaming of Yandex Cloud Postbox events to Yandex Data Streams and triggering webhooks in external systems. To process and store data, you will use Yandex Cloud Functions and Yandex Managed Service for YDB.

You can implement this solution using the Yandex Cloud management console even if you have no coding skills.

To set up event streaming and processing:

  1. Get your cloud ready.
  2. Create service accounts.
  3. Create a static access key.
  4. Create a Managed Service for YDB.
  5. Create a data stream in Data Streams.
  6. Set up Yandex Cloud Postbox resources.
  7. Set up Cloud Functions resources.
  8. Test the solution.

If you no longer need the resources you created, delete them.

Get your cloud readyGet your cloud ready

Sign up for Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or create a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure.

Learn more about clouds and folders here.

Required paid resourcesRequired paid resources

The infrastructure support costs include:

  • Fee for YDB operations and data storage (see Yandex Managed Service for YDB pricing).
  • Data Streams data storage fee (see Yandex Data Streams pricing).
  • Fee for function invocation count, computing resources allocated to run the function, and outbound traffic (see Cloud Functions pricing).
  • Fee for using Yandex Cloud Postbox (see Yandex Cloud Postbox pricing).

Create service accountsCreate service accounts

Create two service accounts:

  • yds-functions to call Cloud Functions and write events to Data Streams.
  • postbox-user to send emails via Yandex Cloud Postbox.
  1. Create a yds-functions service account:

    Management console
    1. In the management console, select the folder where you are going to create your infrastructure.
    2. In the list of services, select Identity and Access Management and click Create service account.
    3. In the Name field, enter yds-functions for name.
    4. Click Add role and select the yds.editor and functions.functionInvoker roles.
    5. Click Create.
  2. Similarly, create a service account named postbox-user and assign the postbox.sender role to it.

Create a static access keyCreate a static access key

Create a static access key to use for sending emails:

Management console
  1. In the management console, select the folder where you are deploying your infrastructure.

  2. In the list of services, select Identity and Access Management and then select postbox-user from the list of service acounts. In the window that opens, do the following:

    1. In the top panel, click Create new key and select Create static access key.

    2. Click Create.

    3. Save the ID and secret key.

      Alert

      After you close this dialog, the key value will no longer be available.

Create a database in Managed Service for YDBCreate a database in Managed Service for YDB

To create a data stream for Yandex Cloud Postbox events, you need a Managed Service for YDB database. Create a serverless Managed Service for YDB database:

Management console
  1. In the management console, select the folder where you are deploying your infrastructure.
  2. In the list of services, select Managed Service for YDB and click Create a database.
  3. In the Name field, specify postbox-events-ydb.
  4. In the Database type field, select Serverless.
  5. Do not edit the other database settings. Click Create a database.

Wait for the database to start. While being created, your database will have the Provisioning status. Once it is ready for use, its status will change to Running.

Create a data stream in Data StreamsCreate a data stream in Data Streams

Create a data stream to log Yandex Cloud Postbox events:

Management console
  1. In the management console, select the folder where you are deploying your infrastructure.
  2. In the list of services, select Data Streams and click Create stream.
  3. In the Database field, select the postbox-events-ydb database you created earlier.
  4. In the Name field, enter the stream name: postbox-events-stream.
  5. In the Pricing Mode field, select Actual usage.
  6. Do not edit the other data stream settings. Click Create.

Wait for the stream to start. Once the stream is ready for use, its status will change from Creating to Active.

Create Yandex Cloud Postbox resourcesCreate Yandex Cloud Postbox resources

In Yandex Cloud Postbox, configure event logging to Data Streams, create a sender address, and verify your domain ownership.

Create a Yandex Cloud Postbox configurationCreate a Yandex Cloud Postbox configuration

Management console
  1. In the management console, select the folder where you are deploying your infrastructure.

  2. In the list of services, select Cloud Postbox.

  3. In the left-hand panel, select Configurations and click Create configuration.

  4. In the Name field, specify the configuration name: postbox-events-config.

  5. Under Subscriptions, click Add and fill out the form that opens:

    1. In the Name field, specify the subscription name: postbox-events-subscribe.
    2. In the Data stream field, select the data stream named postbox-events-stream.
    3. Toggle the Enabled option on to activate the subscription.
  6. Do not edit the other configuration settings. Click Create configuration.

Create a Yandex Cloud Postbox addressCreate a Yandex Cloud Postbox address

  1. Generate the privatekey.pem key to create a DKIM signature by running this command in the terminal:

    openssl genrsa -out privatekey.pem 2048
    

    Note

    openssl comes preinstalled in Linux and macOS. If using Windows, you need to install it manually. For more information, visit the project's website.

  2. Create a Yandex Cloud Postbox address:

    Management console
    1. In the management console, select the folder where you are deploying your infrastructure.
    2. In the list of services, select Cloud Postbox.
    3. In the left-hand panel, select Addresses and click Create address.
    4. In the Domain field, specify the domain you will use to send emails. You can use a domain of any level, as long as you own it.
    5. In the Selector field, specify a selector, e.g., postbox. Make sure to only use this selector in the resource record you create when verifying domain ownership.
    6. In the Configuration field, select postbox-events-config you previously created.
    7. In the Private key field, paste the contents of the privatekey.pem file from the previous step.
    8. Do not change the other address settings. Click Create address.
    9. Click the newly created address in the list that opens.
    10. Under Signature verification on the address info page, copy and save the TXT record from the Value field.

Pass a domain ownership checkPass a domain ownership check

To send emails, confirm domain ownership. After creating an address, DKIM signature settings will be generated on its page. Specify them as the values of the resource record you need to add to your domain zone. You can add a record with your registrar or in Yandex Cloud DNS if you have delegated your Yandex Cloud domain.

Example of creating a resource record in Yandex Cloud DNS

Management console
  1. In the management console, select the folder containing the address and your domain zone.

    If you do not have a public DNS zone yet, create one:

  2. Select Cloud DNS.

  3. Select your domain zone.

  4. Click Create record.

  5. In the Name field, specify the name portion generated when creating the address, omitting the domain in <selector>._domainkey format, e.g., postbox._domainkey.

    Note

    For other DNS services, you may need to copy the entire record. The final record must look like this: <selector>._domainkey.<domain>., e.g., postbox._domainkey.example.com..

  6. In the Type field, select TXT.

  7. Copy the contents of the Value field from the Signature verification section and paste it into the Data field. Note that the record value must be enclosed in quotes, for example:

    "v=DKIM1;h=sha256;k=rsa;p=M1B...aCA8"
    
  8. Click Create.

  9. Go to Cloud Postbox.

  10. Select the address you created.

  11. Click Verify address. If the record is correct, the verification status on the address page will change to Success.

DNS server responses are cached, so delays may occur when updating a resource record.

Create Cloud Functions resourcesCreate Cloud Functions resources

Create a function to send a webhook and a trigger to call that function upon event logging to the data stream.

Create a functionCreate a function

Python
JavaScript
  1. In the management console, select the folder where you are deploying your infrastructure.

  2. In the list of services, select Cloud Functions.

  3. Create a function:

    1. Click Create function.
    2. In the Name field, enter the function name: postbox-webhook.
    3. Click Create.
  4. Create a function version:

    1. In the Editor window that opens, select Python 3.12.

    2. Disable Add files with code examples.

    3. Click Continue.

    4. In the Method field, select Code editor.

    5. Create the following two files:

      • requirements.txt containing a list of required dependencies:

        requests
        
      • index.py containing the following function code:

        import requests
        
        # URL of the webhook to call
        WEBHOOK_URL = "<webhook_URL>"
        
        
        def handler(event, context):
            requests.post(WEBHOOK_URL, json=event)
        
            return {
                "statusCode": 200,
            }
        

        Where WEBHOOK_URL is the URL of the webhook to send the request to.

    6. In the Entry point field, specify index.handler.

    7. Under Parameters, specify:

      • Timeout: 10 seconds.
      • Memory: 128 MB.
    8. Do not edit the other function version settings. Click Save changes.

  1. In the management console, select the folder where you are deploying your infrastructure.

  2. In the list of services, select Cloud Functions.

  3. Create a function:

    1. Click Create function.
    2. In the Name field, enter the function name: postbox-webhook.
    3. Click Create.
  4. Create a function version:

    1. In the Editor window that opens, select Node.js 18.

    2. Disable Add files with code examples.

    3. Click Continue.

    4. In the Method field, select Code editor.

    5. Create a file named index.js with the function code:

      // URL of the webhook to call
      const WEBHOOK_URL = '<webhook_URL>'
      
      module.exports.handler = async function (event, context) {
          await fetch(WEBHOOK_URL, {
              method: 'POST',
              headers: {
                  'Content-Type': 'application/json',
              },
              body: JSON.stringify(event),
          });
      
          return {
              statusCode: 200,
          };
      };
      

      Where WEBHOOK_URL is the URL of the webhook to send the request to.

    6. In the Entry point field, specify index.handler.

    7. Under Parameters, specify:

      • Timeout: 10 seconds.
      • Memory: 128 MB.
    8. Do not edit the other function version settings. Click Save changes.

Create a triggerCreate a trigger

Management console
  1. In the management console, select the folder where you are deploying your infrastructure.
  2. In the list of services, select Cloud Functions.
  3. In the left-hand panel, select Triggers and click Create trigger.
  4. In the Name field, enter the trigger name: postbox-events-trigger.
  5. In the Type field, select Data Streams.
  6. In the Launched resource field, select Function.
  7. Under Data Streams settings, select the data stream named postbox-events-stream and the yds-functions service account.
  8. Under Function settings, select the postbox-webhook function and the yds-functions service account.
  9. Click Create trigger.

Test the solutionTest the solution

  1. Use the Yandex Cloud Postbox address and static access key you created earlier to send several test emails in any way you prefer.

  2. Make sure the emails were delivered by checking the mailbox you sent them to.

  3. Make sure the data about sent emails reaches the services:

    • Check the data stream:

      Management console
      1. In the management console, select the folder where you are deploying your infrastructure.

      2. In the list of services, select Data Streams.

      3. Select the data stream named postbox-events-stream.

      4. Navigate to the Data viewer tab.

        The charts should show email sending events.

    • View the function logs and trigger monitoring charts.

    • Make sure the webhooks for the sent email events were triggered in the external system.

After completing this tutorial, you will be able to trigger webhooks in external systems in response to Yandex Cloud Postbox email sending events.

How to delete the resources you createdHow to delete the resources you created

To stop paying for the resources you created:

  1. Delete the trigger invoking the function in Cloud Functions.
  2. Delete the function in Cloud Functions.
  3. Delete the stream in Data Streams.
  4. Delete the Managed Service for YDB database.
  5. Delete the Yandex Cloud Postbox address and configuration.
  6. Optionally, delete the service accounts.
  7. Optionally, delete the resource record and public DNS zone.

Was the article helpful?

Previous
Configuring Postfix to send emails via Yandex Cloud Postbox
Next
All tutorials
© 2025 Direct Cursus Technology L.L.C.