Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlexSteele's avatar

API, WebHook, or Cron Job?

Hello! I have some cool things happening at endpoints which are already set up in routes. A nice JSON import that is working pretty sweetly. However, I have not successfully automated it yet (hitting a button to get to the endpoint) and I am considering best practices. In order to hit this endpoint, I really want security so to hit the 'manual' trigger the user has to be logged in with higher security. Obviously the other software that generates this lovely JSON is not going to be signed in. I have it placing the JSON in the right spot, I just need to tell Laravel to scoop it up. Is there any way to have a cron job hit a protected endpoint without forcing a sign in? Should I shift all of this to API routes instead, and if so, is there a tutorial on setting up REST API from scratch because I think I need to review all the basic materials at least a couple of times. Also, in I did try to set up a kernel console schedule, and it claims to have worked, but nothing really happened. testing at one minute, would fall back to 15.

$schedule->command('runMe')->everyMinute()->thenPing('https://www.mysite.com/storage/hiddenspot/endpoint');

Once again, thanks for taking a moment to read this question.

0 likes
2 replies
webrobert's avatar
Level 51

Well. When there is a user use a browser/web or api endpoint. Or a webhook if it is triggered by a third-party and a command if otherwise.

If you make the code into a job/action then any of the fore-mentioned can call on the action.

For webhooks, and the sort I recently wrote a signed url to keep the secret url more secret for ical feeds.

1 like
AlexSteele's avatar

I really learned a lot from your comment, and now I know that it definitely need this to be a command. Thank you for the help!

1 like

Please or to participate in this conversation.