Entity Update API
Overviewβ
Update existing entities with new information and metadata.
Endpointβ
- URL:
/api/entities/update/[id]
- Method:
PATCH
- Auth: Required (MEMBER+ role)
URL Parametersβ
id
(string, required): Entity ID to update
Request Bodyβ
interface UpdateEntityRequest {
name?: string;
description?: string;
website?: string;
email?: string;
phone?: string;
address?: string;
category?: string;
tags?: string[];
visibility?: 'public' | 'member' | 'confidential';
logo?: string;
// ... other entity fields
}
Example Requestβ
{
"name": "Updated Company Name",
"description": "Updated company description",
"website": "https://newwebsite.com",
"tags": ["updated", "technology", "innovation"]
}
Responseβ
Success (200 OK)β
{
"message": "Entity updated successfully"
}
Errorsβ
400
- Invalid JSON or update failed401
- Unauthorized403
- Access denied500
- Server error
Code Exampleβ
async function updateEntity(id: string, updates: Partial<Entity>) {
const response = await fetch(`/api/entities/update/${id}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(updates)
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error);
}
return response.json();
}
// Usage
await updateEntity('entity_123', {
name: 'New Name',
description: 'Updated description'
});
Validation Rulesβ
- Only provided fields are updated
name
: 1-100 characters if providedemail
: Valid email format if providedwebsite
: Valid URL format if providedvisibility
: Must match user permissions
Related Endpointsβ
- Get Entity - Retrieve entity details
- Create Entity - Create new entity
- Delete Entity - Remove entity