---
schema_version: "1"
id: 2cba09b94659527d0e67d029d38c0b42f15df84225fc6cead3f7ff0068f1b951
title: InvokeDelete()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/api/mc-ampscript-reference-api-invoke-delete.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-api/mc-ampscript-reference-api-invoke-delete.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 147ed5a730cd8c70329c6f774f9ed0d2540ff916a87dafc99c4d4412e2337404
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# InvokeDelete()

Invokes the Delete method on a Marketing Cloud Engagement API Object and returns the API status code. Use an ID, external ID, or key as the object reference.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>❌ No</td>
  </tr>
</table>

## Syntax

```
InvokeDelete(apiObject,
             statusMessage,
             errorCode,
             deleteOptionsObject)
```

The `InvokeDelete()` function has four parameters:

- `apiObject` (API Object): Required. The API Object to delete.
- `statusMessage` (AMPscript variable): Required. An AMPscript variable that stores the API status message.
- `errorCode` (AMPscript variable): Required. An AMPscript variable that stores the API error code.
- `deleteOptionsObject` (API Object): A DeleteOptions API object.

## Usage

This example creates a Subscriber API Object and sets a property on it. It then deletes the Object and outputs the status code. If the status code doesn’t equal "OK," it outputs the status message and error code.

```
%%[
  var @sub, @statusCode, @statusMessage, @errorCode
  set @sub = CreateObject("Subscriber")

  SetObjectProperty(@sub, "CustomerKey", "4231")

  set @statusCode = InvokeDelete(@sub, @statusMessage, @errorCode)
]%%

<p>Status Code: %%=v(@statusCode)=%%</p>

%%[If @statusCode != "OK" then]%%
<p>Status Message: %%=v(@statusMessage)=%%</p>
<p>Error Code: %%=v(@errorCode)=%%</p>
%%[EndIf]%%
```
