🔌 API Testing

Professional API test cases with structured steps, headers, body, expected responses, and notes.

Screenshots & Postman Collection: Coming Soon…

GET Requests

1. Retrieve All Users

Method: GET

URL: https://api.example.com/users

Headers: Authorization: Bearer <token>, Accept: application/json

Expected Response: HTTP 200 OK

Response JSON
[
  {"id":1,"name":"Alice","email":"alice@example.com"},
  {"id":2,"name":"Bob","email":"bob@example.com"}
]

Notes: Should return all users. Pagination may apply.

2. Retrieve User by ID

Method: GET

URL: https://api.example.com/users/42

Headers: Authorization: Bearer <token>, Accept: application/json

Expected Response: HTTP 200 OK

Response JSON
{"id":42,"name":"Charlie","email":"charlie@example.com"}
Error Response
{"error":"User not found"}

Notes: If the user ID does not exist, should return 404 Not Found.

3. Filter Users by Role

Method: GET

URL: https://api.example.com/users?role=admin

Headers: Authorization: Bearer <token>, Accept: application/json

Expected Response: HTTP 200 OK

Response JSON
[{"id":10,"name":"Dana","role":"admin"}]

Notes: Only users with role 'admin' returned.

4. Paginated Products List

Method: GET

URL: https://api.example.com/products?page=2&limit=3

Headers: Authorization: Bearer <token>, Accept: application/json

Expected Response: HTTP 200 OK

Response JSON
{
  "products":[
    {"id":101,"name":"Wireless Mouse"},
    {"id":102,"name":"USB Keyboard"},
    {"id":103,"name":"HD Monitor"}
  ],
  "pagination":{"page":2,"limit":3,"total_items":9}
}

Notes: Ensure pagination metadata is correct.

5. Search Products by Keyword

Method: GET

URL: https://api.example.com/products?search=wireless

Headers: Authorization: Bearer <token>, Accept: application/json

Expected Response: HTTP 200 OK

Response JSON
[
  {"id":101,"name":"Wireless Mouse"},
  {"id":106,"name":"Wireless Charger"}
]

Notes: Case-insensitive search; empty results return empty array.

POST Requests

1. User Registration

Method: POST

URL: https://api.example.com/auth/register

Headers: Content-Type: application/json

Body: {"name":"Eve","email":"eve@example.com","password":"Pass123!"}

Expected Response: HTTP 201 Created

Response JSON
{"id":55,"name":"Eve","email":"eve@example.com"}

Notes: Email must be unique; missing fields return 400 Bad Request.

2. User Login

Method: POST

URL: https://api.example.com/auth/login

Body: {"email":"alice@example.com","password":"Pass123!"}

Expected Response: HTTP 200 OK

Response JSON
{"token":"abcdef123456","expires_in":3600}

Notes: Invalid password -> 401 Unauthorized.

3. Create Product

Method: POST

URL: https://api.example.com/products

Body: {"name":"Gaming Mouse","price":49.99}

Expected Response: HTTP 201 Created

Response JSON
{"id":201,"name":"Gaming Mouse","price":49.99}

Notes: Price must be numeric; missing fields -> 400 Bad Request.

4. Submit Feedback

Method: POST

URL: https://api.example.com/feedback

Body: {"userId":1,"message":"Great app!"}

Expected Response: HTTP 201 Created

Response JSON
{"id":301,"status":"Received"}

Notes: Empty message -> 400 Bad Request.

5. Password Reset

Method: POST

URL: https://api.example.com/auth/reset-password

Body: {"email":"alice@example.com"}

Expected Response: HTTP 200 OK

Response JSON
{"message":"Password reset email sent"}

Notes: Invalid email -> 404 Not Found.

PUT Requests

1. Update User Email

Method: PUT

URL: https://api.example.com/users/42

Body: {"email":"charlie_new@example.com"}

Expected Response: HTTP 200 OK

Response JSON
{"id":42,"name":"Charlie","email":"charlie_new@example.com"}

Notes: Email must be unique.

2. Update Product Price

Method: PUT

URL: https://api.example.com/products/101

Body: {"price":59.99}

Expected Response: HTTP 200 OK

Response JSON
{"id":101,"name":"Wireless Mouse","price":59.99}

Notes: Negative price -> 400 Bad Request.

3. Change User Role

Method: PUT

URL: https://api.example.com/users/10

Body: {"role":"editor"}

Expected Response: HTTP 200 OK

Response JSON
{"id":10,"name":"Dana","role":"editor"}

Notes: Invalid role -> 400 Bad Request.

4. Update Product Stock

Method: PUT

URL: https://api.example.com/products/102

Body: {"stock":25}

Expected Response: HTTP 200 OK

Response JSON
{"id":102,"name":"USB Keyboard","stock":25}

Notes: Stock cannot be negative.

5. Update User Profile

Method: PUT

URL: https://api.example.com/users/1

Body: {"name":"Alice Johnson","email":"alice_j@example.com"}

Expected Response: HTTP 200 OK

Response JSON
{"id":1,"name":"Alice Johnson","email":"alice_j@example.com"}

Notes: Email must be valid format.

DELETE Requests

1. Delete User by ID

Method: DELETE

URL: https://api.example.com/users/{user_id}

Headers: Authorization: Bearer <valid_token>

Expected Response: HTTP 204 No Content, Body: Empty

Notes: Deleting non-existent user -> 404 Not Found; Missing token -> 401 Unauthorized.

2. Delete Product by ID

Method: DELETE

URL: https://api.example.com/products/{product_id}

Expected Response: HTTP 204 No Content

Notes: Non-existent product -> 404 Not Found.

3. Delete Feedback

Method: DELETE

URL: https://api.example.com/feedback/{feedback_id}

Expected Response: HTTP 204 No Content

Notes: Only the user who submitted can delete feedback.

4. Delete Session

Method: DELETE

URL: https://api.example.com/sessions/{session_id}

Expected Response: HTTP 204 No Content

Notes: Invalid session -> 404 Not Found.

5. Delete Notification

Method: DELETE

URL: https://api.example.com/notifications/{notification_id}

Expected Response: HTTP 204 No Content

Notes: Notifications not found -> 404 Not Found.