How do you edit a product webhook?

I have found no way to edit a web hook short of downloading the existing webhook via something like https://api.particle.io/v1/products/:productid/webhooks/:webhookid?access_token=12345, editing the resulting JSON, and then using the CLI to recreate the webhook via particle webhook create createAlarm.json .

This works fine for non-product webhooks, but I cannot get the CLI particle webhook create to actually create a product webhook. It always creates a regular webhook.

I am including the product_id in the JSON definition.

Any ideas?

3 Likes

Hey! I’m going to tag in @jeiden from the Particle team to help answer that question.

Hey @blakevh,

Currently the CLI does not support creating product webhooks. You’d either have to hit the API directly and pass a product_id in the body of the request, or you can use the Console’s Webhook builder to create the product webhook.

Jeff

1 Like

I realize this is old but I had the same issue. I just wrote a quick script and used curl. Here’s my solution:

curl https://api.particle.io/v1/orgs/$ORG/products/$PRODUCT_ID/webhooks \
  -X POST \
  -H "Authorization:Bearer $AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "event": "'"$EVENT"'",
    "url": "https://123.execute-api.us-east-1.amazonaws.com/prod/particle-event-lambda",
    "headers": {
      "x-api-key": "$AWS_API_KEY"
    },
    "json": {
      "id": "{{PARTICLE_DEVICE_ID}}",
      "value": "{{PARTICLE_EVENT_VALUE}}",
      "event": "{{PARTICLE_EVENT_NAME}}"
    },
    "product_id": "$PRODUCT_ID",
    "requestType": "POST",
    "responseTopic": "{{PARTICLE_DEVICE_ID}}/hook-response/{{PARTICLE_EVENT_NAME}}"
  }'
2 Likes