> For the complete documentation index, see [llms.txt](https://docs.langstack.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.langstack.com/welcome/get-started/learn-langstack/introduction-to-entities/exercise-1-customer-accounts-and-activities/customer-activities/step-4-update-entity-through-api.md).

# Step 4: Update entity through API

Once the Entity and API are created, the API can be used to populate multiple records in the Entity “UserName\_Acc\_Activities”.

* To test the API, click the \[Test] button.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/testapi.png" alt=""><figcaption></figcaption></figure>

* The Test API box will display the “Entity actions” toggle button disabled. (Note: If “Entity actions” is not enabled, testing an API that is using entity actions will result in the status of “failed” in the response.)\
  To allow the Entity to be updated or created with entity actions, click the “Entity actions” toggle button.
*

```
<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/apitestenableentity.png" alt=""><figcaption></figcaption></figure>
```

* Select the default API gateway as “UserName\_Acc\_AddCustomer”. The default API gateway will be selected if the user does not select an API gateway.
* In the “Request” section, update the Json object in the Request section with values to test.\
  In this case, we add two (2) activities for the customer with a certain customer\_id (Users must ensure to add a customer\_id present in the entity “UserName\_Acc\_customers,” else it will give an error message).\
  Copy the following code and paste it into the Request section on the Test Console. (Ensure the data is present in the target entity)\
  \
  `{ "customer_id": "7c55d71fece9e418787f9628a3d77d19c",`\
  `"activities": [{`\
  `"Activity_Type": "Information Request/Query",`

  `"Activity_Description": "test email",`

  `"Activity_DateTime": "2021-03-03",`

  `"Activity_Priority": 1,`

  `"Activity_AssignedTo": "Test HD Team",`

  `"Activity_CreatedBy": "Test Sales Team"`\
  `},`\
  `{`\
  `"Activity_Type": "Incoming call",`

  `"Activity_Description": "test Incoming call",`

  `"Activity_DateTime": "2021-11-29",`

  `"Activity_Priority": 2,`

  `"Activity_AssignedTo": "Test Marketing",`

  `"Activity_CreatedBy": "Test Sales Team"`\
  `}`\
  `]`\
  `}`\
  \`\`
* The test Console will be as per the image below.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5ex1activtestreq.png" alt=""><figcaption></figcaption></figure>

* To test if the record is created in the target entity, click the \[Test API] button.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5ex1testbutton.png" alt=""><figcaption></figcaption></figure>

* The Response section in the Test dialog displays a record creation success message.
* In the list of Entities, click on “UserName\_Acc\_Activities”. The created record will be displayed.

{% hint style="info" %}
Note: If the “Entity actions” toggle button is disabled, and the API is tested, the Response section in the Test dialog displays an error message when the \[Test API] button is clicked.
{% endhint %}
