# Update OAuth API key

`PATCH /v1/apikeys/{apikeyId}`

Available as MCP tool `update-oauth-key` (Replace).

OAuth API key endpoints allow you to view and manage OAuth API keys for a given environment in your Redox organization. [Learn more about OAuth API keys](https://docs.redoxengine.com/permalink/3P1ee9KftdYEE9uuH9KRNs/#authentication-methods), which is our preferred authentication method.  

You can retrieve, create, update, or delete OAuth API keys.

### Update OAuth API key

Update field values of an existing OAuth API key. 

The response contains details about the key with the new values.

## Request parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `apikeyId` | path | string | Yes | Displays the unique identifier (i.e., client ID) of the OAuth API key. |

## Request body

Contains the fields that can be provided when updating a new OAuth API key.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | Displays the human-readable name of the OAuth API key. |
| `jwksURL` | string | No | Contains the JWKS URL for the OAuth API key. |
| `jwkSet` | object | No | Contains a JSON Web Key Set (JWKS). [See the JWK Set Format spec](https://datatracker.ietf.org/doc/html/rfc7517#section-5) for more details. |
| `jwkSet.keys` | Array of object | No | Contains an array of JWK objects. Each JWK must have a `kid` and `kty`, along with some other properties depending on the key type. [See the JWK spec](https://datatracker.ietf.org/doc/html/rfc7517) for more details. |
| `jwkSet.keys[].kid` | string | Yes | Displays the JWK ID ("Key ID"). |
| `jwkSet.keys[].kty` | string | Yes | Identifies the JWK type ("Key type"). |

## Request example

_Generated from the schema: the values are placeholders, not a real payload._

```bash
curl 'https://api.redoxengine.com/platform/v1/apikeys/{apikeyId}' \
--request PATCH \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
  "name": "string",
  "jwksURL": "string",
  "jwkSet": {
    "keys": [
      {
        "kid": "string",
        "kty": "string"
      }
    ]
  }
}'
```

## Responses

### 200

Contains a payload object with the updated details for the specified OAuth API key.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `meta` | object | No |  |
| `meta.version` | string | No | Lists the major and minor version number for the format of the returned payload. The payload format or shape may change between minor versions, like including additional or extended fields in later versions. We include the version data in each response so that you have the option to handle the signaled differences. |
| `payload` | object | No | Contains the payload with details about the requested OAuth API key(s). |
| `payload.apikey` | object | No | Contains an instance of an OAuth API key. |
| `payload.apikey.name` | string | No | Displays the human-readable name of the OAuth API key. |
| `payload.apikey.jwksURL` | string | No | Contains the JWKS URL for the OAuth API key. |
| `payload.apikey.jwkSet` | object | No | Contains a JSON Web Key Set (JWKS). [See the JWK Set Format spec](https://datatracker.ietf.org/doc/html/rfc7517#section-5) for more details. |
| `payload.apikey.jwkSet.keys` | Array of object | No | Contains an array of JWK objects. Each JWK must have a `kid` and `kty`, along with some other properties depending on the key type. [See the JWK spec](https://datatracker.ietf.org/doc/html/rfc7517) for more details. |
| `payload.apikey.jwkSet.keys[].kid` | string | Yes | Displays the JWK ID ("Key ID"). |
| `payload.apikey.jwkSet.keys[].kty` | string | Yes | Identifies the JWK type ("Key type"). |
| `payload.apikey.id` | string | No | Displays the unique identifier (i.e., client ID) of the OAuth API key. |
| `payload.apikey.environment` | object | No | Contains metadata about the environment within the associated Redox organization. |
| `payload.apikey.environment.id` | string (uuid) | No | Contains the unique identifier of the Redox environment. |
| `payload.apikey.environment.environmentFlag` | string | No | Indicates whether the environment is used for development, staging, or production. Possible values: Production, Staging, Development |

_Generated from the schema: the values are placeholders, not a real payload._

```json
{
  "meta": {
    "version": "1.0.0"
  },
  "payload": {
    "apikey": {
      "name": "string",
      "jwksURL": "string",
      "jwkSet": {
        "keys": [
          {
            "kid": "string",
            "kty": "string"
          }
        ]
      },
      "id": "string",
      "environment": {
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "environmentFlag": "Staging"
      }
    }
  }
}
```

### 400

Bad Request

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.id` | string | No | Contains a unique identifier for the given error instance. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Bad Request`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Bad Request",
      "code": "validation.error.bad.request",
      "detail": "Error details",
      "status": 400,
      "transient": false
    }
  }
}
```

### 403

Forbidden

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.errors` | Array of object | No |  |
| `payload.errors[].title` | string | No | Displays the high-level error message, typically something succinct like `Forbidden`. |
| `payload.errors[].code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |

```json
{
  "payload": {
    "errors": [
      {
        "title": "Forbidden",
        "code": "authorization.forbidden"
      }
    ]
  }
}
```

### 500

Internal Server Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Failed in step X`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Internal Server Error",
      "code": "failed.db.lookup",
      "detail": "Error details",
      "status": 500,
      "transient": true
    }
  }
}
```
