Eventing in Couchbase server to send an email once a document is created or updated

Hi Team,

I want to implement Eventing using Couchbase Server. I want to trigger an email/SMS every time a document gets updated/created. I referenced below URL for eventing examples, however none of these example contains
email thing or to make an http call.

Is it possible to trigger an email from Couchbase eventing function. Or other way, is it possible to make an HTTP call to an endpoint (that endpoint can trigger either email/sms basaed on request raised from Evening function).

My motive is to make an HTTP call from evening function when a change is encountered in any document of the bucket. And this http call will further point out to a logic which will trigger an email.

So to implement the same I have gone through below reference links:





However, I am not able to hit that endpoint from function using CURL method. Below is the eventing method that I have created in eventing service.

function OnUpdate(doc, meta) {

log(‘document’, doc);

var response = curl("http://localhost:52136/Home/NotifyUsers", { method: "POST", data: { "Id":"CUST00001" }} );

log(‘curl’, response);


function OnDelete(meta) {


Hi, did you find a solution to your problem?
I have to implement the same thing i.e. hit an endpoint when there is a change in the document in couchbase.

Hi @Madhumitha, Yes I was able to achieve this with Eventing, N1QL and CURL as below:

function OnUpdate(doc, meta) {

var customerName=doc.customerName;
var applicationNumber= doc.applicationNumber;

var query =“http://serverIP/AppNotifier/api/values?email=email@test.com&applicationStatus=Submitted&applicationId=” + applicationNumber + “&customerName=” + customerName;

var http = SELECT CURL($query, {“request”:“GET”, “header”: [“Content-Type: application/json”]});



Here http://serverIP/AppNotifier/api/values is an API which sends email and its hosted on another server.

Hey, thanks for your response.
I created a function in the ‘eventing’ tab in couchbase. I added the source bucket and metadata bucket. However, when i replace your query variable to hit my endpoint, I dont seem to get a response. So am I missing something else that should be added in order to achieve it?
Also, is there a way to find out what the document change is, and not just hit an endpoint on document change, but also exactly find out where the change occurred and what is the change?

You can try to change CURL() Function Access under settings. In my case I changed it to Unrestricted.
In Couchbase web console, go to settings -> under Cluster tab, on right hand side -> expand Advanced Query Settings menu. There will be option to changed CURL() Function Access:

1.) Restricted
2.) Unrestricted

Make sure, Unrestricted radio button is selected. This could be the possible issue in your case,

And regarding your query related to document change, I am not sure if we can identify where changed occurred, but we can find out what is the change. Even I had not implemented this but I am sure it will be there.