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

luddinus's avatar

Naming Api endpoints when two "Entities" are envolved.

Hi,

I pick "tips" channel but I'm don't know if it is the correct. Anyway:

I have users and offers, and users can apply to job offers.

How would you name the api?

POST api/users/{user_id}/offers/{offer_id}/apply
POST api/offers/{offer_id}/apply/{user_id}
...
POST api/offers/{offer_id}/apply // pass the user_id in request body { user_id: 1 }

I'm using the first one but it seems a little awkard to me.

Thx!

0 likes
2 replies
rawilk's avatar

I'd pass the user_id in the request body instead of putting it in the endpoint. IMO it's better to keep your endpoints as simple as possible.

2 likes
shez1983's avatar

yep

POST api/offers/{offer_id}/apply // pass the user_id in request body { user_id: 1 }

is the right way to go..

Please or to participate in this conversation.