Update asset group
curl --request PATCH \
--url https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"name": "<string>"
}
'import requests
url = "https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}"
payload = { "name": "<string>" }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>'})
};
fetch('https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}"
payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>"
}{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}{
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Organization Asset Groups
Update Organization Asset Group
Rename an existing asset group.
PATCH
/
organization
/
asset-groups
/
{groupId}
Update asset group
curl --request PATCH \
--url https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId} \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"name": "<string>"
}
'import requests
url = "https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}"
payload = { "name": "<string>" }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>'})
};
fetch('https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}"
payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.chainpatrol.io/api/v2/organization/asset-groups/{groupId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>"
}{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}{
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Overview
Rename an existing asset group. This endpoint allows you to update the display name of a group belonging to your organization. All assets assigned to this group will remain assigned after the rename.Quick Start
Authentication
Include your API key in theX-API-KEY header:
X-API-KEY: your_api_key_here
Example Request
const response = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups/4",
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({
groupId: 4,
name: "Renamed Group",
}),
}
);
const data = await response.json();
console.log(data);
const response = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups/4",
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({
groupId: 4,
name: "Renamed Group",
}),
}
);
const data = await response.json();
console.log(data);
import requests
response = requests.patch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups/4",
headers={
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
json={
"groupId": 4,
"name": "Renamed Group",
},
)
data = response.json()
print(data)
curl -X PATCH 'https://app.chainpatrol.io/api/v2/organization/asset-groups/4' \
-H 'X-API-KEY: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"groupId": 4,
"name": "Renamed Group"
}'
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| groupId | number | Yes | ID of the group to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| groupId | number | Yes | ID of the group to update (must match path parameter) |
| name | string | Yes | New name for the group (1-255 characters) |
Response
Success Response
{
"id": 4,
"name": "Renamed Group"
}
Response Fields
| Field | Type | Description |
|---|---|---|
| id | number | Group ID |
| name | string | Updated group name |
Error Responses
400 Bad Request
Returned when the request is malformed or validation fails:{
"error": {
"code": "BAD_REQUEST",
"message": "Group name is required"
}
}
{
"error": {
"code": "BAD_REQUEST",
"message": "Group name must be between 1 and 255 characters"
}
}
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 group doesn’t belong to your organization:{
"error": {
"code": "FORBIDDEN",
"message": "Group does not belong to your organization"
}
}
404 Not Found
Returned when the group doesn’t exist:{
"error": {
"code": "NOT_FOUND",
"message": "Group with ID 4 not found"
}
}
409 Conflict
Returned when a group with the new name already exists:{
"error": {
"code": "CONFLICT",
"message": "A group with this name already exists"
}
}
Best Practices
Validation Before Rename
Check if a group with the target name already exists:async function safeRenameGroup(groupId: number, newName: string) {
// Check if name is already in use
const listResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
}
);
const { groups } = await listResponse.json();
const existingGroup = groups.find(
(g) => g.name.toLowerCase() === newName.toLowerCase() && g.id !== groupId
);
if (existingGroup) {
console.error(`Group name "${newName}" is already in use by group ${existingGroup.id}`);
return null;
}
// Proceed with rename
const updateResponse = await fetch(
`https://app.chainpatrol.io/api/v2/organization/asset-groups/${groupId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ groupId, name: newName }),
}
);
const updatedGroup = await updateResponse.json();
console.log(`Successfully renamed group to "${updatedGroup.name}"`);
return updatedGroup;
}
Bulk Rename with Prefix/Suffix
Add a prefix or suffix to multiple groups:async function addPrefixToGroups(prefix: string, groupIds: number[]) {
// First, get current group names
const listResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
}
);
const { groups } = await listResponse.json();
const results = [];
for (const groupId of groupIds) {
const group = groups.find((g) => g.id === groupId);
if (!group) {
results.push({ id: groupId, success: false, error: "Group not found" });
continue;
}
const newName = `${prefix}${group.name}`;
try {
const updateResponse = await fetch(
`https://app.chainpatrol.io/api/v2/organization/asset-groups/${groupId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ groupId, name: newName }),
}
);
if (updateResponse.ok) {
const updated = await updateResponse.json();
results.push({ id: groupId, success: true, newName: updated.name });
} else {
const error = await updateResponse.json();
results.push({ id: groupId, success: false, error: error.error.message });
}
} catch (error) {
results.push({ id: groupId, success: false, error: String(error) });
}
}
return results;
}
// Usage
addPrefixToGroups("Archive - ", [1, 2, 3]).then((results) => {
results.forEach((r) => {
if (r.success) {
console.log(`✓ Renamed group ${r.id} to "${r.newName}"`);
} else {
console.log(`✗ Failed to rename group ${r.id}: ${r.error}`);
}
});
});
Audit Trail
Log group renames for audit purposes:async function renameGroupWithAudit(
groupId: number,
newName: string,
renamedBy: string,
reason: string
) {
// Get current group details
const listResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
}
);
const { groups } = await listResponse.json();
const currentGroup = groups.find((g) => g.id === groupId);
if (!currentGroup) {
throw new Error(`Group ${groupId} not found`);
}
const oldName = currentGroup.name;
// Perform rename
const updateResponse = await fetch(
`https://app.chainpatrol.io/api/v2/organization/asset-groups/${groupId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ groupId, name: newName }),
}
);
const updatedGroup = await updateResponse.json();
// Create audit log
const auditLog = {
timestamp: new Date().toISOString(),
action: "GROUP_RENAMED",
groupId: groupId,
oldName: oldName,
newName: newName,
renamedBy: renamedBy,
reason: reason,
assetCount: currentGroup.assetCount,
};
console.log("Audit log:", JSON.stringify(auditLog));
// await sendToAuditSystem(auditLog);
return updatedGroup;
}
// Usage
await renameGroupWithAudit(
4,
"Legacy Wallets",
"admin@example.com",
"Reorganizing wallet groups by status"
);
Use Cases
Standardize Naming Convention
Rename groups to follow a consistent naming convention:async function standardizeGroupNames() {
const listResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
}
);
const { groups } = await listResponse.json();
// Define naming standards
const nameMapping = {
urls: "Official Websites",
wallets: "Blockchain Addresses",
social: "Social Media Accounts",
contracts: "Smart Contracts",
};
for (const group of groups) {
const lowerName = group.name.toLowerCase();
const standardName = nameMapping[lowerName];
if (standardName && standardName !== group.name) {
await fetch(
`https://app.chainpatrol.io/api/v2/organization/asset-groups/${group.id}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ groupId: group.id, name: standardName }),
}
);
console.log(`Renamed "${group.name}" to "${standardName}"`);
}
}
}
Migrate Group Structure
Rename groups as part of a structural migration:async function migrateGroupStructure() {
const migrations = [
{ oldName: "Production URLs", newName: "Prod - Websites" },
{ oldName: "Production Wallets", newName: "Prod - Addresses" },
{ oldName: "Staging URLs", newName: "Staging - Websites" },
{ oldName: "Staging Wallets", newName: "Staging - Addresses" },
];
const listResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
}
);
const { groups } = await listResponse.json();
for (const migration of migrations) {
const group = groups.find((g) => g.name === migration.oldName);
if (group) {
await fetch(
`https://app.chainpatrol.io/api/v2/organization/asset-groups/${group.id}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ groupId: group.id, name: migration.newName }),
}
);
console.log(`Migrated: "${migration.oldName}" → "${migration.newName}"`);
}
}
}
Interactive Rename
Provide an interactive interface for renaming:import * as readline from "readline";
async function interactiveRename(groupId: number) {
// Get current group details
const listResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
headers: { "X-API-KEY": "YOUR_API_KEY_HERE" },
}
);
const { groups } = await listResponse.json();
const group = groups.find((g) => g.id === groupId);
if (!group) {
console.error("Group not found");
return;
}
console.log(`\nCurrent group name: "${group.name}"`);
console.log(`Asset count: ${group.assetCount}\n`);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question("Enter new name (or press Enter to cancel): ", async (newName) => {
if (!newName.trim()) {
console.log("Rename cancelled");
rl.close();
return;
}
const updateResponse = await fetch(
`https://app.chainpatrol.io/api/v2/organization/asset-groups/${groupId}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ groupId, name: newName }),
}
);
if (updateResponse.ok) {
const updated = await updateResponse.json();
console.log(`\n✓ Group renamed to "${updated.name}"`);
} else {
const error = await updateResponse.json();
console.error(`\n✗ Failed to rename: ${error.error.message}`);
}
rl.close();
});
}
Common Error Messages
| Error Message | Cause | Resolution |
|---|---|---|
| Group with ID not found | Invalid group ID | Verify the group ID exists |
| Group does not belong to your organization | Group belongs to a different organization | Use a group ID from your organization |
| A group with this name already exists | Duplicate group name | Choose a different name |
| Group name is required | Missing name field in request | Provide a name field |
| Group name must be between 1 and 255 characters | Name is too short or too long | Use a name with 1-255 characters |
| Path parameter groupId does not match body | Mismatch between URL and body group IDs | Ensure both group IDs match |
Notes
- Group names must be unique within your organization
- Names are case-sensitive for uniqueness checks
- All assets assigned to the group remain assigned after rename
- Organization is automatically determined from your API key
- The group ID must match in both the URL path and request body
- Renaming a group does not affect asset assignments or asset metadata
- Group’s asset count is not affected by rename operations
Authorizations
Your API key. This is required by most endpoints to access our API programatically. Reach out to us at support@chainpatrol.io to get an API key for your use.
Path Parameters
ID of the group to update
Required range:
x > 0Body
application/json
Required string length:
1 - 255Was this page helpful?
⌘I