Skip to content

no-create-verb-in-post-path

POST routes name their collection instead of ending in a create, add or new segment.

Why

The HTTP method already states the action. A trailing create, add or new segment turns a resource API into ad hoc RPC names, so clients cannot predict paths and PUT, PATCH and DELETE lose their pairing.

Fix

POST to the collection path, use PUT on the item path for an upsert and PATCH for a partial update.

Examples

Before — flagged A POST route repeats the verb in its path
api.py
from fastapi import APIRouter
router = APIRouter()
@router.post("/tickets/create")
async def create_ticket() -> None:
return None
After — preferred A POST route names its collection
api.py
from fastapi import APIRouter
router = APIRouter()
@router.post("/tickets")
async def create_ticket() -> None:
return None