# How to turn OneAgent ON or OFF on a specific host via the REST API

**URL:** <https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905>\
**Category:** Open Q&A\
**Tags:** oneagent, hosts-classic, dynatrace-api\
**Created:** [July 27, 2023, 6:21pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905 "2023-07-27T18:21:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DuaneRoelands](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DuaneRoelands](https://community.dynatrace.com/u/DuaneRoelands)\
**Post date:** [July 27, 2023, 6:21pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/1 "2023-07-27T18:21:37Z")

</div>

I want to turn OneAgent ON or OFF on a specific host via the REST API, but I can’t find the specific endpoint to do this.&nbsp; The OneAgent API seems to be read-only.

I am able to get a list of OneAgents from the API, and by searching the response for my server name, I can find the entityID.&nbsp; &nbsp;What endpoint in the REST API can I use to turn OneAgent off on that server?

This is for DynaTrace SaaS.

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [July 27, 2023, 6:44pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/2 "2023-07-27T18:44:56Z")

</div>

Hi&nbsp;[@DuaneRoelands](https://community.dynatrace.com/user/42547)

Once upon a time we used&nbsp;[OneAgent monitoring configuration API - PUT configuration](https://www.dynatrace.com/support/help/shortlink/api-config-oneagent-on-host-monitoring-put)&nbsp;but this API is deprecated.

 ![Yosi_Neuman_1-1690482810621.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/1/b14b35652e5c8408a340686c0ac6d97b329f6faa.png)

In order to use the current v2 setting api please go to the setting page of your host under _setting --\> host monitoring_ , use the … on the right corner

 ![Yosi_Neuman_2-1690483128768.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/3/631cda26b93fab62d98a5b4593d55505d5f734bf.png)

in order to open the menu

 ![Yosi_Neuman_3-1690483162689.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/e/ee31d057a0fb4bab176f5e366281c579891edb39.png)

and choose api

 ![Yosi_Neuman_4-1690483227305.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/484963666d11cc6256b73c4f3a2d94778292a99c.png)

just copy the update api call and&nbsp;you are all set!

HTH

Yos

---

<div class="post-metadata">

**Author:** ![DuaneRoelands](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DuaneRoelands](https://community.dynatrace.com/u/DuaneRoelands)\
**Post date:** [July 28, 2023, 4:18pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/3 "2023-07-28T16:18:45Z")

</div>

This does not work.

Submitted this payload (taken from the API section of the settings as you instructed:

{“schemaId”:“builtin:host.monitoring”,“schemaVersion”:“1.2.1”,“scope”:“HOST-29200A0CBEF971B4”,“value”:{“enabled”:true,“autoInjection”:true}}Got error 400, “constraints violated”,&nbsp; path “setting must not be null”.I would post the full JSON of the response, but the forum software flags it as invalid HTML and won’t let me post it.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [July 28, 2023, 5:30pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/4 "2023-07-28T17:30:39Z")

</div>

Hi [@DuaneRoelands](https://community.dynatrace.com/user/42547). Please add [] in the payload.

---

<div class="post-metadata">

**Author:** ![DuaneRoelands](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DuaneRoelands](https://community.dynatrace.com/u/DuaneRoelands)\
**Post date:** [July 31, 2023, 2:26pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/5 "2023-07-31T14:26:42Z")

</div>

This doesn’t work, either.

Payload:

[{“schemaId”:“builtin:host.monitoring”,“schemaVersion”:“1.2.1”,“scope”:“HOST-29200A0CBEF971B4”,“value”:{“enabled”:true,“autoInjection”:true}}]Response:{&nbsp;&nbsp;&nbsp;&nbsp;“error”:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“code”:&nbsp;400,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“message”:&nbsp;“Could&nbsp;not&nbsp;map&nbsp;JSON&nbsp;at&nbsp;‘’&nbsp;near&nbsp;line&nbsp;1&nbsp;column&nbsp;1”&nbsp;&nbsp;&nbsp;&nbsp;}}Please don’t accept solutions that haven’t been validated.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [July 31, 2023, 4:02pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/6 "2023-07-31T16:02:53Z")

</div>

Hi [@DuaneRoelands](https://community.dynatrace.com/user/42547)

Use POST method in the following API:

```markup
{{baseUrl}}/settings/objects?validateOnly=true

```

and change baseUrl placeholder for your tenant/api/v2

then your payload

```markup
[
  {
    "schemaId": "builtin:host.monitoring",
    "value": {
                "enabled": true,
                "fullStack": false,
                "autoInjection": true
            },
    "schemaVersion": "1.2.1",
    "scope": "HOST-29200A0CBEF971B4"
  }
]

```

if everything goes right you should receive a

```markup
[
    {
        "code": 200
    }
]

```

---

<div class="post-metadata">

**Author:** ![DuaneRoelands](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DuaneRoelands](https://community.dynatrace.com/u/DuaneRoelands)\
**Post date:** [July 31, 2023, 7:22pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/7 "2023-07-31T19:22:37Z")

</div>

Still not working.

Endpoint:

/api/v2/settings/objects?validateOnly=true

Body:

[&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;“schemaId”:&nbsp;“builtin:host.monitoring”,&nbsp;&nbsp;&nbsp;&nbsp;“value”:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“enabled”:&nbsp;true,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“fullStack”:&nbsp;false,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“autoInjection”:&nbsp;true&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;“schemaVersion”:&nbsp;“1.2.1”,&nbsp;&nbsp;&nbsp;&nbsp;“scope”:&nbsp;“HOST-29200A0CBEF971B4”&nbsp;&nbsp;}]Response:[&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“code”:&nbsp;400,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“error”:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“code”:&nbsp;400,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“message”:&nbsp;“Validation&nbsp;failed&nbsp;for&nbsp;1&nbsp;Validators.”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“constraintViolations”:&nbsp;[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“path”:&nbsp;“builtin:host.monitoring/0/fullStack”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“message”:&nbsp;“Given&nbsp;property&nbsp;‘fullStack’&nbsp;with&nbsp;value:&nbsp;‘false’&nbsp;was&nbsp;not&nbsp;found&nbsp;in&nbsp;the&nbsp;schema”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“parameterLocation”:&nbsp;“PAYLOAD\_BODY”,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“location”:&nbsp;null&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“invalidValue”:&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“enabled”:&nbsp;true,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“fullStack”:&nbsp;false,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“autoInjection”:&nbsp;true&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}]

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [August 1, 2023, 1:37pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/8 "2023-08-01T13:37:57Z")

</div>

Hi [@DuaneRoelands](https://community.dynatrace.com/user/42547) set schema to:

```markup
"schemaVersion": "1.2.0",

```

this should work. Could be a bug on the API.

I query the schema and it is correct:

```markup
{
            "schemaId": "builtin:host.monitoring",
            "displayName": "Monitoring",
            "latestSchemaVersion": "1.2.1"
        }

```

---

<div class="post-metadata">

**Author:** ![DuaneRoelands](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@DuaneRoelands](https://community.dynatrace.com/u/DuaneRoelands)\
**Post date:** [August 2, 2023, 2:03pm UTC](https://community.dynatrace.com/t/how-to-turn-oneagent-on-or-off-on-a-specific-host-via-the-rest-api/40905/9 "2023-08-02T14:03:28Z")

</div>

Changing the schema version to 1.2.0 worked.&nbsp; Thank you for your assistance!
