# Inserting relation through the API

**URL:** <https://connect.superhuman.com/t/inserting-relation-through-the-api/42955>\
**Category:** Developers Central\
**Created:** [September 20, 2023, 2:34pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955 "2023-09-20T14:34:11Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian\_Lefebvre2](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/florian_lefebvre2/32/37743_2.png) [@Florian\_Lefebvre2](https://connect.superhuman.com/u/Florian_Lefebvre2)\
**Post date:** [September 20, 2023, 2:34pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/1 "2023-09-20T14:34:11Z")

</div>

Hi,

I am trying to insert data into a table. One of the values I would like to insert is a relation to another table.  
I would like to use the row ID of the data in the other table, rather than using the display value. If I try something like this :

```auto
{
    "rows": [
        {
            "cells": [
                {
                    "column": "c-m8h7K3TEJ3",
                    "value": "Test Name "
                },
                {
                    "column": "c-fJY8WCIJFO",
                    "value": 
                       ["c-qiqWjlS4ij"]
                    
                }
            ]
        }
    ]
}

```

as my API insert call, I will have a broken reference in my column, as it will have tried to insert the text “c-qiqWjlS4ij” itself.

Is there any way to use IDs in insert ? I could not find anything in the documentation or the forum.

Thank you very much !  
Florian.

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [September 20, 2023, 5:41pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/2 "2023-09-20T17:41:49Z")

</div>

Hi @Florian_Lefebvre2 - Unfortunately not. 🙁 At the moment the only option is to use the display value of the target row, which I understand is quite error prone. We are tracking this request internally, and I’ll bump it again.

---

<div class="post-metadata">

**Author:** ![Joel\_Szwarga](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/joel_szwarga/32/6562_2.png) [@Joel\_Szwarga](https://connect.superhuman.com/u/Joel_Szwarga)\
**Post date:** [October 11, 2023, 4:44pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/3 "2023-10-11T16:44:48Z")

</div>

This would be helpful for me too.

---

<div class="post-metadata">

**Author:** ![Leon\_Grdic](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/leon_grdic/32/35976_2.png) [@Leon\_Grdic](https://connect.superhuman.com/u/Leon_Grdic)\
**Post date:** [November 6, 2023, 6:42pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/4 "2023-11-06T18:42:01Z")

</div>

+1  
Please add support for this! Using the display value of the target row is unreliable because there can be multiple rows with the same display name and this often requires a separate API call just to fetch the display column of a row.

---

<div class="post-metadata">

**Author:** ![Logan\_Krantz](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Logan\_Krantz](https://connect.superhuman.com/u/Logan_Krantz)\
**Post date:** [November 17, 2023, 3:04am UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/5 "2023-11-17T03:04:01Z")

</div>

+1 to this!

Bonus points if we can used the returned value of another api call as a key. E.g. “Row ID: 'i-djr7ApmsBb”’ from the UpdateRow call

---

<div class="post-metadata">

**Author:** ![Leon\_Grdic](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/leon_grdic/32/35976_2.png) [@Leon\_Grdic](https://connect.superhuman.com/u/Leon_Grdic)\
**Post date:** [November 20, 2023, 11:01pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/6 "2023-11-20T23:01:51Z")

</div>

Can we please get an update on this? Can’t believe such a basic functionality is missing from the API.

---

<div class="post-metadata">

**Author:** ![Nad](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/nad/32/26972_2.png) [@Nad](https://connect.superhuman.com/u/Nad)\
**Post date:** [November 21, 2023, 2:55am UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/7 "2023-11-21T02:55:10Z")

</div>

Fully agree that the “real” row ID (e.g. ‘i-djr7ApmsBb’) , should be treated better by the API, including querying for rows by list of row IDs , using IDs to insert relations.  
Using the display value is extremely brittle.

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [November 21, 2023, 1:53pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/8 "2023-11-21T13:53:14Z")

</div>

Thanks for raising this issue to our attention again. I agree with you that it would be better if we supported row IDs in more places, with relation column values being the most pressing need. We don’t currently have any plans in the works to fix this, but I’m chatting with the engineering team to discuss a path forward.

---

<div class="post-metadata">

**Author:** ![Leon\_Grdic](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/leon_grdic/32/35976_2.png) [@Leon\_Grdic](https://connect.superhuman.com/u/Leon_Grdic)\
**Post date:** [December 1, 2023, 7:25am UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/9 "2023-12-01T07:25:55Z")

</div>

I see this is now supported with the upsert row endpoint in the latest API update (1.4.5) - this is awesome and thank you so much for reacting to feedback so fast!

Could you please take a look at the remaining two cases:

- Multiple row references - I tried passing both a single string (e.g. “i-KBtx1k-pJJ, i-nfq2xcBF8z”) and an array of strings (e.g. [“i-KBtx1k-pJJ”, “i-nfq2xcBF8z”]) as the cell value but neither work; the column has the _Allow multiple selections_ option enabled
- The update row endpoint still seems to not accept row id as cell values

---

<div class="post-metadata">

**Author:** ![Martin\_Portevin](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/martin_portevin/32/26357_2.png) [@Martin\_Portevin](https://connect.superhuman.com/u/Martin_Portevin)\
**Post date:** [December 1, 2023, 12:00pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/10 "2023-12-01T12:00:36Z")

</div>

That’s very good news, thank you for noticing @Leon_Grdic !

The update row endpoint seem to also accept row id on my side now.  
But multiple row references doesn’t work too.

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [December 1, 2023, 1:31pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/11 "2023-12-01T13:31:34Z")

</div>

Good eyes @Leon_Grdic, you beat me to it. Yes, this week we released support for passing row IDs in this upsertRows endpoint. Let me ask about the multiple row references, as I’m not sure what was intended there.

---

<div class="post-metadata">

**Author:** ![Martin\_Portevin](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/martin_portevin/32/26357_2.png) [@Martin\_Portevin](https://connect.superhuman.com/u/Martin_Portevin)\
**Post date:** [December 4, 2023, 10:42am UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/12 "2023-12-04T10:42:58Z")

</div>

Also interested in this.  
I guess what @Leon_Grdic is asking is instead of only being able to set one relation like :

```auto
{
  "column" : "c-fQpfvKC35x",
  "value" : "i-xxxxxxxxxx"
}

```

… being able to set multiple relations when the target cell is set to “allow multiple selections” with for example :

```auto
{
  "column" : "c-fQpfvKC35x",
  "value" : ["i-xxxxxxxxxx", "i-yyyyyyyyyy", "i-zzzzzzzzzz"]
}

```

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [December 4, 2023, 3:34pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/13 "2023-12-04T15:34:50Z")

</div>

Yes, that’s what I understood as well. I checked with the engineering team and they hadn’t built in support for setting multiple references at once, but they are looking into that case to see if they can add support for it as well.

---

<div class="post-metadata">

**Author:** ![Scott\_Collier-Weir](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/scott_collier-weir/32/29677_2.png) [@Scott\_Collier-Weir](https://connect.superhuman.com/u/Scott_Collier-Weir)\
**Post date:** [December 10, 2023, 3:14pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/14 "2023-12-10T15:14:24Z")

</div>

> [@Martin\_Portevin](#):
>
> dpoint seem to also accept row id on my side now.  
> But multiple row references doesn’t work too.

Interestingly, this isn’t working for me. Im passing my payload just as you had shown above

```auto
"body":{"rows":[
 {"cells":[
  {"column":"c-HTrCjTrep8","value":"scott"},
  {"column":"c-4BStpR6p5L","value":"scott@simpladocs.com"},
  {"column":"c-VXChNuiuRe","value":"i-CzRim0yf3_"}
 ]
}

```

But not working on my end, it’s simply inserting the ID itself and not the actual relation. Any idea why?

Also - Im in need of inserting multiple row references as well. . . @Eric_Koleda would love to see that addition to the API!

EDIT:

I figured it out - My relation column was not set to the correct table 😭 - but my need for inserting multiple values to a relation column via the uuid in the API still stands!

---

<div class="post-metadata">

**Author:** ![Eric\_Koleda](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/eric_koleda/32/50286_2.png) [@Eric\_Koleda](https://connect.superhuman.com/u/Eric_Koleda)\
**Post date:** [December 15, 2023, 8:09pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/15 "2023-12-15T20:09:50Z")

</div>

Good news! The engineer working on this has now also added support for setting multiple relations via ID using the API:

```auto
PUT https://coda.io/apis/v1/docs/{DOC_ID}/tables/{TABLE_ID}/rows/{ROW_ID}

{
  "row": {
    "cells": [
      {
        "column": "{COLUMN_ID}",
        "value": [
          "{TARGET_ROW_ID_1}",
          "{TARGET_ROW_ID_2}",
          // etc...
        ]
      }
    ]
  }
}

```

Let us know if you run into any issues using this.

---

<div class="post-metadata">

**Author:** ![Scott\_Collier-Weir](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/scott_collier-weir/32/29677_2.png) [@Scott\_Collier-Weir](https://connect.superhuman.com/u/Scott_Collier-Weir)\
**Post date:** [December 15, 2023, 10:02pm UTC](https://connect.superhuman.com/t/inserting-relation-through-the-api/42955/16 "2023-12-15T22:02:17Z")

</div>

Oh joy!!! Great news
