The AddObjectArrayItem API method is used to append an object to an array. It is most typically used in conjunction with the AMPscript CreateObject and SetObjectProperty functions.

The AddObjectArrayItem function can be used to create subscribers from a CloudPage using AMPscript.



1 = API Object containing the array such as Subscriber

2 = Array properties to receive new item

3 = Item to add to array


%%[ SET @Attribute=CreateObject(Attribute)

SetObjectProperty(@Attribute,’Name’,’First Name’)


SET @sub = CreateObject(“Subscriber”)

SetObjectProperty(@sub, “SubscriberKey”, @SubscriberKey)

SetObjectProperty(@sub, “EmailAddress”, @EmailAddress)

SetObjectProperty(@sub, “Status”, @SubscriberStatus)

AddObjectArrayItem(@sub, “Attributes”, @Attribute)

SET @statusCode = InvokeCreate(@sub, @statusMsg, @errorCode) ]%%


[There is no output. Subscriber created]


The SetObjectProperty function is used first to create the Attribute object, which has one column for “First Name” and a value of “John.” This is then used to connect with the Subscriber object to assign SubscriberKey, EmailAddress, and Status with AMPscript variables defined from the CloudPage.

To connect the two objects with the array, use the AddObjectArrayItem function.

Related functions are the CreateObject and SetObjectProperty functions.