HTTP logoHTTP BEGINNER

HTTP Methods

HTTP methods cheat sheet covering GET, POST, PUT, PATCH, DELETE with idempotency rules, request body syntax, and REST API examples.

12 min read
httprestapimethodscrudweb

Other HTTP Sheets

CRUD Methods

GET - Retrieve Resource

javascript
✅ Safe - doesn't modify data
💡 Use query params for filtering
🔍 Cacheable by default

POST - Create Resource

javascript
🆕 Creates new resources
⚠️ Not idempotent - multiple calls create multiple resources
📍 Should return 201 with Location header

PUT - Update/Replace Resource

javascript
🔄 Replaces entire resource
✅ Idempotent - same request produces same result
📝 Requires complete resource representation

PATCH - Partial Update

javascript
🔧 Updates only specified fields
💡 More efficient than PUT for small changes
⚠️ Can be idempotent depending on implementation

DELETE - Remove Resource

javascript
🗑️ Removes resources permanently
✅ Idempotent - deleting twice has same effect
💡 Usually returns 204 No Content

Other HTTP Methods

HEAD - Get Headers Only

javascript
📋 Same as GET but no body
💡 Useful for checking existence
⚡ Saves bandwidth

OPTIONS - Get Allowed Methods

javascript
🔍 Discovers API capabilities
✈️ Used for CORS preflight
📝 Returns Allow header

CONNECT & TRACE

javascript
🚇 CONNECT: For proxy tunneling
🔍 TRACE: Debugging (security risk)
⚠️ Usually disabled in production

Method Properties

Safety & Idempotency

javascript
🛡️ Safe = no side effects
🔄 Idempotent = same result on retry
💡 Important for caching and retry logic

More HTTP Cheat Sheets