---
schema_version: "1"
id: 28fdc56ad5f8b0c67f782ab72675384895602e3ed9e93dab550d0e89e353f355
title: InvokePerform()
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-perform.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-api/mc-ampscript-reference-api-invoke-perform.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: bc9f16f17a34ffa2529f66cb677709077fa082ca40d7ec68d32a8be6b7545bdd
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# InvokePerform()

Invokes the Perform method on a Marketing Cloud Engagement API Object and returns the API status code.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>❌ No</td>
  </tr>
</table>

## Syntax

```
InvokePerform(apiObject,
              actionToPerform,
              statusMessage)
```

The `InvokePerform()` has three parameters:

- `apiObject` (API Object): Required. The API Object to invoke the Perform method on.
- `actionToPerform` (string): Required. Action to perform, with valid parameter values varying depending on the object type.
- `statusMessage` (AMPscript variable): An AMPscript variable that stores the API status message.

## Usage

This example creates a Campaign API Object and sets a property on it. It then invokes the Perform method on the Object, passing the "stop" action. The function then outputs the status code. If the status code doesn’t equal "OK," it outputs the status message and error code.

```
%%[
  var @campaign, @statusCode, @statusMessage, @errorCode, @campaignId

  set @campaignId = 1
  set @campaign = CreateObject("Campaign")

  SetObjectProperty(@campaign, "ID", @campaignId)

  Set @statusCode = InvokePerform(@campaign, "stop", @statusMessage)
]%%

<p>Status Code: %%=v(@statusCode)=%%</p>

%%[If @statusCode != "OK" then]%%

<p>Status Message: %%=v(@statusMessage)=%%</p>
<p>Error Code: %%=v(@errorCode)=%%</p>
%%[EndIf]%%
```
