Skip to main content
PATCH
/
organization
/
assets
/
{assetId}
Update organization asset
curl --request PATCH \
  --url https://app.chainpatrol.io/api/v2/organization/assets/{assetId} \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "name": "<string>",
  "description": "<string>",
  "groupId": 1
}
'
{
  "id": 123,
  "content": "<string>",
  "name": "<string>",
  "description": "<string>",
  "groupId": 123
}

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:
X-API-KEY: your_api_key_here

Example Request

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);

Path Parameters

ParameterTypeRequiredDescription
assetIdnumberYesID of the asset to update

Request Body

FieldTypeRequiredDescription
assetIdnumberYesID of the asset to update (must match path parameter)
namestringNoNew display name for the asset. Omit to leave unchanged.
descriptionstring | nullNoNew description for the asset. Pass null to clear. Omit to leave unchanged.
groupIdnumber | nullNoNew group ID to assign. Pass null to ungroup. Omit to leave unchanged.
At least one of name, description, or groupId must be provided to update the asset.

Response

Success Response

{
  "id": 12345,
  "content": "https://example.com",
  "name": "Updated Name",
  "description": "Updated description",
  "groupId": 2
}

Response Fields

FieldTypeDescription
idnumberAsset ID
contentstringAsset content (unchanged)
namestringUpdated display name
descriptionstring | nullUpdated description (null if cleared)
groupIdnumber | nullUpdated group ID (null if ungrouped)

Update Operations

Update Name Only

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

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

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:
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:
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

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:
{
  "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:
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "API key with organization access required"
  }
}

403 Forbidden

Returned when the asset doesn’t belong to your organization:
{
  "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:
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Asset with ID 12345 not found"
  }
}

Common Error Messages

Error MessageCauseResolution
Asset with ID not foundInvalid asset IDVerify the asset ID exists
Asset does not belong to your organizationAsset belongs to a different organizationUse an asset ID from your organization
Group with ID not foundInvalid group IDUse a valid group ID from your organization
At least one field must be providedEmpty update requestProvide at least one field to update
Path parameter assetId does not match bodyMismatch between URL and body asset IDsEnsure 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:
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

// 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

// 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

Authorizations

X-API-KEY
string
header
required

Your API key. This is required by most endpoints to access our API programatically. Reach out to us at [email protected] to get an API key for your use.

Path Parameters

assetId
integer
required

ID of the asset to update

Required range: x > 0

Body

application/json
name
string
description
string | null
groupId
integer | null
Required range: x > 0

Response

Successful response

id
number
required
content
string
required
name
string | null
required
description
string | null
required
groupId
number | null
required