Ver .md

custom_objects.relation_create

Criar ligação de um objeto. Liga o objeto (objectId, a origem) a Contatos (leads), Oportunidades (opportunities), Empresas (companies) ou outro objeto (objects + targetObjectId, que pode ser o próprio objeto: aí os dois nomes precisam ser diferentes). cardinality: many_to_one (cada registro da origem tem um só do outro lado), one_to_many (cada um do outro lado tem um só da origem) ou many_to_many. sourceLabel aparece na ficha da origem e targetLabel na ficha do outro lado. showOnCard só vale com Oportunidades (selo no card do kanban). Nome repetido entre os mesmos dois lados dá invalid_input. Objetos arquivados não recebem ligação.

  • Endpoint: POST https://app.atomiks.com.br/api/v1/custom_objects.relation_create (corpo JSON)
  • Quem pode chamar: administrador da conta
  • Escopo da chave: crm:write
  • Grava dados: sim
  • Pela chave de API: sim
  • Ferramenta MCP: custom_objects_relation_create
  • Ficha em JSON: https://app.atomiks.com.br/api/v1/openapi.json (operationId custom_objects.relation_create)

Entrada

CampoTipoObrigatórioNota
cardinality"many_to_one" | "one_to_many" | "many_to_many"sim
sourceLabelstringsim
targetLabelstringsim
showOnCardbooleannão
objectIdstring (uuid)sim
targetType"leads" | "opportunities" | "companies" | "objects"sim
targetObjectIdstring (uuid)não
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "cardinality": {
      "type": "string",
      "enum": [
        "many_to_one",
        "one_to_many",
        "many_to_many"
      ]
    },
    "sourceLabel": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60
    },
    "targetLabel": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60
    },
    "showOnCard": {
      "type": "boolean"
    },
    "objectId": {
      "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)$"
    },
    "targetType": {
      "type": "string",
      "enum": [
        "leads",
        "opportunities",
        "companies",
        "objects"
      ]
    },
    "targetObjectId": {
      "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": [
    "cardinality",
    "sourceLabel",
    "targetLabel",
    "objectId",
    "targetType"
  ]
}

Exemplo

curl -X POST https://app.atomiks.com.br/api/v1/custom_objects.relation_create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"objectId":"00000000-0000-0000-0000-000000000000","targetType":"leads","cardinality":"many_to_one","sourceLabel":"Proprietário","targetLabel":"Imóveis"}'

CLI:

node cli/atomiks.mjs custom_objects.relation_create --json '{"objectId":"00000000-0000-0000-0000-000000000000","targetType":"leads","cardinality":"many_to_one","sourceLabel":"Proprietário","targetLabel":"Imóveis"}'

MCP: ferramenta custom_objects_relation_create com a mesma entrada.

Saída

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

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "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
}

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).