Back to Home
$httpDelete
$httpDelete sends a DELETE request to an API. Use this when you need to remove a resource, like deleting a user, a message, or a record.
Syntax
$httpDelete[Url;(Body)]
Url: the web address of the API resource you want to delete.(Body): data to include with the request (usually JSON). This is optional, but most APIs expect at least{}if they require a body. Leave it fully empty only if the API explicitly accepts a bodyless request.
What happens
$httpDeletesends a request to the URL.- The API finds the resource and deletes it.
- The response is stored in memory. Use $httpResult to see it.
Example 1: Deleting a user
Remove a user from the database:
$httpDelete[https://api.example.com/users/1]
$httpResult
What happens:
$httpDeletetells the API to delete user 1.- The API removes the user and sends back a response (often a confirmation message).
$httpResultdisplays whatever the API returned.
To extract specific parts of the response, see the $httpResult page.
Example 2: Delete with a body
Some APIs expect extra info with the delete request:
$httpDelete[https://api.example.com/users/1;{"reason":"inactivity"}]
$httpResult
What happens:
$httpDeletesends the delete request with a reason attached.- The API deletes the user and returns a response.
$httpResultshows the response.
Common uses
- Removing users or accounts from a database
- Cleaning up old records like expired entries
- Deleting messages or comments
- Unlinking or removing resources from a server
See also
- $httpResult: to read the API's response
- $httpStatus: to check if the deletion succeeded
- $httpAddHeader: to send an API key or auth token