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

thesimons's avatar

API returns 404

Hello,

I tried to create my first API so I decided to create the route in the web.php file. Got a 419 due to CSRF.

So I followed a guide and installed api using

php artisan install:api

and into the api.php that appeared I placed my api

Route::domain('core.domain.com')->group(function () {
    Route::post('/process/rg', [RocketgateController::class, 'postback']);
});

However when I tried to call for it I get a 404 error.

What's wrong I'm doing? I have edited the real domain to domain.com for privacy to the client.

Thanks, S

0 likes
7 replies
tykus's avatar

Do you have the api segment in the full URL that you are trying to visit, e.g. https://core.domain.com/api/process/rg?

thesimons's avatar

@tykus Hello, sorry for the late reply. Yes, it has worked very well. Thanks again :)

thesimons's avatar

@tykus Uh no! I'm going to add it. Does it magically make the trick?

Thanks, S

tykus's avatar

@thesimons Whenever you define Routes in the api.php Routes file, by default, you are getting this prefix in the URL. Have you checked that it is working with that api segment?

Snapey's avatar

However when I tried to call for it I get a 404 error.

Are you using Post?

I would also remove the domain group.

reaz's avatar

Just to be sure, clear your route cache after you made changes to the route file.

Snapey's avatar

@reaz or better, never cache routes except in production deployment script.

Please or to participate in this conversation.