I'm designing an API that a social network app will consume. I need to manage friend requests between users.

I have this endpoint:

POST /users/{userId}/friend-requests 

{ requesterId: string }

that is called when requesterId wants to be a friend of userId. It returns a FriendRequest:

    id: string,
    requesterId: string,
    requesteeId: string,
    createdOn: date

When userId log in, it will fetch pending friend requests using endpoint below:

GET /users/{userId}/friend-requests?status=PENDING

that will return a FriendRequest array. So, that endpoint return incomming friend requests, i.e. those requests where userId is the requestee.

How should I design the endpoint to fetch the outgoing friend requests? Should it be somethig like this?

GET /users/{userId}/friend-requests/incoming
GET /users/{userId}/friend-requests/outgoing

Is that a good approach?

  • 3
    I don't see anything wrong with that approach. Commented Aug 17, 2018 at 10:54
  • I use similar endpoints (nothing to do with social networks) at work. No one has jumped off the roof yet. :) Commented Aug 17, 2018 at 11:26
  • if you want to keep the look of your incoming requests(namely GET /users/{userId}/friend-requests?status=PENDING) you could use GET /users/{userId}/friend-requests?status=AWAITING as well Commented Aug 17, 2018 at 12:57
  • While admittedly I know nothing about your model, I would use a nested 'event': {action:[ACCEPTED, REJECTED], timestamp:"yyyy-mm-dd 12:30pm utc"} instead of an enum in the request status. pending would be a null value.
    – JoseHdez_2
    Commented Aug 17, 2018 at 17:53

1 Answer 1


The approach seems fine. However, to give a complete answer, here is what I would also consider.

Maybe make the ‘direction’ of the friend request a filter, so you can say


or, closer to an implementation:

  • That was just my thought: From a ressource perspective, there is no difference between befriending-requests. incoming and outgoing are no "material" difference, only a different attribute. Commented Aug 17, 2018 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.