Bulk create with relationships in the Data API

I have a quick question about the Data API and how relationships work when doing a bulk create.

Let’s say I have two data types:

  • Host

  • Property

I want to bulk create around 100 Properties and link each one to its respective Host.

What exactly should I send to the bulk create endpoint to make that link happen?
Do I just include the Host’s unique ID in the Property’s Host field, or is there another way to do it?

Basically, I’m wondering: can you bulk create items that have relationships, and if so, what’s the right way to pass those relationships in the request?

Thanks!

As far as I know, that is indeed the way to go.

FYI: if I’m not mistaken, you can set an option set by using its “Display” value. But I can’t remember what happens if you have non-unique values in the Option Set…

When you say non-unique values in the option set do you mean something like an option set of Colors where there is a list of options with displays like Red, Blue, Red, Orange…where Red is a non-unique value? If so, Bubble creates IDs for the option set behind the scenes I think, so that the first Red is Red but the second is something else, so if using Red as the value in the API call, it will be the first Red and not the second. Not 100% sure as I have not tested it, but that is my assumption based on how Bubble assigns IDs to custom data type field labels. It might follow a similar pattern to the IDs of Slugs where Bubble appends -1 or -2 to each slug that already exists on another record of the same custom data type.

1 Like