DELETE /resource/{id}/subresource
API Design

Meaning

Defines a REST API endpoint that removes a child resource belonging to a specific parent resource identified by its ID. Addresses the need to manage nested data lifecycles without orphaning references or deleting the parent. Triggered when designing CRUD endpoints for one-to-many relationships where the child has no independent identity outside the parent.

Primary Function

REST API design

Communicative Purpose

Enables clients to delete a specific sub-resource scoped under a parent resource using a single, predictable URL.

Pattern

DELETE /resource/{id}/subresource

Core Structure

DELETE /.../.../...

Função primária

REST API design

Propósito comunicativo

Enables clients to delete a specific sub-resource scoped under a parent resource using a single, predictable URL.

Situações de gatilho

REST API design: removing a comment from a blog post; E-commerce: deleting an item from a user's cart; Content management: removing a tag from an article

Contextos

REST APIs, web services, CRUD applications, microservices, Express.js, Flask, FastAPI, Spring Boot, Django REST Framework

Padrão

DELETE /resource/{id}/subresource

Estrutura central

DELETE /.../.../...

Slots de substituição

resource: string (parent collection name, plural noun); id: int or string (unique identifier of parent resource); subresource: string (child collection name, plural noun)

Colocados típicos

  • HTTP 204 No Content response
  • HTTP 404 Not Found handling
  • authentication/authorization middleware
  • ORM delete operations
  • cascade delete constraints
  • API versioning

Substituições comuns

  • DELETE /resource/{id}/subresource/{sub_id}: when the child has its own unique ID
  • POST /resource/{id}/subresource/delete: RPC-style fallback when DELETE verb is unsupported
  • PATCH /resource/{id}/subresource/{sub_id} with {active: false}: soft-delete pattern preserving audit trail

Erros comuns

Using POST instead of DELETE: violates REST semantics and breaks HTTP caching/proxy assumptions; Not verifying the subresource belongs to the parent: allows cross-tenant deletion via guessed IDs; Returning 200 with a body instead of 204: non-standard for idempotent DELETE; Omitting existence check: returns 204 even when nothing was deleted, masking client bugs; Using query parameters for resource IDs: breaks REST URL conventions and bookmarkability

Similar / contraste

DELETE /resource/{id}: deletes the parent itself, not a child; DELETE /resource/{id}/subresource/{sub_id}: targets a specific child by its own ID; POST /resource/{id}/subresource: creates a new child under the parent

Interferências

Coming from RPC/SOAP: may use POST with an action parameter like ?action=delete — REST maps the verb to the HTTP method itself; Coming from GraphQL: may expect a single mutation endpoint — REST uses distinct URL paths per resource hierarchy

Família do chunk

  • REST resource patterns
  • HTTP DELETE method
  • nested resource routes
  • RESTful API design
  • CRUD endpoint conventions

Nuance

When NOT to use: if the sub-resource has its own globally unique ID, address it directly at /resource/{id}/subresource/{sub_id} for clarity; Performance: typically a single indexed DELETE on a composite key (parent_id, child_id) — ensure the index exists; Boundary: if the parent does not exist, return 404 before attempting the child lookup to avoid leaking child existence

Efeito pragmático

Provides a clean, idempotent way to manage nested resource lifecycles, prevents orphaned records, and gives clients a predictable URL structure that composes well with parent resource caching.

Dica de memória

Like pulling a specific book off a numbered shelf in a library — you name the shelf (resource/{id}) and which book to remove (subresource), leaving the shelf itself untouched.

Upgrade path

DELETE /resource/{id}/subresource/{sub_id} — addressing a specific child resource by its own unique identifier when it has independent identity.

Frequência: HighFormulaicidade: Semi-fixedPrioridade de aquisição: Active recallPrioridade de output: BothTag de espaçamento: Medium-term

Log in to save chunks.