# custom_objects.links_list

Vínculos de um registro ou de um contato, oportunidade ou empresa. O que está ligado a uma coisa, agrupado por ligação (o que a ficha de contato, oportunidade, empresa e registro mostra). `targetType` é `leads` (contato), `opportunities`, `companies` ou `objects` (`targetId` é o id de um registro). Cada grupo traz a `relation`, o `side` em que a coisa está (`source`: ela é a origem e os itens são o outro lado; `target`: ela é o alvo e os itens são registros de objetos) e `items` (`linkId`, `type`, `id`, `label`, `subtitle`). Ligações sem vínculo também vêm, com `items` vazio. Objetos arquivados ficam de fora.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/custom_objects.links_list` (corpo JSON)
- Quem pode chamar: membro da conta
- Escopo da chave: `crm:read`
- Grava dados: não
- Pela chave de API: sim
- Ferramenta MCP: `custom_objects_links_list`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `custom_objects.links_list`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `targetType` | "leads" \| "opportunities" \| "companies" \| "objects" | sim |  |
| `targetId` | string (uuid) | sim |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "targetType": {
      "type": "string",
      "enum": [
        "leads",
        "opportunities",
        "companies",
        "objects"
      ]
    },
    "targetId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    }
  },
  "required": [
    "targetType",
    "targetId"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/custom_objects.links_list \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"targetType":"leads","targetId":"00000000-0000-0000-0000-000000000000"}'
```

CLI:

```bash
node cli/atomiks.mjs custom_objects.links_list --json '{"targetType":"leads","targetId":"00000000-0000-0000-0000-000000000000"}'
```

MCP: ferramenta `custom_objects_links_list` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "relation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "objectId": {
            "type": "string"
          },
          "sourceObject": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "singularName": {
                "type": "string"
              },
              "pluralName": {
                "type": "string"
              },
              "icon": {
                "type": "string"
              },
              "color": {
                "type": "string"
              },
              "gender": {
                "type": "string",
                "enum": [
                  "masculine",
                  "feminine"
                ]
              }
            },
            "required": [
              "id",
              "singularName",
              "pluralName",
              "icon",
              "color",
              "gender"
            ],
            "additionalProperties": false
          },
          "sourceLabel": {
            "type": "string"
          },
          "targetLabel": {
            "type": "string"
          },
          "targetType": {
            "type": "string",
            "enum": [
              "leads",
              "opportunities",
              "companies",
              "objects"
            ]
          },
          "targetObjectId": {
            "type": [
              "string",
              "null"
            ]
          },
          "targetObject": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "singularName": {
                    "type": "string"
                  },
                  "pluralName": {
                    "type": "string"
                  },
                  "icon": {
                    "type": "string"
                  },
                  "color": {
                    "type": "string"
                  },
                  "gender": {
                    "type": "string",
                    "enum": [
                      "masculine",
                      "feminine"
                    ]
                  }
                },
                "required": [
                  "id",
                  "singularName",
                  "pluralName",
                  "icon",
                  "color",
                  "gender"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "cardinality": {
            "type": "string",
            "enum": [
              "many_to_one",
              "one_to_many",
              "many_to_many"
            ]
          },
          "showOnCard": {
            "type": "boolean"
          },
          "linkCount": {
            "type": "number"
          },
          "createdAt": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "objectId",
          "sourceObject",
          "sourceLabel",
          "targetLabel",
          "targetType",
          "targetObjectId",
          "targetObject",
          "cardinality",
          "showOnCard",
          "linkCount",
          "createdAt",
          "updatedAt"
        ],
        "additionalProperties": false
      },
      "side": {
        "type": "string",
        "enum": [
          "source",
          "target"
        ]
      },
      "items": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "linkId": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "enum": [
                "leads",
                "opportunities",
                "companies",
                "objects"
              ]
            },
            "id": {
              "type": "string"
            },
            "label": {
              "type": "string"
            },
            "subtitle": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "linkId",
            "type",
            "id",
            "label",
            "subtitle"
          ],
          "additionalProperties": false
        }
      }
    },
    "required": [
      "relation",
      "side",
      "items"
    ],
    "additionalProperties": false
  }
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
