# Scheduling an API when DATA changes

**URL:** <https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302>\
**Category:** APIs\
**Created:** [May 22, 2020, 11:11pm UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302 "2020-05-22T23:11:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaffneyantonio](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gaffneyantonio/32/35409_2.png) [@gaffneyantonio](https://forum.bubble.io/u/gaffneyantonio)\
**Post date:** [May 22, 2020, 11:11pm UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302/1 "2020-05-22T23:11:37Z")

</div>

Hello everyone,

I have a workflow that schedules an API when a user books an appointment. The API is to charge for the appointment at a later time (30 minutes after).

Within that time, I intend to give the client of the appointment the option to include a tip after the appointment is finished. As of now, they have a default tip option but I don’t want to limit or increase the professional user’s earnings depending on the service provided. So therefore I also want the client to have the option to add a one time tip for a specific appointment and not use the default tip.

My issue is that when the workflow runs, it records the data from the appointment at the time it was booked and not when the API is scheduled to run and charge the client. Therefore, it’s not calculating the tip that the client submitted after the appointment was booked. And I don’t want to run a separate workflow to charge the user for the tip because Stripe will take another fee.

Does anyone have an idea of how I can achieve this?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ambroisedlg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ambroisedlg/32/61966_2.png) [@ambroisedlg](https://forum.bubble.io/u/ambroisedlg)\
**Post date:** [May 23, 2020, 6:29am UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302/2 "2020-05-23T06:29:16Z")

</div>

Hey @gaffneyantonio,

When the tip value changes, you could cancel the first scheduled API and re-schedule one with the correct tip. That means you would need to store the first Scheduled API’s ID in your Appointment data type to retrieve it

That way you would only have one transaction from Stripe

---

<div class="post-metadata">

**Author:** ![gaffneyantonio](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gaffneyantonio/32/35409_2.png) [@gaffneyantonio](https://forum.bubble.io/u/gaffneyantonio)\
**Post date:** [May 23, 2020, 4:15pm UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302/3 "2020-05-23T16:15:01Z")

</div>

Ok, I will give this a try. Thanks for chiming in.

---

<div class="post-metadata">

**Author:** ![gaffneyantonio](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gaffneyantonio/32/35409_2.png) [@gaffneyantonio](https://forum.bubble.io/u/gaffneyantonio)\
**Post date:** [May 23, 2020, 7:14pm UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302/4 "2020-05-23T19:14:28Z")

</div>

Where exactly do you capture the Scheduled API’s ID? Is it on the backend workflows? I’m having trouble understanding how exactly I would capture it.

---

<div class="post-metadata">

**Author:** ![ambroisedlg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ambroisedlg/32/61966_2.png) [@ambroisedlg](https://forum.bubble.io/u/ambroisedlg)\
**Post date:** [May 23, 2020, 7:23pm UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302/5 "2020-05-23T19:23:12Z")

</div>

@gaffneyantonio see the screenshots below:

 ![scheduledAPI.1](https://us1.discourse-cdn.com/bubble/original/3X/0/5/05f1127baafc5da8fc270943a56c4d1f7a90bc62.png)  
 ![scheduledAPI.2](https://us1.discourse-cdn.com/bubble/original/3X/e/9/e96df93bc45c0d4355f991dadc6942313f96d7ba.png)  
 ![scheduledAPI.3](https://us1.discourse-cdn.com/bubble/original/3X/c/d/cd08eb89ebe81e7f64c5b62531770aaaa4367f98.png)

---

<div class="post-metadata">

**Author:** ![gaffneyantonio](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gaffneyantonio/32/35409_2.png) [@gaffneyantonio](https://forum.bubble.io/u/gaffneyantonio)\
**Post date:** [May 23, 2020, 7:25pm UTC](https://forum.bubble.io/t/scheduling-an-api-when-data-changes/93302/6 "2020-05-23T19:25:52Z")

</div>

Ok, Gotcha. I got to this point, but thought it was incorrect. I guess i was expecting further options after ‘result of step…’

Thank you so much.
