> ## Documentation Index
> Fetch the complete documentation index at: https://chainpatrol-knowledge-update-blockaid-and-hypernative-partn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Organization Asset

> Update an asset's name, description, or group assignment. The asset must belong to your organization.

## Overview

Update an asset's name, description, or group assignment. This endpoint allows you to modify metadata for assets belonging to your organization. The asset's content and type cannot be changed - create a new asset if you need to modify these fields.

## Quick Start

### Authentication

Include your API key in the `X-API-KEY` header:

```bash theme={null}
X-API-KEY: your_api_key_here
```

### Example Request

<CodeGroup>
  ```typescript TypeScript theme={null}
  const response = await fetch(
    "https://app.chainpatrol.io/api/v2/organization/assets/12345",
    {
      method: "PATCH",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY_HERE",
      },
      body: JSON.stringify({
        assetId: 12345,
        name: "Updated Name",
        description: "Updated description",
        groupId: 2,
      }),
    }
  );

  const data = await response.json();
  console.log(data);
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://app.chainpatrol.io/api/v2/organization/assets/12345",
    {
      method: "PATCH",
      headers: {
        "Content-Type": "application/json",
        "X-API-KEY": "YOUR_API_KEY_HERE",
      },
      body: JSON.stringify({
        assetId: 12345,
        name: "Updated Name",
        description: "Updated description",
        groupId: 2,
      }),
    }
  );

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.patch(
      "https://app.chainpatrol.io/api/v2/organization/assets/12345",
      headers={
          "Content-Type": "application/json",
          "X-API-KEY": "YOUR_API_KEY_HERE",
      },
      json={
          "assetId": 12345,
          "name": "Updated Name",
          "description": "Updated description",
          "groupId": 2,
      },
  )

  data = response.json()
  print(data)
  ```

  ```bash cURL theme={null}
  curl -X PATCH 'https://app.chainpatrol.io/api/v2/organization/assets/12345' \
    -H 'X-API-KEY: YOUR_API_KEY_HERE' \
    -H 'Content-Type: application/json' \
    -d '{
      "assetId": 12345,
      "name": "Updated Name",
      "description": "Updated description",
      "groupId": 2
    }'
  ```
</CodeGroup>

## Path Parameters

| Parameter | Type   | Required | Description               |
| --------- | ------ | -------- | ------------------------- |
| assetId   | number | Yes      | ID of the asset to update |

## Request Body

| Field       | Type           | Required | Description                                                                   |
| ----------- | -------------- | -------- | ----------------------------------------------------------------------------- |
| assetId     | number         | Yes      | ID of the asset to update (must match path parameter)                         |
| name        | string         | No       | New display name for the asset. Omit to leave unchanged.                      |
| description | string \| null | No       | New description for the asset. Pass `null` to clear. Omit to leave unchanged. |
| groupId     | number \| null | No       | New group ID to assign. Pass `null` to ungroup. Omit to leave unchanged.      |

<Note>
  At least one of `name`, `description`, or `groupId` must be provided to update the asset.
</Note>

## Response

### Success Response

```json theme={null}
{
  "id": 12345,
  "content": "https://example.com",
  "name": "Updated Name",
  "description": "Updated description",
  "groupId": 2
}
```

### Response Fields

| Field       | Type           | Description                           |
| ----------- | -------------- | ------------------------------------- |
| id          | number         | Asset ID                              |
| content     | string         | Asset content (unchanged)             |
| name        | string         | Updated display name                  |
| description | string \| null | Updated description (null if cleared) |
| groupId     | number \| null | Updated group ID (null if ungrouped)  |

## Update Operations

### Update Name Only

```typescript theme={null}
const response = await fetch(
  "https://app.chainpatrol.io/api/v2/organization/assets/12345",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": "YOUR_API_KEY_HERE",
    },
    body: JSON.stringify({
      assetId: 12345,
      name: "New Display Name",
    }),
  }
);
```

### Update Description Only

```typescript theme={null}
const response = await fetch(
  "https://app.chainpatrol.io/api/v2/organization/assets/12345",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": "YOUR_API_KEY_HERE",
    },
    body: JSON.stringify({
      assetId: 12345,
      description: "Updated asset description",
    }),
  }
);
```

### Clear Description

```typescript theme={null}
const response = await fetch(
  "https://app.chainpatrol.io/api/v2/organization/assets/12345",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": "YOUR_API_KEY_HERE",
    },
    body: JSON.stringify({
      assetId: 12345,
      description: null,
    }),
  }
);
```

### Change Group Assignment

Move asset to a different group:

```typescript theme={null}
const response = await fetch(
  "https://app.chainpatrol.io/api/v2/organization/assets/12345",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": "YOUR_API_KEY_HERE",
    },
    body: JSON.stringify({
      assetId: 12345,
      groupId: 3,
    }),
  }
);
```

### Ungroup Asset

Remove asset from all groups:

```typescript theme={null}
const response = await fetch(
  "https://app.chainpatrol.io/api/v2/organization/assets/12345",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": "YOUR_API_KEY_HERE",
    },
    body: JSON.stringify({
      assetId: 12345,
      groupId: null,
    }),
  }
);
```

### Update Multiple Fields

```typescript theme={null}
const response = await fetch(
  "https://app.chainpatrol.io/api/v2/organization/assets/12345",
  {
    method: "PATCH",
    headers: {
      "Content-Type": "application/json",
      "X-API-KEY": "YOUR_API_KEY_HERE",
    },
    body: JSON.stringify({
      assetId: 12345,
      name: "Treasury Multi-Sig",
      description: "Main treasury wallet with 3/5 multisig",
      groupId: 2,
    }),
  }
);
```

## Error Responses

### 400 Bad Request

Returned when the request is malformed or contains invalid data:

```json theme={null}
{
  "error": {
    "code": "BAD_REQUEST",
    "message": "At least one field (name, description, or groupId) must be provided"
  }
}
```

### 401 Unauthorized

Returned when the API key is missing, invalid, or doesn't have organization access:

```json theme={null}
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "API key with organization access required"
  }
}
```

### 403 Forbidden

Returned when the asset doesn't belong to your organization:

```json theme={null}
{
  "error": {
    "code": "FORBIDDEN",
    "message": "Asset does not belong to your organization"
  }
}
```

### 404 Not Found

Returned when the asset ID or group ID doesn't exist:

```json theme={null}
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Asset with ID 12345 not found"
  }
}
```

## Common Error Messages

| Error Message                              | Cause                                     | Resolution                                  |
| ------------------------------------------ | ----------------------------------------- | ------------------------------------------- |
| Asset with ID {id} not found               | Invalid asset ID                          | Verify the asset ID exists                  |
| Asset does not belong to your organization | Asset belongs to a different organization | Use an asset ID from your organization      |
| Group with ID {id} not found               | Invalid group ID                          | Use a valid group ID from your organization |
| At least one field must be provided        | Empty update request                      | Provide at least one field to update        |
| Path parameter assetId does not match body | Mismatch between URL and body asset IDs   | Ensure both asset IDs match                 |

## Best Practices

### Field Updates

* **Partial updates**: Only include fields you want to change
* **Null vs. omit**:
  * Pass `null` to clear a field (description, groupId)
  * Omit the field to leave it unchanged
* **Validation**: Validate group IDs exist before updating

### Bulk Updates

When updating multiple assets, process them sequentially or in small batches:

```typescript theme={null}
async function updateMultipleAssets(updates: Array<{ id: number; data: any }>) {
  const results = [];

  for (const update of updates) {
    try {
      const response = await fetch(
        `https://app.chainpatrol.io/api/v2/organization/assets/${update.id}`,
        {
          method: "PATCH",
          headers: {
            "Content-Type": "application/json",
            "X-API-KEY": "YOUR_API_KEY_HERE",
          },
          body: JSON.stringify({
            assetId: update.id,
            ...update.data,
          }),
        }
      );

      const data = await response.json();
      results.push({ id: update.id, success: true, data });
    } catch (error) {
      results.push({ id: update.id, success: false, error });
    }
  }

  return results;
}

// Update multiple assets
const updates = [
  { id: 12345, data: { name: "Updated Name 1" } },
  { id: 12346, data: { groupId: 2 } },
  { id: 12347, data: { description: null } },
];

updateMultipleAssets(updates)
  .then((results) => console.log("Update results:", results));
```

### Error Handling

* Verify asset ownership before updating (check if asset belongs to your organization)
* Validate group IDs before assignment
* Handle 404 errors gracefully (asset may have been deleted)
* Log failed updates for auditing

## Use Cases

### Organize Assets into Groups

```typescript theme={null}
// Move all URL assets to "Websites" group
async function organizeURLAssets() {
  // First, get all URL assets
  const listResponse = await fetch(
    "https://app.chainpatrol.io/api/v2/organization/assets?type=URL",
    {
      headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
    }
  );
  const { assets } = await listResponse.json();

  // Then update each to assign to group
  for (const asset of assets) {
    await fetch(
      `https://app.chainpatrol.io/api/v2/organization/assets/${asset.id}`,
      {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          "X-API-KEY": "YOUR_API_KEY_HERE",
        },
        body: JSON.stringify({
          assetId: asset.id,
          groupId: 1, // Websites group
        }),
      }
    );
  }
}
```

### Add Descriptions to Assets

```typescript theme={null}
// Add descriptions to assets that don't have them
async function addDescriptions(assetDescriptions: Map<number, string>) {
  for (const [assetId, description] of assetDescriptions) {
    await fetch(
      `https://app.chainpatrol.io/api/v2/organization/assets/${assetId}`,
      {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          "X-API-KEY": "YOUR_API_KEY_HERE",
        },
        body: JSON.stringify({
          assetId,
          description,
        }),
      }
    );
  }
}
```

## Notes

* Asset content and type cannot be modified - create a new asset if needed
* Only assets belonging to your organization can be updated
* Organization is automatically determined from your API key
* All update operations are atomic - either all fields update or none do
* The response contains the updated asset information
* Asset's `updatedAt` timestamp will be updated when any field changes


## OpenAPI

````yaml PATCH /organization/assets/{assetId}
openapi: 3.0.3
info:
  title: ChainPatrol External API - OpenAPI 3.0
  description: ChainPatrol External API documentation
  version: 2.0.0
servers:
  - url: https://app.chainpatrol.io/api/v2
security: []
tags:
  - name: asset
  - name: report
externalDocs:
  url: https://chainpatrol.com/docs
paths:
  /organization/assets/{assetId}:
    patch:
      tags:
        - organization
      summary: Update organization asset
      description: >-
        Update an asset's name, description, or group assignment. The asset must
        belong to your organization.
      operationId: organizationAssetsUpdate
      parameters:
        - in: path
          name: assetId
          description: ID of the asset to update
          schema:
            type: integer
            minimum: 0
            exclusiveMinimum: true
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
                  nullable: true
                groupId:
                  type: integer
                  nullable: true
                  minimum: 0
                  exclusiveMinimum: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: number
                  content:
                    type: string
                  name:
                    type: string
                    nullable: true
                  description:
                    type: string
                    nullable: true
                  groupId:
                    type: number
                    nullable: true
                required:
                  - id
                  - content
                  - name
                  - description
                  - groupId
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '401':
          description: Authorization not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.UNAUTHORIZED'
        '403':
          description: Insufficient access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.FORBIDDEN'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.NOT_FOUND'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
      security:
        - ApiKey: []
components:
  schemas:
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Invalid input data error (400)
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.UNAUTHORIZED:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Authorization not provided
        code:
          type: string
          description: The error code
          example: UNAUTHORIZED
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Authorization not provided error (401)
      description: The error information
      example:
        code: UNAUTHORIZED
        message: Authorization not provided
        issues: []
    error.FORBIDDEN:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Insufficient access
        code:
          type: string
          description: The error code
          example: FORBIDDEN
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Insufficient access error (403)
      description: The error information
      example:
        code: FORBIDDEN
        message: Insufficient access
        issues: []
    error.NOT_FOUND:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Not found
        code:
          type: string
          description: The error code
          example: NOT_FOUND
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Not found error (404)
      description: The error information
      example:
        code: NOT_FOUND
        message: Not found
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Internal server error error (500)
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        Your API key. This is required by most endpoints to access our API
        programatically. Reach out to us at
        [support@chainpatrol.io](mailto:support@chainpatrol.io?subject=Re:%20API%20Key%20for%20SDK&body=Company:%20%0AName:%20%0APurpose:%20)
        to get an API key for your use.

````