Write API — target specific block or instance, not entire page

I’m trying to build a process to programmatically make changes to all instances of a block. The goal is to be able to change a block’s API and migrate the data of all existing instances.

For example we would want to change the size input in a block called Heading from being an enum of ["large","small"] into a number from 1 to 5, and replace all instances of "large" with 4 and instances of "small" to 2.

Ideally I would be able to query the database and find every instance of Heading, and change the size field of each instance. However, the docs (Builder.io Write API - Builder.io) only show the ability to target entire pages. Is there any way to target every instance of a specific block? Targeting instances by their ID would also be fine, since I can get those from a general query.

This is possible:

Once transformed, you’ll get a new json of the content that you can use to send a POST to the write API

1 Like