> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.datagol.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Row with Linked Records

> ## 1️⃣ Overview

**Purpose:**
Creates a new row in the specified table and simultaneously links it to one or more records in associated tables via existing LINK columns.

This endpoint supports:
- Setting cell values for the new row at creation time
- Linking the new row to existing records in associated tables using `linkColumnId`
- Multiple link relations can be established in a single request

---

## 2️⃣ Endpoint

```
POST /noCo/api/v2/workspaces/{workspaceId}/tables/{workbook_id}/rows
```

---

## 3️⃣ Path Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| workspaceId | UUID | ✅ Yes | Workspace identifier |
| workbook_id | UUID | ✅ Yes |  workbook where the row will be created |

---

## 4️⃣ Authentication

Requires **Bearer JWT Token**

```
Authorization: Bearer <token>
```

---

## 5️⃣ Request Headers

| Header | Required |
| --- | --- |
| Authorization | ✅ Yes |
| Content-Type: application/json | ✅ Yes |

---

## 6️⃣ Request Body Schema

```json
{
  "cellValues": {
    "<columnName>": "<value>"
  },
  "linkRecords": [
    {
      "destinationRecordId": "integer",
      "linkColumnId": "uuid"
    }
  ]
}
```

---

## 7️⃣ Field Descriptions

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| cellValues | object | ✅ Yes | Key-value map of column names and their values for the new row |
| cellValues.\<columnName\> | any | ❌ No | Value for a specific column — pass empty string or empty array if no value |
| linkRecords | array | ❌ No | List of link operations to perform when creating the row |
| linkRecords[].destinationRecordId | integer | ✅ Yes | PK of the record in the associated table to link to |
| linkRecords[].linkColumnId | UUID | ✅ Yes | ID of the LINK column that defines the relation |



## OpenAPI

````yaml /openapi/openapi.yaml post /noCo/api/v2/workspaces/{workspaceId}/tables/{workbook_id}/rows
openapi: 3.0.0
info:
  title: DataGOL APIs
  version: 1.0.0
  description: ''
servers:
  - url: https://be.datagol.ai
  - url: https://be.datagol.ai
  - url: https://kg.datagol.ai
  - url: https://ai.datagol.ai
security: []
tags:
  - name: Links & Joins
    description: >
      ## 🔗 Links & Joins


      LINK and LOOKUP are special workbook column types that enable relational
      data modeling across tables.


      | Column Type | Purpose |

      |---|---|

      | `LINK` | Defines a relationship between two tables |

      | `LOOKUP` | Projects columns from an associated table via a link |


      Both are configured through `ColumnDTO.colOptions`. A table can have
      multiple link columns, and each link can have multiple lookup columns.


      ---


      ## 📐 UI Data Types


      - **LINK** — Special column used to represent inter-table relations

      - **LOOKUP** — Special column used to project associated table fields via
      a link


      ---


      ## 🔗 LINK Semantics


      A LINK column stores metadata for:

      - `tableId` — Current table

      - `associatedTableId` — Associated (linked) table

      - `relationType` — Type of relationship

      - `linkColumnId` — Link column identifier


      **Supported relation patterns:**


      | Pattern | Description |

      |---|---|

      | `ONE_TO_ONE` | Each record in the source maps to one record in the
      destination |

      | `ONE_TO_MANY` | One source record maps to many destination records |

      | `MANY_TO_MANY` | Many source records map to many destination records |


      ---


      ## 🔍 LOOKUP Semantics


      - A LOOKUP column is tightly coupled with a specific LINK column

      - References a link using `linkColumnId`

      - Represents a selected column from the associated table

      - Multiple lookup columns can be defined for the same link


      ---


      ## 🗂️ Metadata in `ColumnDTO.colOptions`


      Use `colOptions` to persist link/lookup metadata.


      | Field | Description |

      |---|---|

      | `columnId` | Current column ID |

      | `tableId` | Current table ID |

      | `associatedTableId` | Associated table ID |

      | `linkColumnId` | Link column ID — used by LOOKUP; references the LINK
      column's `columnId` |

      | `relationType` | Relation semantics for LINK |


      ---


      ## 🔄 Manual Linking Record Flow


      To create manual record-level links:


      1. Fetch associated table schema/data

      2. User selects associated record(s) to link

      3. Send linking payload with:
          - `sourceRecordId` — PK of the current table row
          - `destinationRecordId` — PK of the associated table row
          - `linkColumnId` — LINK column identifier
      4. Backend resolves link metadata from `linkColumnId` (relation type,
      associated table, direction/constraints)

      5. Backend applies relation rules and stores the link relation


      ---


      ## 📋 Record Linking Contract


      | Field | Description |

      |---|---|

      | `sourceRecordId` | PK of the current table row |

      | `destinationRecordId` | PK of the associated table row |

      | `linkColumnId` | LINK column identifier |

      | `tableId` | Current table ID |


      > Backend derives all remaining relation metadata from the link
      configuration.


      ---


      ## ⚠️ Important Notes


      > - LINK and LOOKUP are **column-level constructs** first; record linking
      is a data-level operation built on top

      > - LOOKUP behavior depends on LINK existence and metadata integrity

      > - With multiple links to the same associated table, each LOOKUP must
      bind to the correct `linkColumnId`

      > - Always treat the associated row ID as the associated table PK for
      linking UI selection
paths:
  /noCo/api/v2/workspaces/{workspaceId}/tables/{workbook_id}/rows:
    post:
      tags:
        - Links & Joins
      summary: Add Row with Linked Records
      description: >-
        ## 1️⃣ Overview


        **Purpose:**

        Creates a new row in the specified table and simultaneously links it to
        one or more records in associated tables via existing LINK columns.


        This endpoint supports:

        - Setting cell values for the new row at creation time

        - Linking the new row to existing records in associated tables using
        `linkColumnId`

        - Multiple link relations can be established in a single request


        ---


        ## 2️⃣ Endpoint


        ```

        POST /noCo/api/v2/workspaces/{workspaceId}/tables/{workbook_id}/rows

        ```


        ---


        ## 3️⃣ Path Parameters


        | Parameter | Type | Required | Description |

        | --- | --- | --- | --- |

        | workspaceId | UUID | ✅ Yes | Workspace identifier |

        | workbook_id | UUID | ✅ Yes |  workbook where the row will be created |


        ---


        ## 4️⃣ Authentication


        Requires **Bearer JWT Token**


        ```

        Authorization: Bearer <token>

        ```


        ---


        ## 5️⃣ Request Headers


        | Header | Required |

        | --- | --- |

        | Authorization | ✅ Yes |

        | Content-Type: application/json | ✅ Yes |


        ---


        ## 6️⃣ Request Body Schema


        ```json

        {
          "cellValues": {
            "<columnName>": "<value>"
          },
          "linkRecords": [
            {
              "destinationRecordId": "integer",
              "linkColumnId": "uuid"
            }
          ]
        }

        ```


        ---


        ## 7️⃣ Field Descriptions


        | Field | Type | Required | Description |

        | --- | --- | --- | --- |

        | cellValues | object | ✅ Yes | Key-value map of column names and their
        values for the new row |

        | cellValues.\<columnName\> | any | ❌ No | Value for a specific column —
        pass empty string or empty array if no value |

        | linkRecords | array | ❌ No | List of link operations to perform when
        creating the row |

        | linkRecords[].destinationRecordId | integer | ✅ Yes | PK of the record
        in the associated table to link to |

        | linkRecords[].linkColumnId | UUID | ✅ Yes | ID of the LINK column that
        defines the relation |
      parameters:
        - name: workspaceId
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Workspace identifier
        - name: workbook_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Target table identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - cellValues
              properties:
                cellValues:
                  type: object
                  description: >-
                    Key-value map of column names and their initial values for
                    the new row
                  additionalProperties:
                    oneOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                linkRecords:
                  type: array
                  description: List of link operations to attach when creating the row
                  items:
                    type: object
                    required:
                      - destinationRecordId
                      - linkColumnId
                    properties:
                      destinationRecordId:
                        type: integer
                        description: PK of the record in the associated table to link to
                      linkColumnId:
                        type: string
                        format: uuid
                        description: ID of the LINK column that defines the relation
            example:
              cellValues:
                name: ''
                notes: ''
              linkRecords:
                - destinationRecordId: 2
                  linkColumnId: ed7584c6-a33a-4779-b7bb-03a5d1345bb2
      responses:
        '200':
          description: Row created and linked successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: integer
                    description: Auto-generated primary key of the newly created row
                  cellValues:
                    type: object
                    description: The column values stored for the new row
                    additionalProperties:
                      oneOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                  linkRecords:
                    type: array
                    description: Confirmation of link relations established
                    items:
                      type: object
                      properties:
                        destinationRecordId:
                          type: integer
                          description: PK of the linked record in the associated table
                        linkColumnId:
                          type: string
                          format: uuid
                          description: LINK column ID used to establish the relation
              example:
                id: 101
                cellValues:
                  name: ''
                  notes: ''
                linkRecords:
                  - destinationRecordId: 2
                    linkColumnId: ed7584c6-a33a-4779-b7bb-03a5d1345bb2
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        This API uses OAuth 2.0 with the authorization code grant flow.

````