> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/api/guides/working-with-the-import-api-v2/import-commands/importing-complex-relations.md).

# Importing complex relations

## Command structure

```json
[
  {
    "resourceType": "Complex Relation",
    "identifier": {
      "externalSystemId": "EXT_SYSTEM",
      "externalEntityId": "Asset_1234"
    },
    "complexRelationType": {
      "name": "Field Mapping"
    },
    "attributes": {
      "Original Column Name": [
        {
          "value": "XXX_COLUMN_1"
        }
      ],
      "00000000-0000-0000-0001-000500000011": [
        {
          "value": "True"
        }
      ]
    },
    "relations": {
      "00000000-0000-0000-0000-000000007088:TARGET": [
        {
          "name": "Asset 2",
          "domain": {
            "name": "Data Asset Domain 1",
            "community": {
              "name": "Data Community"
            }
          }
        }
      ],
      "00000000-0000-0000-0000-000000007089:TARGET": [
        {
          "name": "Table representation Asset",
          "domain": {
            "name": "Business Asset Domain 2",
            "community": {
              "name": "Business Community"
            }
          }
        }
      ]
    }
  }
]
```

## Identifier

The identifier for a complex relation may contain any of the following fields:

* `id`
* `externalSystemId` and `externalEntityId`
* `RELATION_TYPE_ID:RELATION_DIRECTION`

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>The list of relations, also known as complex relation legs, does not guarantee the unique identification of a complex relation. This method is prone to error in cases where there are two complex relations in Collibra:</p><ul><li>One complex relation with legs A, B and C.</li><li>Another complex relation with legs A, B, C and D.</li></ul><p>In this example, identifying a complex relation by the legs A, B and C results in an error because the API cannot determine which of the two complex relations it should process. In cases like this, use one of the other identification methods.</p></div>

{% hint style="info" %}
Code snippets in this section may show redundant data to demonstrate the fields accepted by the import API.
{% endhint %}

### Identifier structure

```json
{
  "id": "12345678-1234-1234-1234-123456788765"
}
```

```json
{
  "relations": {
    "00000000-0000-0000-0000-000000007088:TARGET": [
      {
        "name": "Data Element Source Asset 1",
        "domain": {
          "name": "Data Domain 1",
          "community": {
            "name": "The Community"
          }
        }
      },
      {
        "name": "Data Element Source Asset 2",
        "domain": {
          "name": "Data Domain 1",
          "community": {
            "name": "The Community"
          }
        }
      }
    ],
    "00000000-0000-0000-0000-000000007089:TARGET": [
      {
        "name": "Data Element Target Asset 1",
        "domain": {
          "name": "Data Domain 2",
          "community": {
            "name": "The Community"
          }
        }
      },
      {
        "name": "Data Element Target Asset 2",
        "domain": {
          "name": "Data Domain 2",
          "community": {
            "name": "The Community"
          }
        }
      }
    ],
    "00000000-0000-0000-0000-000000007090:TARGET": [
      {
        "name": "Mapping Specs 1",
        "domain": {
          "name": "Mapping Specs Domain",
          "community": {
            "name": "The Community"
          }
        }
      }
    ]
  }
}
```

```json
{
  "externalSystemId": "EXT_SYSTEM",
  "externalEntityId": "Asset_1234"
}
```

## Optional fields

| Field name          | Field type                                   | Remarks                                                                                                                      |
| ------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| attributes          | `ATTRIBUTE_TYPE_ID` or `ATTRIBUTE_TYPE_NAME` | Sets or updates the complex relation attributes.                                                                             |
| complexRelationType | `id` or `name`                               | Sets the complex relation type. Should only be used for `create` operations. It is silently ignored for `update` operations. |
| relations           | `RELATION_TYPE_ID:RELATION_DIRECTION`        | Sets or updates the relations of the complex relation based on the relation type id and the direction.                       |

## Expected behavior

The behavior is similar to the commands for communities and domains.

## Add operation

If the complex relation needs to be created, the following fields have to be provided in order to import successfully:

* `relations`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.collibra.com/api/guides/working-with-the-import-api-v2/import-commands/importing-complex-relations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
