# Update a credential

`PATCH https://api.cademi.com.br/api/v3/credentials/{credential_id}`

Operation ID: `credentials.update` · API v3

Updates the `name`, `purpose`, or `expires_at` of a credential, or changes its `status`.

Setting `status` to `inactive` suspends the credential, and setting it to `active` reactivates it. Setting `status` to `revoked` permanently revokes the credential; revocation cannot be undone.

Send the `ETag` returned by the retrieve operation in the `If-Match` header to avoid overwriting a newer version.

A credential cannot update itself.

Required permissions: `credentials.manage`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `credential_id` | path | string | yes |  |
| `If-Match` | header | string | no |  |

## Request body

Content type: `application/json`, required.

| Field | Type | Required | Description |
|---|---|---|---|
| `expires_at` | string or null (date-time) | no |  |
| `name` | string | no |  |
| `purpose` | string or null | no |  |
| `status` | string, one of `active`, `inactive`, `revoked` | no |  |

## Responses

### 200

Returns the updated credential.

Body: `data`: Credential.

Fields of Credential:

| Field | Type | Required | Description |
|---|---|---|---|
| `auth_mode` | string, one of `autonomous`, `human_required`, `both` | yes |  |
| `created_at` | string (date-time) | yes |  |
| `created_by` | object | yes |  |
| `environment` | string, one of `production`, `sandbox` | yes |  |
| `expires_at` | string or null (date-time) | yes |  |
| `human` | object or null | yes | The administrator on whose behalf the current call is made, when the credential acts in human mode. null when the credential acts autonomously. |
| `id` | string | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `credential` | yes |  |
| `policy` | object | yes |  |
| `purpose` | string or null | yes |  |
| `revision` | integer | yes |  |
| `revoked_at` | string or null (date-time) | yes |  |
| `revoked_by` | object or null | yes |  |
| `secret` | object or null | yes |  |
| `status` | string, one of `active`, `suspended`, `revoked` | yes |  |
| `updated_at` | string (date-time) | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The credential was not found or is not accessible with the current credentials.

Body: Error.

### 412

The credential has changed since the revision supplied in If-Match was retrieved.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
