Using the Write API
The Write API is a way to programmatically update your Plasmic projects.
Authentication
The Write API can only be requested if you have a secret token authorization to access the requested project.
In the request for the endpoint you should include x-plasmic-api-project-token
in the headers. The field has to be set in the following way.
{"x-plasmic-api-project-tokens": "PROJECTID:SECRETTOKEN"}
Where PROJECTID
is the id of the project that you are request, and SECRETTOKEN
is a token that will indicate if you are authorized to perform the request.
Secret tokens are currently only available for enterprise customers.
Update projects
You can currently make a few specific types of updates to Plasmic projects.
Called with the POST
method at
https://studio.plasmic.app/api/v1/projects
/PROJECTID
Note: calling this will cause the project to refresh for anyone who has it open in their browser.
Example body:
{"newComponents": [{"name": "MyNewPage", // must be a unique name"path": "/home", // if set, is a page component// Same type system as element types used in code components:// https://docs.plasmic.app/learn/code-components-ref/#element-types"body": {"type": "hbox","children": [{"type": "text","value": "Hello world"}]}}],"updateComponents": [// Same as newComponents, but will upsert based on matched component// name, path, or UUID instead.{"byUuid": "...", // to select by UUID"name": "...", // to select by name"path": "..." // to select by path// ...specify any properties to change}],"tokens": [{"name": "...","value": "...","type": "Color" // "Color"|"Spacing"|"Opacity"|"LineHeight"|"FontFamily"|"FontSize"|"BoxShadow"}]}
Example response includes identifying info about newly created components:
{"newComponents": [{"uuid": "...","path": "...","name": "..."}]}
Have feedback on this page? Let us know on our forum.