Skip to content

Instantly share code, notes, and snippets.

@JoshMock
Last active July 10, 2023 03:28
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshMock/7185b8d9dd2669f0e3eabc511632068b to your computer and use it in GitHub Desktop.
Save JoshMock/7185b8d9dd2669f0e3eabc511632068b to your computer and use it in GitHub Desktop.
RESTful HTTP method cheat sheet

GET

  • fetch entity data only
  • does not alter any data, ever

POST

  • create a new entity with the data values provided in the body
  • if an entity already exists with these values, create it anyway (read: non-idempotent)
  • should not be used to alter an existing entity

PUT

  • if no entity ID is specified:
    • create a new entity with the data values provided in the body
    • if an entity already exists with these values, do nothing (read: idempotent)
  • if an entity ID is specified:
    • replace all entity data with the values specified in the body
    • delete any values from the existing entity that are not specified in the body

PATCH

  • update an existing entity with the data values provided in the body
  • any data values on the entity that don't have new values in the request body should be left as-is

DELETE

  • delete an entity

HEAD

  • check if an endpoint or entity exists without returning any data

Further reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment