Create asset group
curl --request POST \
--url https://app.chainpatrol.io/api/v2/organization/asset-groups \
--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"
payload = { "name": "<string>" }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
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', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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"
payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://app.chainpatrol.io/api/v2/organization/asset-groups")
.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")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Organization Asset Groups
Create Organization Asset Group
Create a new asset group for organizing your organization’s assets.
POST
/
organization
/
asset-groups
Create asset group
curl --request POST \
--url https://app.chainpatrol.io/api/v2/organization/asset-groups \
--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"
payload = { "name": "<string>" }
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
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', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
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"
payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://app.chainpatrol.io/api/v2/organization/asset-groups")
.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")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.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": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Overview
Create a new asset group for organizing your organization’s assets. Groups help you categorize assets by type, project, purpose, or any other criteria that makes sense for your use case.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",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({
name: "New Group",
}),
}
);
const data = await response.json();
console.log(data);
const response = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({
name: "New Group",
}),
}
);
const data = await response.json();
console.log(data);
import requests
response = requests.post(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
headers={
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
json={
"name": "New Group",
},
)
data = response.json()
print(data)
curl -X POST 'https://app.chainpatrol.io/api/v2/organization/asset-groups' \
-H 'X-API-KEY: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"name": "New Group"
}'
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Name for the new group (1-255 characters) |
Response
Success Response
{
"id": 4,
"name": "New Group"
}
Response Fields
| Field | Type | Description |
|---|---|---|
| id | number | Unique identifier for the group |
| name | string | Name of the created group |
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"
}
}
409 Conflict
Returned when a group with the same name already exists:{
"error": {
"code": "CONFLICT",
"message": "A group with this name already exists"
}
}
Best Practices
Naming Conventions
Use clear, descriptive names that reflect the group’s purpose:// Good examples
await createGroup("Official Websites");
await createGroup("Treasury Wallets");
await createGroup("Social Media Accounts");
await createGroup("Smart Contracts - Production");
await createGroup("Smart Contracts - Testnet");
// Avoid
await createGroup("Group1"); // Not descriptive
await createGroup("Misc"); // Too vague
await createGroup("test"); // Not professional
Check for Existing Groups
Before creating a group, check if one with the same name already exists:async function createGroupIfNotExists(groupName: string) {
// Check if group already exists
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() === groupName.toLowerCase()
);
if (existingGroup) {
console.log(`Group "${groupName}" already exists with ID ${existingGroup.id}`);
return existingGroup;
}
// Create new group
const createResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ name: groupName }),
}
);
const newGroup = await createResponse.json();
console.log(`Created new group "${groupName}" with ID ${newGroup.id}`);
return newGroup;
}
Batch Group Creation
Create multiple groups in sequence:async function createMultipleGroups(groupNames: string[]) {
const results = [];
for (const name of groupNames) {
try {
const response = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ name }),
}
);
if (response.ok) {
const group = await response.json();
results.push({ name, success: true, id: group.id });
} else {
const error = await response.json();
results.push({ name, success: false, error: error.error.message });
}
} catch (error) {
results.push({ name, success: false, error: String(error) });
}
}
return results;
}
// Usage
const groupNames = ["Websites", "Wallets", "Social Media", "Contracts"];
createMultipleGroups(groupNames).then((results) => {
const successful = results.filter((r) => r.success).length;
console.log(`Created ${successful} of ${results.length} groups`);
results.forEach((r) => {
if (r.success) {
console.log(`✓ ${r.name} (ID: ${r.id})`);
} else {
console.log(`✗ ${r.name}: ${r.error}`);
}
});
});
Use Cases
Initialize Group Structure
Set up a standard group structure for a new organization:async function initializeGroupStructure() {
const standardGroups = [
"Official Websites",
"Documentation Sites",
"Blockchain Addresses",
"Smart Contracts",
"Twitter Accounts",
"Discord Servers",
"Telegram Channels",
"GitHub Repositories",
"Email Addresses",
"Other Assets",
];
console.log("Initializing group structure...");
for (const groupName of standardGroups) {
const response = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ name: groupName }),
}
);
if (response.ok) {
const group = await response.json();
console.log(`✓ Created "${groupName}" (ID: ${group.id})`);
} else {
console.log(`✗ Failed to create "${groupName}"`);
}
}
console.log("Group structure initialization complete");
}
Project-Based Groups
Create groups for different projects:async function createProjectGroups(projectName: string) {
const groupTypes = ["URLs", "Wallets", "Contracts", "Socials"];
const groups = [];
for (const type of groupTypes) {
const groupName = `${projectName} - ${type}`;
const response = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ name: groupName }),
}
);
if (response.ok) {
const group = await response.json();
groups.push(group);
console.log(`Created group: ${groupName}`);
}
}
return groups;
}
// Usage
createProjectGroups("DeFi Protocol").then((groups) => {
console.log(`Created ${groups.length} groups for project`);
});
Environment-Based Groups
Organize by environment (production, staging, development):async function createEnvironmentGroups() {
const environments = ["Production", "Staging", "Development"];
const categories = ["URLs", "APIs", "Contracts"];
for (const env of environments) {
for (const category of categories) {
const groupName = `${env} - ${category}`;
await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ name: groupName }),
}
);
console.log(`Created: ${groupName}`);
}
}
}
Dynamic Group Creation
Create groups dynamically based on asset type:async function ensureGroupForAssetType(assetType: string) {
const groupName = `${assetType} Assets`;
// Check if group exists
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 === groupName);
if (existingGroup) {
return existingGroup.id;
}
// Create new group
const createResponse = await fetch(
"https://app.chainpatrol.io/api/v2/organization/asset-groups",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY_HERE",
},
body: JSON.stringify({ name: groupName }),
}
);
const newGroup = await createResponse.json();
return newGroup.id;
}
// Usage: Automatically create groups as needed
const urlGroupId = await ensureGroupForAssetType("URL");
const addressGroupId = await ensureGroupForAssetType("ADDRESS");
Common Error Messages
| Error Message | Cause | Resolution |
|---|---|---|
| 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 |
| A group with this name already exists | Duplicate group name | Use a different name or use existing group |
Notes
- Group names must be unique within your organization
- Names are case-sensitive for uniqueness checks
- Group names have a maximum length of 255 characters
- Organization is automatically determined from your API key
- Newly created groups start with zero assets
- Groups can be renamed later using the update endpoint
- There is no hard limit on the number of groups per organization
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.
Body
application/json
Required string length:
1 - 255Was this page helpful?
⌘I