Where do I place the API key in the Webhook settings?

Hello everyone, I’m working on a project that involves webhooks, but I’m kind of new to the particle platform.

I’m following the tutorial and I’m a bit confused where should I place the copied api_key from Thingspeak. The tutorial states to copy the api key and the channel ID. I understand how the webhook fields work, however I don’t see where the api key is placed, should I substitute YOUR_API_KEY with the api key itself? Also I would like to know if I have to do something with the channel ID or it is already covered by the api key.

Thank you :grinning:

The answer depends on how you intend to use the webhook.
The common use case (for myself anyway) is to send the ThingSpeak API Write key with every publish.
That way, you will only need 1 webhook to send data to any ThingSpeak Channel.

This Post/Thread may help you:

The Webhook definition is a few posts below it.

1 Like

Cool, thank you for the quick answer! That is indeed what I was looking for, although I wanted to follow the tutorial to understand the concept first. I was confused because in the tutorial the API key seems not to be used anywhere, nor even in the firmware.

So, to see if I really got it: you are formating the data field in such a way that it sends the API key and the values you need together and then that is “parsed” as different fields, right?

It appears that the Particle Docs show you how to create a webhook for an individual ThingSpeak Channel.
You would Type your API Write Key into the Webhook Definition:
Any of your Particle Devices that uses that Webhook would be updating that specific ThingSpeak Channel.

A Different Method:

But in the Shared file that I linked to thingspeak-sample.ino, you send the API Write Key inside each Publish:
Note: you replace your API Write Key at the top const char * myWriteAPIKey = "xxxxxxxxxxxxxxxx";
Then, each publish can update (1) Field, or multiple (up to all 8 Fields) per publish.
The sample code sends Field1, Field2, and the API Key.

If you create the WebHook as per the thingspeak-sample.ino, it allows you to use a Switch/Case in your firmware and update 100’s of different ThingSpeak channels from a Particle Device using only 1 webhook.


All clear, thank you very much for the help!