# `deleteRecord(recordId)`

Deletes a record.

## Syntax

```javascript
import { deleteRecord } from 'lightning/uiRecordApi';
deleteRecord(recordId: string): Promise<void>
```

## User Interface API Resource

```html
DELETE /ui-api/records/{recordId}
```

`deleteRecord` uses this [User Interface API resource](https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_record_delete.htm).

## Parameters

| Parameter Name | Type   | Description                     | Required?                                                                         |
| -------------- | ------ | ------------------------------- | --------------------------------------------------------------------------------- |
| `recordId`     | String | The ID of the record to delete. | ![Yes](https://a.sfdcstatic.com/developer-website/sfdocs/lwc/media/checkmark.png) |

## Returns

The return type is `void`.

## Usage

`deleteRecord` accepts a single record ID. To delete multiple records, use `Promise.all()` or Apex.

This example displays a list of account records with a delete button next to each account name. When a record is deleted successfully, the component displays a toast message and uses `refreshApex()` to refresh the data provisioned via the Apex `@wire`.

```javascript title="ldsDeleteRecord.js"
import { LightningElement, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import { deleteRecord } from 'lightning/uiRecordApi';
import getAccountList from '@salesforce/apex/AccountController.getAccountList';
import { reduceErrors } from 'c/ldsUtils';

export default class LdsDeleteRecord extends LightningElement {
    accounts;
    error;

    /** Wired Apex result so it can be refreshed programmatically */
    wiredAccountsResult;

    @wire(getAccountList)
    wiredAccounts(result) {
        this.wiredAccountsResult = result;
        if (result.data) {
            this.accounts = result.data;
            this.error = undefined;
        } else if (result.error) {
            this.error = result.error;
            this.accounts = undefined;
        }
    }

    async deleteAccount(event) {
        const recordId = event.target.dataset.recordid;

        try {
            await deleteRecord(recordId);
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Success',
                    message: 'Account deleted',
                    variant: 'success'
                })
            );
            await refreshApex(this.wiredAccountsResult);
        } catch (error) {
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error deleting record',
                    message: reduceErrors(error).join(', '),
                    variant: 'error'
                })
            );
        }
    }
}

```

When you successfully delete a record, any component that's subscribed to the deleted record via a wire returns a 404 error for that record data.

Don't call `deleteRecord` from a record page for a record that you want to delete. The record is deleted and you receive a 404 error with a message "The requested resource does not exist".

**See Also**

- [Client-Side Caching of Apex Method Results](/docs/platform/lwc/guide/apex-result-caching.md)
