Passing an API token to Particle Webhook

Hello,
I have been utilizing Particle Webhooks to pass data off to Ubidots for visualization. An issue is arising however because all my webhooks contain the same token in the X-Auth-Token header and I am hitting the rate limit for that token.

I want to switch over to using a unique device token but have no idea how to pass that off and use it in the webhook. A key is able to be stored on each device, the unknown is how to send it to the webhook in a way that it can be utilized.

Yes, this is possible, assuming:

  • Your access token is small enough to fit in the publish (typically 1024 character) along with your data.
  • Your published data is in JSON format.

When you create your webhook, it can contain mustache templates, which are described in the link above. They look like {{{token}}} and there are some built-in ones like {{{PARTICLE_EVENT_VALUE}}}

These work in all fields, not just the data. Instead of hardcoding the token in your webhook, you can pass it from the device in the token key/value pair and use {{{token}}} instead of the hardcoded value in your webhook.

2 Likes

@rickkas7 thanks for the reply!
I’m quite new to this and not easily able to test changes so to clarify if i pass
image
and then in a particle webhook I have
image
this will work? our tech guy seemed to think values couldn’t be passed in the header so I want to double check before asking him to try it out

Yes, assuming token is passed in the JSON from the device, that’s exactly how you’d do it. The templates like {{{token}}} work all of the headers, and the URL.

1 Like

Hey! you can test your changes with this tool:

Basically, they give you a URL where you can send your webhooks and the site tells you the headers and body of the message received. I use it all the time when I get in trouble with webhooks.
Best

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.