Update an api key by id
PUT /api_keys/{api_key_id}
Updates an api key by id. Requires the target api_key_id as a path parameter.
An API Key can be disabled by passing status: disabled. By passing status: enabled, you can enable the key again.
Always pass the the whole array of scopes you want this key to have. At this moment there is no way to make incremental updates. Whenever the scopes array is passed to the endpoint, the previous scopes array will be overriden.
Protected scopes like api_clients, api_keys and subscriptions cannot be set via API.
A valid api_key_id is one that was returned by the api key creation endpoint. If no api key can be found with the given api_key_id, the endpoint returns status 404.
Returns 404 if no api key was found with the given api_key_id.
Only mutable properties like name, status, and scopes can be updated.
Authentication
The target organization for this request will be determined by the supplied access token.
As a prerequisite you need to create an account and follow the onboarding process to also create an organization and an API key.
See also: Authentication.
Examples
curl -X PUT http://api.discue.io/v1/api_keys/{api_key_id} \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-API-KEY: API_KEY' \
-d '{
"name": "string",
"status": "disabled",
"scopes": [
{
"resource": "queues",
"access": "write",
"targets": [
"*"
]
},
{
"resource": "listeners",
"access": "write",
"targets": [
"_Tzrg1O3jk4_FZTAEThNq"
]
},
{
"resource": "messages",
"access": "read",
"targets": [
"*"
]
}
]
}'
const body = {
"name": "string",
"status": "disabled",
"scopes": [
{
"resource": "queues",
"access": "write",
"targets": [
"*"
]
},
{
"resource": "listeners",
"access": "write",
"targets": [
"_Tzrg1O3jk4_FZTAEThNq"
]
},
{
"resource": "messages",
"access": "read",
"targets": [
"*"
]
}
]
}
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'X-API-KEY':'API_KEY'
}
const response = await fetch('http://api.discue.io/v1/api_keys/{api_key_id}', {
method: 'PUT', body, headers
})
const body = await response.json()
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-API-KEY': 'API_KEY'
}
r = requests.put('http://api.discue.io/v1/api_keys/{api_key_id}', headers = headers)
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"X-API-KEY": []string{"API_KEY"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("PUT", "http://api.discue.io/v1/api_keys/{api_key_id}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
}
Body
{
"name": "string",
"status": "disabled",
"scopes": [
{
"resource": "queues",
"access": "write",
"targets": [
"*"
]
},
{
"resource": "listeners",
"access": "write",
"targets": [
"_Tzrg1O3jk4_FZTAEThNq"
]
},
{
"resource": "messages",
"access": "read",
"targets": [
"*"
]
}
]
}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| api_key_id | path | ResourceId | ✔ | Id of the api key |
| pretty | query | boolean | ❌ | Return the response pretty printed |
| body | body | UpdateApiKeyRequest | ❌ | none |
| » name | body | ResourceName | ❌ | none |
| » status | body | string | ❌ | none |
| » scopes | body | ApiKeyScope | ❌ | none |
| »» resource | body | string | ❌ | none |
| »» access | body | string | ❌ | none |
| »» targets | body | any | ❌ | none |
| »»» anonymous | body | ResourceId | ❌ | none |
| »»» anonymous | body | string | ❌ | none |
Enumerated Values
| Parameter | Value |
|---|---|
| » status | disabled |
| » status | enabled |
| »» resource | api_clients |
| »» resource | api_keys |
| »» resource | events |
| »» resource | queues |
| »» resource | listeners |
| »» resource | messages |
| »» resource | schemas |
| »» resource | stats |
| »» resource | subscriptions |
| »» access | read |
| »» access | write |
| »»» anonymous | * |
Responses
400 Response
{
"title": "Bad Request",
"status": 400
}
401 Response
{
"title": "Unauthorized",
"status": 401
}
402 Response
{
"title": "Payment Required",
"status": 402
}
403 Response
{
"title": "Forbidden",
"status": 403
}
404 Response
{
"title": "Not Found",
"status": 404
}
405 Response
{
"title": "Method Not Allowed",
"status": 405
}
406 Response
{
"title": "Not Acceptable",
"status": 406
}
409 Response
{
"title": "Conflict",
"status": 409
}
415 Response
{
"title": "Unsupported Media Type",
"status": 415
}
422 Response
{
"title": "Unprocessable Entity",
"status": 422
}
423 Response
{
"title": "Locked",
"status": 423
}
429 Response
{
"title": "Too Many Requests",
"status": 429
}
500 Response
{
"title": "Internal Server Error",
"status": 500
}
501 Response
{
"title": "Not Implemented",
"status": 501
}
503 Response
{
"title": "Service Unavailable",
"status": 503
}
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Ok | None |
| 400 | Bad Request | Bad Request | Inline |
| 401 | Unauthorized | Unauthorized | Inline |
| 402 | Payment Required | Payment Required | Inline |
| 403 | Forbidden | Forbidden | Inline |
| 404 | Not Found | Not Found | Inline |
| 405 | Method Not Allowed | Method Not Allowed | Inline |
| 406 | Not Acceptable | Not Acceptable | Inline |
| 409 | Conflict | Conflict | Inline |
| 415 | Unsupported Media Type | Unsupported Media Type | Inline |
| 422 | Unprocessable Entity | Unprocessable Entity | Inline |
| 423 | Locked | Locked | Inline |
| 429 | Too Many Requests | Too Many Requests | Inline |
| 500 | Internal Server Error | Internal Server Error | Inline |
| 501 | Not Implemented | Not Implemented | Inline |
| 503 | Service Unavailable | Service Unavailable | Inline |