BigCommerce – Creating a WebHook

I couldn’t find any reliable C# examples on how to create a webhook using BigCommerce’s API so I thought I’d share my solution. The example code below will create a webhook when an order is created in your BigCommerce store.

//BigCommerce Authorization
string clientID = "<your_client_id>";              
string token = "<your_token>";
string storeHash = "<your_store_hash>";
string resourcePath = "hooks";

string baseURL = "" + storeHash + "/v2/" + resourcePath;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(baseURL);
req.AllowAutoRedirect = true;
req.ContentType = "application/json";
req.Accept = "application/json";
req.Method = "POST";

req.Headers.Add("X-Auth-Client", clientID);
req.Headers.Add("X-Auth-Token", token);             
//send scope and destination as json
using (var streamWriter = new StreamWriter(req.GetRequestStream()))
    string json = "{\"scope\":\"store/order/created\"," +


string jsonResponse = null;
using (WebResponse resp = req.GetResponse())
    if (req.HaveResponse && resp != null)
        using (var reader = new StreamReader(resp.GetResponseStream()))
            jsonResponse = reader.ReadToEnd();



Listener is a .NET web service.

public void orders()
Context.Request.InputStream.Position = 0;
string payload = new System.IO.StreamReader(Context.Request.InputStream).ReadToEnd();
//process payload

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Do the Math      

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: