# API Bug? Error enabling rule: could not create API key - Unsupported scheme \\"ApiKey\\" for granting API Key

**URL:** <https://discuss.elastic.co/t/api-bug-error-enabling-rule-could-not-create-api-key-unsupported-scheme-apikey-for-granting-api-key/285407>\
**Category:** Kibana\
**Created:** [September 28, 2021, 8:41pm UTC](https://discuss.elastic.co/t/api-bug-error-enabling-rule-could-not-create-api-key-unsupported-scheme-apikey-for-granting-api-key/285407 "2021-09-28T20:41:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrykowski-huron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jrykowski-huron/32/69454_2.png) [@jrykowski-huron](https://discuss.elastic.co/u/jrykowski-huron)\
**Post date:** [September 28, 2021, 8:41pm UTC](https://discuss.elastic.co/t/api-bug-error-enabling-rule-could-not-create-api-key-unsupported-scheme-apikey-for-granting-api-key/285407/1 "2021-09-28T20:41:54Z")

</div>

Authentication type is ApiKey.  
Version: 7.14.1

When rule is already Enabled, there is no trouble calling the API endpoint for \_enable. Returns Status Code 204.

But if rule is actually Disabled (and therefore need to Enable), an error occurs when attempting \_enable action. Can call hit the \_disable endpoint using same Header with same ApiKey value, the only material change is using the /\_enable endpoint versus the /\_disable one. (/\_mute\_all and /unmute\_all both work as expected).

`POST https://{kibana host}:5601/api/alerting/rule/{rule id}/_enable with 0-byte payload`

Response...  
`{"statusCode":400,"error":"Bad Request","message":"Error enabling rule: could not create API key - Unsupported scheme \"ApiKey\" for granting API Key"}`

---

<div class="post-metadata">

**Author:** ![dosant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dosant/32/64489_2.png) [@dosant](https://discuss.elastic.co/u/dosant)\
**Post date:** [October 1, 2021, 9:47am UTC](https://discuss.elastic.co/t/api-bug-error-enabling-rule-could-not-create-api-key-unsupported-scheme-apikey-for-granting-api-key/285407/2 "2021-10-01T09:47:56Z")

</div>

Looking at docs [here](https://www.elastic.co/guide/en/kibana/current/enable-rule-api.html)

> This API supports [Token-based authentication](https://www.elastic.co/guide/en/kibana/current/api.html#token-api-authentication) only.

---

<div class="post-metadata">

**Author:** ![jrykowski-huron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jrykowski-huron/32/69454_2.png) [@jrykowski-huron](https://discuss.elastic.co/u/jrykowski-huron)\
**Post date:** [October 4, 2021, 2:48pm UTC](https://discuss.elastic.co/t/api-bug-error-enabling-rule-could-not-create-api-key-unsupported-scheme-apikey-for-granting-api-key/285407/3 "2021-10-04T14:48:08Z")

</div>

Thanks for pointing that out @dosant. Will review the API docs more carefully. Updating custom PowerShell module now to add support for Token-based authentication.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 1, 2021, 2:48pm UTC](https://discuss.elastic.co/t/api-bug-error-enabling-rule-could-not-create-api-key-unsupported-scheme-apikey-for-granting-api-key/285407/4 "2021-11-01T14:48:33Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
