Skip to main content
PUT
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
components
/
{id}
Update Component
curl --request PUT \
  --url https://api.example.com/v1/organizations/{organizationId}/projects/{projectId}/components/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "content": "<string>",
  "collectionId": "<string>",
  "metadata": {
    "metadata.tags": [
      "<string>"
    ]
  }
}
'

Path Parameters

organizationId
string
required
Organization ID
projectId
string
required
Project ID
id
string
required
Component ID

Request Body

All fields are optional. Only provided fields will be updated.
name
string
Updated component name
content
string
Updated component source code (TypeScript)
collectionId
string
Move to different collection (null for root)
metadata
object

Example Request

{
  "content": "const metadata = () => ({\n  title: 'Product Card',\n  description: 'Updated description'\n});\n\nconst body = (props: ComponentProps) => {...};",
  "metadata": {
    "tags": ["product", "card", "updated"]
  }
}
When updating a published component, its status changes to modified. The TypeScript code in content is automatically recompiled.

Response

Returns the updated Component object.
{
  "id": "c123",
  "name": "ProductCard",
  "title": "Product Card",
  "description": "Updated description",
  "type": "view",
  "status": "modified",
  "version": null,
  "lastPublishedVersion": 2,
  "content": "...",
  "compiled": "...",
  "schema": {...},
  "metadata": {
    "tags": ["product", "card", "updated"]
  },
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-22T09:15:00Z"
}

Error Responses

Name Already Exists

{
  "error": {
    "code": "COMPONENT_NAME_EXISTS",
    "message": "A component with name 'ProductCard' already exists",
    "details": {
      "name": "ProductCard"
    }
  }
}

Compilation Error

{
  "error": {
    "code": "COMPILATION_ERROR",
    "message": "Failed to compile component",
    "details": {
      "line": 15,
      "column": 10,
      "error": "Unexpected token"
    }
  }
}

Not Found

{
  "error": {
    "code": "NOT_FOUND",
    "message": "Component not found"
  }
}

Code Examples

curl -X PUT "https://api.metabind.ai/v1/organizations/org123/projects/proj456/components/c123" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "tags": ["product", "card", "featured"]
    }
  }'