Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda