# Update API Key

Rename a key, or change what it may do. You can remove any permission; you can add only permissions your own key holds.

`PUT https://connect.mindcloud.co/v2/api-keys/:apiKeyId`

Permissions: `api_key:manage`.

## Parameters

### Path

- `apiKeyId` (string, required): The key's id, from List API Keys.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. Here a key acts in another organization only as one of its members: with "Use this key across all of your organizations" on, in an organization its creator belongs to with a role. Child organizations and MindCloud staff access do not reach this endpoint. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `name` (string): A new name, up to 256 characters.
- `permissions` (array): The full new set of permissions. Replaces the current set.
  Allowed values:
    - `workflow:view`: Workflows: View workflows.
    - `workflow:create`: Workflows: Create workflows.
    - `workflow:edit`: Workflows: Edit workflows.
    - `workflow:delete`: Workflows: Delete workflows.
    - `workflow:run`: Workflows: Run and cancel workflows.
    - `log:view`: Runs: View runs and logs.
    - `credential:view`: Connections: View connections.
    - `credential:create`: Connections: Create connections and connect links.
    - `credential:edit`: Connections: Edit, reconnect, and test connections.
    - `credential:delete`: Connections: Delete connections.
    - `universal:read`: Universal API: Run read actions and lookups.
    - `universal:create`: Universal API: Run create actions.
    - `universal:update`: Universal API: Run update actions.
    - `universal:delete`: Universal API: Run delete actions.
    - `member:view`: Members and roles: View members and roles.
    - `member:create`: Members and roles: Invite members.
    - `member:edit`: Members and roles: Change member roles.
    - `member:delete`: Members and roles: Remove members.
    - `member:owner_edit`: Members and roles: Invite, change, or remove Owners.
    - `role:manage`: Members and roles: Create, edit, and delete roles.
    - `company:view`: Company: View company and environments.
    - `company:edit`: Company: Edit company profile.
    - `environment:edit`: Company: Create, edit, and delete environments.
    - `company:parent:manage`: Company: Accept, decline, or leave a parent organization.
    - `subscription:view`: Company: View usage and spend limits.
    - `subscription:manage`: Company: Set member spend limits.
    - `api_key:manage`: API keys: See and revoke all API keys.
    - `embedded:view`: Embedded: View end users and their connections.
    - `embedded:create`: Embedded: Create end users and connect links.
    - `embedded:edit`: Embedded: Edit end users.
    - `embedded:delete`: Embedded: Delete end users.
    - `analytics:page:view`: Analytics: View Analytics pages, panels and data sources.
    - `analytics:page:create`: Analytics: Create Analytics pages and manage data sources, publications, themes, folder shares and template installs.
    - `analytics:page:edit`: Analytics: Edit, publish, share and delete Analytics pages.
    - `child_company:access`: Child organizations: Act in child organizations.
    - `child_company:manage`: Child organizations: Create, link, release, and close child organizations.
- `isAllOrganizations` (boolean): true or false: "Use this key across all of your organizations". Turning it off is always allowed; only a calling key that has it may turn it on, or rename or add permissions to a key that has it.
  "Use this key across all of your organizations". Only a key that has it may turn it on.

## Example request

```bash
curl --request PUT \
  --url 'https://connect.mindcloud.co/v2/api-keys/apikey_K7dM2qP9xL4s' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Nightly sync",
  "permissions": [
    "workflow:view",
    "workflow:run"
  ],
  "isAllOrganizations": false
}'
```

## Response fields

- `id` (string): Unique id of the key.
- `name` (string): The name the key was created with.
- `companyId` (string): The organization the key belongs to. A key with isAllOrganizations is listed in every organization its creator opens, so it may belong to another one.
- `isAllOrganizations` (boolean): "Use this key across all of your organizations": the key can act, through X-Company-Id, in every organization its creator can open in the app, with no more than the creator may do there.
- `accessLevel` (string): A summary of the key permissions: full_access, run_workflows, read_only, or none. Derived from permissions; it is never set directly.
  Allowed values:
    - `read_only`
    - `run_workflows`
    - `full_access`
    - `none`
- `permissions` (array of string): The permissions the key holds. A request may use one only while the key's creator also holds it.
- `usedOn` (date): The last time the key was used. Old dates are rotation candidates.
- `revokedOn` (date): When the key was revoked. Empty while it is active.
- `createdOn` (date): When the key was created.
- `createdBy` (string): Who created it.
- `updatedOn` (date): When it was last changed.

## Errors

- 403 Beyond the calling key (API_KEY_PERMISSION_EXCEEDS_ACTOR): `FORBIDDEN` / `API_KEY_PERMISSION_EXCEEDS_ACTOR` "An API key cannot be given permissions beyond your own: member:delete."
