Skip to main content

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 failed
  • 401 - Unauthorized
  • 403 - Access denied
  • 500 - 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 provided
  • email: Valid email format if provided
  • website: Valid URL format if provided
  • visibility: Must match user permissions