Question

RESThookes - using subscribe data in unsubscribe request

  • 23 June 2020
  • 2 replies
  • 1708 views

Hey there, I have what may be a simple question, but it’s been challenging to self-service an answer.

 

Scenario:

I’m creating our first Zapier integration. For now, I’m focusing on triggers, which correlate to several webhook types that our platform offers. Each webhook type gets its own specific trigger. I’m also using the visual/web builder as I’m not actually a developer myself.

 

Our Subscribe request:

{
"data":{
"attributes":{
"subscriptions":[
"course_completed_events" //corresponds to selected trigger
],
"url": bundle.targetUrl
}
}
}

 

Our system returns the following:

{
"data": {
"type": "webhook_endpoints",
"id": "3c0cd54b-e116-4dff-ad40-18958e59841b",
"attributes": {
"url": "URL here",
"subscriptions": [
"course_completed_events" //corresponds to selected trigger
]
}
}
}

 

The Unsubscribe request should look like this:

DELETE {baseURL}/webhook_endpoints/{id}

Where id is equal to the id returned in the Subscribe response (so in this example, it should be 3c0cd54b-e116-4dff-ad40-18958e59841b 

 

 

How do I get at that id so that my Unsubscribe functionality works?

I’ve read about using bundle.subscribeData, but logging bundle.subscribeData to the console always returns back undefined.

Do I have to explicitly store the ID? Can I do that? 

Any advice? Am I thinking about this the right way?

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +8

Hi @Northpass - Thanks for the detailed question and explanation! I feel like this is great context and I think our Support team will be thrilled to help further. I’ve escalated this issue to the Support team. Please stay tuned! 

Userlevel 7
Badge +12

@Northpass - The object that is returned from calling performSubscribe will be saved and can be accessed from bundle.subscribeData when Zapier calls performUnsubscribe.

In your case, given the following API output:

{
"data": {
"type": "webhook_endpoints",
"id": "3c0cd54b-e116-4dff-ad40-18958e59841b",
"attributes": {
"url": "URL here",
"subscriptions": ["course_completed_events"]
}
}
}

the id can be found in bundle.subscribeData.data.id