> ## Documentation Index
> Fetch the complete documentation index at: https://docs.commenda.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update credential

> Update an existing credential and its blocks

Update a credential's details and blocks. You can add new blocks, update existing ones, and delete blocks by ID.

## Path parameters

<ParamField path="id" type="string" required>
  The unique identifier (UUID) of the credential to update.
</ParamField>

## Request body

<ParamField body="corporation_id" type="string" required>
  The unique identifier (UUID) for the corporation.
</ParamField>

<ParamField body="portal_id" type="string">
  The portal ID to associate the credential with.
</ParamField>

<ParamField body="name" type="string">
  Updated display name.
</ParamField>

<ParamField body="portal_url" type="string">
  Updated portal URL.
</ParamField>

<ParamField body="notes" type="string">
  Updated notes.
</ParamField>

<ParamField body="status" type="string">
  Updated status. Values: `ACTIVE`, `EXPIRED`.
</ParamField>

<ParamField body="blocks" type="array">
  Array of blocks to add or update. Each block requires `block_key`, `block_label`, `block_type`, and `value`. Include `id` for existing blocks to update them; omit `id` to create new blocks.
</ParamField>

<ParamField body="blocks_to_delete" type="array">
  Array of block IDs to delete from this credential.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://transaction-tax.api.in.commenda.io/api/v1/credentials/a1b2c3d4-e5f6-7890-abcd-ef1234567890' \
    --header 'Authorization: Bearer <your_token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "corporation_id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "California CDTFA Portal (Updated)",
      "blocks": [
        {
          "id": "block-uuid-1",
          "block_key": "username",
          "block_label": "Username",
          "block_type": "String",
          "value": "new-user@example.com"
        }
      ]
    }'
  ```

  ```json Update blocks theme={null}
  {
    "corporation_id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "California CDTFA Portal (Updated)",
    "blocks": [
      {
        "id": "block-uuid-1",
        "block_key": "username",
        "block_label": "Username",
        "block_type": "String",
        "value": "new-user@example.com"
      }
    ]
  }
  ```

  ```json Delete blocks theme={null}
  {
    "corporation_id": "550e8400-e29b-41d4-a716-446655440000",
    "blocks_to_delete": ["block-uuid-2"]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "message": "Successfully updated credential.",
    "data": {
      "credential": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "updated_at": "2024-02-01T14:00:00Z"
      }
    }
  }
  ```

  ```json 404 - Not found theme={null}
  {
    "error": {
      "type": "CREDENTIAL_NOT_FOUND",
      "title": "Credential not found.",
      "detail": {
        "description": "The credential does not exist or you don't have access."
      },
      "status": 404,
      "instance": "/api/v1/credentials/a1b2c3d4-e5f6-7890-abcd-ef1234567890"
    }
  }
  ```
</ResponseExample>
