Widget update
Endpoint PUT /widgets/:id
Update a user's widget data.
Path Parameters
Required
id
- The widget's id.
Body Parameters
name
- The name of the widgetdescription
- The description of the widgetstatus
- The status of the widget (draft
orpublished
)data
- The widget's data. The structure of this data will depend on the widget type. You can explore the different schemas with the Widget Data Explorer Tool tool.
All parameters are optional
You can update only the parameters you want to change. There's no need to send all the parameters.
Example Request:
- curl
- Node.js
curl -X PUT -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "name": "Widget name updated!" }' "https://api.commoninja.com/platform/api/v1/widgets/894f5aed-29f5-46c5-9f26-022bfccc5292"
const axios = require('axios');
async function getData() {
const data = {
name: 'Widget name updated!'
};
const response = await axios.put('https://api.commoninja.com/platform/api/v1/widgets/894f5aed-29f5-46c5-9f26-022bfccc5292', data, {
headers: {
'Authorization': 'Bearer ACCESS_TOKEN',
'Content-Type': 'application/json'
}
});
return response.data;
}
getData();
Example Response:
{
"id": "894f5aed-29f5-46c5-9f26-022bfccc5292",
"name": "Widget name updated!",
"description": "",
"type": "comparison_table",
"previewImage": "",
"status": "draft",
"projectId": "",
"modelVersion": 1,
"created": "2023-04-25T09:44:42.842Z",
"updated": "2023-04-25T09:44:42.842Z",
"data": {}
}