# Trigger API Workflow from backend

**URL:** <https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453>\
**Category:** Need help\
**Created:** [September 10, 2023, 10:07am UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453 "2023-09-10T10:07:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![WildlyOptimistic](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@WildlyOptimistic](https://forum.bubble.io/u/WildlyOptimistic)\
**Post date:** [September 10, 2023, 10:07am UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/1 "2023-09-10T10:07:06Z")

</div>

Hi folks,

Please see my screenshot.

So I need to schedule an API workflow at the backend  
( No front-end action needed, no click the button whatsoever).

So in the backend workflow:  
1, I set up a “new database trigger event” called (DAILYRESET)  
2, I set up an API workflow called "dailyreset)  
3, In the Trigger’s step 1, I’ve chosen dailyreset as the API Workflow , and I’ve set a scheduled date (for testing purpose, I set it just 2 or 3 mins from my current time, so I can observe it).

But so far it is not working, the schedule change didn’t happen, it didn’t show in the log’s scheduler neither.

Am I doing anything wrong?

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/8/8/88a9439cdc878d823f58a39450a5f82308706ee0.png)

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/0/4/04a17ece5b42d864a95c31832e7e9ae6d8995f70.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 10, 2023, 10:59am UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/2 "2023-09-10T10:59:10Z")

</div>

I’m not sure why you’re using a database trigger event for this?..

But assuming that _is_ your intention (and you understand how Trigger events work)… has the required database change _actually_ been made to trigger the event?

Also, are you _sure_ you want to be running a workflow on a list, which then in turn is making changes to another list? (and what list is it making change to)?

Maybe explain your intended use case here…

also, isn’t it better to set the scheduled date in relation to the current date, for testing purposes (rather than to an arbitrary date)? Otherwise you’ll have to manually change it every time you want to test it.

---

<div class="post-metadata">

**Author:** ![WildlyOptimistic](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@WildlyOptimistic](https://forum.bubble.io/u/WildlyOptimistic)\
**Post date:** [September 10, 2023, 2:15pm UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/3 "2023-09-10T14:15:15Z")

</div>

But Adam, in this post you said I have to trigger it.

> [@Recurring Event: How to set](http://forum.bubble.io/t/recurring-event-how-to-set/282394/2):
>
> You trigger a recurring event from an admin page which sets it off and it will recur every X hours/days etc. Nothing in the backend happens without a trigger (and data triggers are triggered by a data change). Only when Current date time is 25th December for example will not run if you don’t configure it to because Bubble isn’t checking every second whether it’s 25th December for the sake of your workflow. See this post about recurring events / recursive workflows by @tylerboodman

1, So where should I trigger this event ? ( I don’t want to have a front-end activity for it , I only want it to happen naturally when the time is mid-night). So there’s no other changes in Database to trigger the event , it is only that “mid-night” (i.e. 12am) the solo factor triggering the workflow

2, Yes I want to run a workflow on all Users when it is mid-night (the workflow is to change one field’s value on all users when it is mid-night)

3, Yes your point on current time is understood and will follow.

Thanks  
W-O

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [September 10, 2023, 2:21pm UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/4 "2023-09-10T14:21:32Z")

</div>

> [@WildlyOptimistic](#):
>
> But Adam, in this post you said I have to trigger it.

Adam didn’t say that, I did… Trigger it means schedule it or set it to be recurring. What you’ve created is a database trigger which runs whenever a specific data is changed.

> [@WildlyOptimistic](#):
>
> So where should I trigger this event ?

From a button on an admin panel, use the ‘set recurring event’ action (but personally I use recursive backend workflows)

> [@WildlyOptimistic](#):
>
> Yes I want to run a workflow on all Users when it is mid-night (the workflow is to change one field’s value on all users when it is mid-night)

Have a scheduled workflow that has actions to

1. Schedules itself to run in 24 hours
2. Schedule API workflow on list of All Isers

The API workflow in 2. should make changes to This User.

Have you even looked at the diagram I linked by @tylerboodman which explains vary well how you can create a recursive workflow that runs daily?

---

<div class="post-metadata">

**Author:** ![WildlyOptimistic](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@WildlyOptimistic](https://forum.bubble.io/u/WildlyOptimistic)\
**Post date:** [September 10, 2023, 2:52pm UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/6 "2023-09-10T14:52:12Z")

</div>

Yes I looked but it has two WFs in his chart. and it also involves a button. So a button is a must ? Then I have to hide it from users, yea ?

Also in his chart , I understand why WF1 will also schedule another WF1 (it is like a looping) , But I cannot get my head around why WF2 needs to schedule another WF2.

I’d love to use recursive, but it also needs a button ? Cannot the database tell itself to kick it off when it is mid-night ? Isn’t the natural clock a better trigger than a button ?

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [September 10, 2023, 3:49pm UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/7 "2023-09-10T15:49:28Z")

</div>

> [@WildlyOptimistic](#):
>
> So a button is a must ? Then I have to hide it from users, yea ?

That’s why I told you to put it in your app’s admin panel. If you really don’t want a button you can kick it off with the WF API.

> [@WildlyOptimistic](#):
>
> Cannot the database tell itself to kick it off when it is mid-night ?

Would you check the clock every second of every day or would you set a reminder that tells you when to start doing something?

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 10, 2023, 4:23pm UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/8 "2023-09-10T16:23:01Z")

</div>

> [@WildlyOptimistic](#):
>
> But Adam, in this post you said I have to trigger it.

Yeah, you do need to trigger it… (how else would it start?)

But not with a database trigger event - that is something entirely different.

You don’t _have_ to use a button click to trigger it initially… you can use _any_ workflow event you like (including a database trigger event - although that wouldn’t make any sense in this context).

But logically, a Button Click is the simplest and most obvious way to do it.

> it is only that “mid-night” (i.e. 12am) the solo factor triggering the workflow

The time being midnight is not a factor in triggering this… it’s just the time you’ll schedule it to run at.

> Cannot the database tell itself to kick it off when it is mid-night ?

Database trigger events are caused by changes to data in the database… so, no.

---

<div class="post-metadata">

**Author:** ![WildlyOptimistic](https://avatars.discourse-cdn.com/v4/letter/w/278dde/32.png) [@WildlyOptimistic](https://forum.bubble.io/u/WildlyOptimistic)\
**Post date:** [September 11, 2023, 3:31pm UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/9 "2023-09-11T15:31:48Z")

</div>

Thank you guys @georgecollier @adamhholmes I will try around this weekend !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [November 19, 2023, 10:07am UTC](https://forum.bubble.io/t/trigger-api-workflow-from-backend/282453/10 "2023-11-19T10:07:11Z")

</div>

This topic was automatically closed after 70 days. New replies are no longer allowed.
