The idea itself is valid.
I do not see problems since id
and codUsuario
are some kind of composite key to access this resource in which you want to remove OR both form a URL in which the set of these two information can point to a single resource, in a parent-child relationship.
I will give an example of each case. First, with compound key.
First example
If you want to remove a document in which the compound key is the document type and its number:
/documentos/{tipo-documento}/{numero}
A request would be:
DELETE /documentos/CPF/12312312300/
Now let's go to the second example.
Second Example
You can have the orders and products, and you want to access the product within an order (or remove it in your case).
/pedidos/{id-pedido}/produtos/{id-produto}
And a request:
DELETE /pedidos/123/produtos/3333
However , looking at the example you gave, your endpoint is very strange, it does not seem to be either case since you can not see a natural relationship between id
and codUsuario
. We would need to understand the context behind this endpoint for a better solution. Maybe you're looking for something like this:
DELETE /users/{codUsuario}/addresses/{idAddress}