Discard Changes
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discardimport requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard', 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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyComponents
Discard Changes
Discard unpublished changes and revert to last published version
POST
/
app
/
v1
/
organizations
/
{organizationId}
/
projects
/
{projectId}
/
components
/
{id}
/
discard
Discard Changes
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discardimport requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard', 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://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/projects/{projectId}/components/{id}/discard")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyPath Parameters
string
required
Organization ID
string
required
Project ID
string
required
Component ID
Request Body
No request body required.Behavior
Discard resets a component to its last published version:- Only works for components with
draftormodifiedstatus - Component must have been previously published (have a
lastPublishedVersion) - All unpublished changes are permanently discarded
- Status returns to
published
This action cannot be undone. All unpublished changes will be permanently lost.
Response
Returns the Component object withpublished 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
Onlydraft or modified components can have changes discarded.
{
"error": {
"code": "INVALID_STATUS",
"message": "Only draft or modified components can be discarded"
}
}
No Published Version
Draft components that have never been published cannot be discarded.{
"error": {
"code": "NO_PUBLISHED_VERSION",
"message": "Cannot discard a component that has never been published"
}
}
Code Examples
curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/components/c123/discard" \
-H "Authorization: Bearer YOUR_JWT"
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/components/c123/discard',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT'
}
}
);
const component = await response.json();