Creating Data Models via API with Relations

Hi! We're just onboarding onto Twenty and are really loving what y'all are doing here so far! We're looking into building some API integrations to automatically create tasks, notes and other custom data models that we have. However, all of the create REST APIs don't seem to expose a way to define any relations on the created data model. Is this currently possible via API?
5 Replies
Prastoin
Prastoin3w ago
Hey @thedappercamper, unless I'm mistaken you can do anything the same way using the REST than for the GRAPHQL one @martmull could you please confirm >?
martmull
martmull3w ago
@thedappercamper @prastoin, no we cannot create relations via api rest for now. I create a ticket to allow that. Waiting that, we should create related objects, then assign them to the parent object using create or update endpoint
Prastoin
Prastoin3w ago
I didn't know ! Thanks Martin !
thedappercamper
thedappercamperOP3w ago
@martmull got it. so we create the objects first, and then i'll have to use the graphql API to relate them? is there an example available on how to do this? or any documentation? specifically for notes/tasks. for custom data models it seems like i can just update the appropriate id field on the object to relate it with another object via the graphql api. but how do i properly relate notes and tasks to other objects?
martmull
martmull3w ago
Yes you create children records, then the parent one and link children using the uuid join column. For example companyId. It depends on your parent object and what name did you use to create the relation. You can do that using the graphql api or the REST api You can also create the parent and the children records, then query one child using find one query with depth=1. It will gives you the join columns you need to update to link your child record to its parent. Then you update the children to set the join column value to the parent record id using update one endpoint No documentation for now sorry

Did you find this page helpful?