Skip to main content
POST
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
components
/
{id}
/
discard
Discard Changes
curl --request POST \
  --url https://api.example.com/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard

Path Parameters

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

Request Body

No request body required.

Behavior

Discard resets a component to its last published version:
  1. Only works for components with draft or modified status
  2. Component must have been previously published (have a lastPublishedVersion)
  3. All unpublished changes are permanently discarded
  4. Status returns to published
This action cannot be undone. All unpublished changes will be permanently lost.

Response

Returns the Component object with published status.
{
  "id": "c123",
  "name": "ProductCard",
  "status": "published",
  "version": 2,
  "lastPublishedVersion": 2,
  "content": "// Content reset to match version 2",
  "compiled": "...",
  "schema": {...},
  "metadata": {
    "discardedAt": "2024-03-22T10:00:00Z",
    "discardedBy": "user123"
  },
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-22T10:00:00Z"
}

Error Responses

Invalid Status

Only draft or modified components can have changes discarded.
{
  "error": {
    "code": "INVALID_STATUS",
    "message": "Can only discard changes for draft or modified components",
    "details": {
      "currentStatus": "published"
    }
  }
}

No Published Version

Draft components that have never been published cannot be discarded.
{
  "error": {
    "code": "NO_PUBLISHED_VERSION",
    "message": "Cannot discard - component has never been published",
    "details": {
      "hint": "Use DELETE to remove unpublished draft components"
    }
  }
}

Code Examples

curl -X POST "https://api.metabind.ai/v1/organizations/org123/projects/proj456/components/c123/discard" \
  -H "Authorization: Bearer YOUR_API_KEY"