The 424 Failed Dependency HTTP status code indicates that a request failed because it relied on another request or operation that did not succeed. It is commonly used in APIs and WebDAV-based systems where actions depend on prior steps.
The server returns status code 424 when it cannot complete the current request due to a failed dependency. This status helps avoid partial updates and inconsistent system states.
// Sending a response with HTTP 424 Failed Dependency res.status(424).json({ error: "Failed Dependency", message: "Previous operation must succeed first" });The API responds with status code 424 and an explanatory message indicating which dependency failed.
Imagine a user registration flow where profile creation depends on account creation. If account creation fails, profile creation returns 424 Failed Dependency.
Step 1: Account Creation
Status: FAILEDStep 2: Profile Setup (Dependent)
// Example of dependent API logic if (!accountCreated) { return res.status(424).send("Account creation failed"); }