---
schema_version: "1"
id: 38fc967aa7263d8f1b057be62239f8604b26c05c3320d2cf32c80364ec77a71d
title: InvokeCreate()
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-create.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-api/mc-ampscript-reference-api-invoke-create.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4bac633dd6ee51835443f2e8c4dac44cad7f72421a9327eef6dad89863a67d01
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# InvokeCreate()

Invokes the Create method on an API object and returns an 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

```
InvokeCreate(apiObject,
             statusMessage,
             errorCode,
             createOptionsObject)
```

The `InvokeCreate()` function has four parameters:

- `apiObject` (API Object): Required. The API Object to create.
- `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.
- `createOptionsObject` (API Object): A CreateOptions API object.

## Usage

This example creates the TriggeredSend and TriggeredSendDefinition objects as @ts and @tsDef. It also assigns the correct properties to the objects and passes the object into the InvokeCreate call. The InvokeCreate call returns a status code and status message, which you can use for handling exceptions.

```
%%[
  Var @emailaddr
  Set @emailaddr = 'help@example.com'

  Set @ts = CreateObject('TriggeredSend')

  Set @tsDef = CreateObject('TriggeredSendDefinition')

  Set @ts_subkey = @emailaddr
  SetObjectProperty(@tsDef, 'CustomerKey', 'VolConfirm')
  SetObjectProperty(@ts, 'TriggeredSendDefinition', @tsDef)

  Set @ts_sub = CreateObject('Subscriber')
  SetObjectProperty(@ts_sub, 'EmailAddress', @emailaddr)
  SetObjectProperty(@ts_sub, 'SubscriberKey', @ts_subkey)
  AddObjectArrayItem(@ts, 'Subscribers', @ts_sub)

  Set @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)

  If @ts_statusCode != 'OK' then
    RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
  EndIf
]%%
```

In this example, the AMPscript returns errors to the screen.

## See Also

- [API Error Codes](https://developer.salesforce.com/docs/marketing/guides/mc-apis/error_codes.md)
- [CreateOptions API](https://developer.salesforce.com/docs/marketing/guides/mc-apis/createoptions.md)
