# API Create Engagement Metadata

**URL:** <https://community.hubspot.com/t/api-create-engagement-metadata/20519>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, contacts\
**Created:** [May 1, 2020, 12:40am UTC](https://community.hubspot.com/t/api-create-engagement-metadata/20519 "2020-05-01T00:40:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![srolandmarshall](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/srolandmarshall/32/31851_2.png) [@srolandmarshall](https://community.hubspot.com/u/srolandmarshall)\
**Post date:** [May 1, 2020, 12:40am UTC](https://community.hubspot.com/t/api-create-engagement-metadata/20519/1 "2020-05-01T00:40:51Z")

</div>

Hi there,

I have a large batch of data I am running through a Ruby script. To avoid unnecessary debugging and testing, are all fields in an Engagement’s Metadata “required”? I.e. if I do not send a start and end time for a phone call, will it not import?

If they are required, is passing in a null value or blank string going to cause the response to be an error?

---

<div class="post-metadata">

**Author:** ![Willson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/willson/32/84663_2.png) [@Willson](https://community.hubspot.com/u/Willson)\
**Post date:** [May 1, 2020, 10:27am UTC](https://community.hubspot.com/t/api-create-engagement-metadata/20519/2 "2020-05-01T10:27:56Z")

</div>

Hey @srolandmarshall

To confirm, the metadata is required and if it is not set it will return the following error:

`"message": "metadata cannot be null"`

In this case, to get past this, we can work with a payload such as:

`{"engagement": {"active": true,"ownerId": 1,"type": "CALL"},"associations": {"contactIds": [48051],"companyIds": [],"dealIds": [],"ownerIds": [],"ticketIds":[]},"metadata": {}}`

In the above case, a Call engagement will be logged to the record and the contens of the engagement will be left blank bar the Date and Time that defaults to the time when the request was made, should it be left blank.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![srolandmarshall](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/srolandmarshall/32/31851_2.png) [@srolandmarshall](https://community.hubspot.com/u/srolandmarshall)\
**Post date:** [May 1, 2020, 6:11pm UTC](https://community.hubspot.com/t/api-create-engagement-metadata/20519/3 "2020-05-01T18:11:03Z")

</div>

Yes, this does make sense. To clarify, my question was about leaving some of the requested fields out of metadata when they are not relevant, I see how I was not clear about that.

Your example was awesome and super helpful. Thanks!
