Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
I don't know how to decide path of API on REST API in updating user information situation

PATCH /api/users/:id/email => user update email
PATCH /api/users/:id/nickname => user update nickname

As above, I designed path of API based on Rest API.
but, I have a question
I am using jwt
jwt_token has id information of user
i think, better way is to use id of user in jwt_token instead of adding id of user to parameter.
but, I have a another question

PATCH /api/email => user update email
PATCH /api/nickname => user update nickname

if i use id of user in jwt_token, API path will change like a example above.
I think, it`s strange.
because, According to Rest API, use collection.(ex. users, books and so on..)
What is the right thing to do?
thank you for reading

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

"REST" is the architectural style on which the HTTP protocol was built. Every web page was intended to be "RESTful" and REST itself says nothing about what the API should look like. The query is obviously about modern APIs. A modern API MUST adhere to the RFCs and at the same time SHOULD adhere to common conventions. Common conventions make the REST API understandable to consumers. Further, I am answering with respect to modern APIs.


If you want to do partial update of resource, you should use PATCH method. There are two ways (RFCs) which you can use: RFC 6902 aka JSON Patch and RFC 7396 aka Merge Match. URL should target the updated resource (USER):

PATCH  /users/:id

BUT: You wrote that you want to update only authenticated user. In this case is common to use "special" URL:

PATCH /me/profile

You should send JSON body based on preferred RFC. In case if RFC 7396:

{
   "email": "new@email.value",
   "nickname": "newNickname"
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!