Skip to main content

Widget create

Endpoint POST /widgets

Create a new widget.

Body Parameters

Required
  • type - The type of the widget (bracket, comparison_table, chart, etc.)
  • name - The name of the widget
  • status - The status of the widget (draft or published)
Optional
  • 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. If not provided, a default data will be used.
  • description - The description of the widget
  • projectId - The related project ID of the widget
  • modelVersion - The version of the widget's data model. This is used to determine the schema of the data field. If not provided, the latest version will be used.

Example Request:

curl -X POST -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" -d '{ "name": "New Widget", "type": "bracket", "data": {} }' "https://api.commoninja.com/platform/api/v1/widgets"

Example Response:

{
"id": "894f5aed-29f5-46c5-9f26-022bfccc5292",
"name": "New Widget",
"description": "",
"type": "comparison_table",
"previewImage": "",
"projectId": "",
"status": "draft",
"modelVersion": 1,
"created": "2023-04-25T09:44:42.842Z",
"updated": "2023-04-25T09:44:42.842Z",
"data": {},
"embedCode": {
"html": "<div class=\"commonninja_component pid-894f5aed-29f5-46c5-9f26-022bfccc5292\"></div>",
"script": "<script src=\"https://cdn.commoninja.com/sdk/latest/commonninja.js\" defer></script>"
},
"editorUrl": "https://www.commoninja.com/comparison-tables/editor/view/894f5aed-29f5-46c5-9f26-022bfccc5292"
}