Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

HTTP DELETE with a body ?

Hello,

I have to soft delete a user and specify the reason why he has been deleted. The reason is required, otherwise I cannot soft delete the user.

The soft delete is done via an HTTP DELETE request.

But with an HTTP DELETE request, it's not possible to add a body to the request.

So what could be the solution to soft delete a user and save a reason to this deletion in another table, given that the reason is required to be able to soft delete the user.

Thanks for your help.

Vincent

0 likes
9 replies
Snapey's avatar

You can't send http delete unless this is from an API call? Normal web form deletes have to be post with hidden delete _method field. You can pass a body here.

If via API, you would have to url encode the reason and add it to the query string I think.

1 like
vincent15000's avatar

@Snapey The application is with VueJS for the front, so yes it's an API call.

What I thought about is for example use a patch request to soft delete the user and send the reason inside the body.

What do you think about this ?

Or as you say via the URL ... when you say url encode, you mean https://domain.com?reason=this_is_the_reason ?

vincent15000's avatar

@Snapey Well ... yes ... about semantics, I would say that a soft delete isn't a delete, it's rather an update of the deleted_at field.

What's the best pratice in Laravel for doing soft deletes ? Via an PATCH request or a DELETE request ?

Some members of the teams in which I work like to think that a soft delete should be a PATCH request. I agree with because the model isn't really deleted.

jlrdw's avatar
jlrdw
Best Answer
Level 75

@vincent15000 I'd just use a put request for that. You are just updating the deleted_at column.

1 like
vincent15000's avatar

@jlrdw It's probably a good idea. In this case I can add a body to the request to pass the reason of the deletion.

What's the real difference between PUT and PATCH ?

I read that a PUT request is to replace all the fields whereas a PATCH request to merge the request with the existing datas. But in pratice it could be rather different because I could use a DELETE request to create a new model and not the delete one (sure which has no sense ;)).

Is there really a good reason to use PATCH instead of PUT ? Or i it just to respect a certain semantic (which is already a good reason) ?

1 like
jlrdw's avatar

@vincent15000 you have document type storage and you have field storage like innodb in mysql.

Laravel uses symfony request, so in the background it handles whether to turn it into a post request.

In regular request (crud), there is no put, patch or delete Symfony automatically turns them into a post request for you if needed.

1 like
vincent15000's avatar

@jlrdw @snapey Finally it was easier to write a new endpoint to post the reason just after having deleted the user. And the frontend will check that the connected user has explained the reason before deleting the user.

1 like

Please or to participate in this conversation.