Ver .md

custom_objects.records_import

Importar registros de uma planilha. Cria a tarefa de importação (kind: "import", state: "waiting") do arquivo enviado com records_import_upload_url (uploadId) e devolve na hora; o worker lê o arquivo em lotes de 500 linhas (até 100.000). columnMappings: {csvColumn, customFieldId} (o campo-título precisa estar mapeado; a coluna é o texto do cabeçalho do arquivo). Cada célula é lida pelo tipo do campo (números "1.234,56", datas "26/10/2026", sim/não, opções pelo nome). matchFieldId casa com registros que já existem pelo valor desse campo e conflictStrategy decide: merge preenche só o que está vazio, overwrite troca os valores mapeados, keep pula a linha. Sem matchFieldId, toda linha cria registro. responsibleAttendantId vale para os criados. Acompanhe com custom_objects.record_job_get: progress, affected (criados + atualizados) e, em meta: created, updated, skipped, failed e errors ({row, message}, até 50; a linha 2 é a primeira de dados). Valores entram com a origem import.

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

Entrada

CampoTipoObrigatórioNota
objectIdstring (uuid)sim
uploadIdstring (uuid)sim
fileNamestringsim
columnMappingsobject[]sim
matchFieldIdstring (uuid) | nullnão
conflictStrategy"merge" | "overwrite" | "keep"não
responsibleAttendantIdstring (uuid) | nullnão
totalRowsintegernão
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "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)$"
    },
    "uploadId": {
      "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)$"
    },
    "fileName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "columnMappings": {
      "minItems": 1,
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "csvColumn": {
            "type": "string",
            "maxLength": 200
          },
          "customFieldId": {
            "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": [
          "csvColumn",
          "customFieldId"
        ]
      }
    },
    "matchFieldId": {
      "anyOf": [
        {
          "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)$"
        },
        {
          "type": "null"
        }
      ]
    },
    "conflictStrategy": {
      "type": "string",
      "enum": [
        "merge",
        "overwrite",
        "keep"
      ]
    },
    "responsibleAttendantId": {
      "anyOf": [
        {
          "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)$"
        },
        {
          "type": "null"
        }
      ]
    },
    "totalRows": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "objectId",
    "uploadId",
    "fileName",
    "columnMappings"
  ]
}

Exemplo

curl -X POST https://app.atomiks.com.br/api/v1/custom_objects.records_import \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"objectId":"00000000-0000-0000-0000-000000000000","uploadId":"00000000-0000-0000-0000-000000000000","fileName":"imoveis.csv","columnMappings":[{"csvColumn":"Endereço","customFieldId":"00000000-0000-0000-0000-000000000000"}]}'

CLI:

node cli/atomiks.mjs custom_objects.records_import --json '{"objectId":"00000000-0000-0000-0000-000000000000","uploadId":"00000000-0000-0000-0000-000000000000","fileName":"imoveis.csv","columnMappings":[{"csvColumn":"Endereço","customFieldId":"00000000-0000-0000-0000-000000000000"}]}'

MCP: ferramenta custom_objects_records_import 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"
    },
    "kind": {
      "type": "string",
      "enum": [
        "bulk_update",
        "bulk_delete",
        "export",
        "import"
      ]
    },
    "state": {
      "type": "string",
      "enum": [
        "waiting",
        "active",
        "completed",
        "failed"
      ]
    },
    "progress": {
      "type": "number"
    },
    "total": {
      "type": "number"
    },
    "affected": {
      "type": [
        "number",
        "null"
      ]
    },
    "fileName": {
      "type": [
        "string",
        "null"
      ]
    },
    "downloadUrl": {
      "type": [
        "string",
        "null"
      ]
    },
    "csv": {
      "type": [
        "string",
        "null"
      ]
    },
    "meta": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "failedReason": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string"
    },
    "finishedAt": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "id",
    "kind",
    "state",
    "progress",
    "total",
    "affected",
    "fileName",
    "downloadUrl",
    "csv",
    "meta",
    "failedReason",
    "createdAt",
    "finishedAt"
  ],
  "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).