Ver .md

custom_objects.records_export

Exportar registros de um objeto em CSV. Cria a tarefa de exportação (kind: "export", state: "waiting") e devolve na hora; o worker gera o CSV em segundo plano. Acompanhe com custom_objects.record_job_get (progress, state): ao ficar completed, downloadUrl é o link do arquivo (vale 5 minutos; a cada consulta vem um novo; o arquivo fica guardado por 24 horas). Seleção como a das ações em massa: recordIds (até 5.000) ou allMatching: true com filters/relations/search. columns (na ordem do arquivo): cf:<id do campo>, rel:<id da ligação>:<source|target> (nomes dos vinculados, separados por "; "), responsible, createdAt, updatedAt, id. Até 100.000 registros. notifyEmail (opcional): ao terminar, manda para esse endereço um e-mail com o link do arquivo, válido pelas 24 horas em que ele fica guardado.

  • Endpoint: POST https://app.atomiks.com.br/api/v1/custom_objects.records_export (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_export
  • Ficha em JSON: https://app.atomiks.com.br/api/v1/openapi.json (operationId custom_objects.records_export)

Entrada

CampoTipoObrigatórioNota
objectIdstring (uuid)sim
recordIdsstring (uuid)[]não
allMatchingbooleannão
filtersobject[]não
relationsobject[]não
searchstringnão
columnsstring[]sim
notifyEmailstring (email)nã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)$"
    },
    "recordIds": {
      "maxItems": 5000,
      "type": "array",
      "items": {
        "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)$"
      }
    },
    "allMatching": {
      "type": "boolean"
    },
    "filters": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "fieldId": {
            "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": "string",
                "enum": [
                  "title",
                  "responsible",
                  "createdAt",
                  "updatedAt"
                ]
              }
            ]
          },
          "op": {
            "type": "string",
            "enum": [
              "eq",
              "neq",
              "contains",
              "not_contains",
              "gt",
              "gte",
              "lt",
              "lte",
              "empty",
              "not_empty",
              "in",
              "not_in",
              "starts_with",
              "ends_with"
            ]
          },
          "value": {}
        },
        "required": [
          "fieldId",
          "op"
        ]
      }
    },
    "relations": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "relationId": {
            "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)$"
          },
          "side": {
            "type": "string",
            "enum": [
              "source",
              "target"
            ]
          },
          "quantifier": {
            "type": "string",
            "enum": [
              "any",
              "all",
              "none"
            ]
          },
          "value": {
            "type": "string",
            "maxLength": 200
          },
          "conditions": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fieldId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "neq",
                    "contains",
                    "not_contains",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "empty",
                    "not_empty",
                    "in",
                    "not_in",
                    "starts_with",
                    "ends_with"
                  ]
                },
                "value": {}
              },
              "required": [
                "fieldId",
                "op"
              ]
            }
          }
        },
        "required": [
          "relationId",
          "side",
          "quantifier"
        ]
      }
    },
    "search": {
      "type": "string",
      "maxLength": 200
    },
    "columns": {
      "minItems": 1,
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^(cf:[0-9a-f-]{36}|rel:[0-9a-f-]{36}:(source|target)|responsible|createdAt|updatedAt|id)$"
      }
    },
    "notifyEmail": {
      "type": "string",
      "maxLength": 254,
      "format": "email",
      "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
    }
  },
  "required": [
    "objectId",
    "columns"
  ]
}

Exemplo

curl -X POST https://app.atomiks.com.br/api/v1/custom_objects.records_export \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"objectId":"00000000-0000-0000-0000-000000000000","allMatching":true,"columns":["responsible","createdAt"]}'

CLI:

node cli/atomiks.mjs custom_objects.records_export --json '{"objectId":"00000000-0000-0000-0000-000000000000","allMatching":true,"columns":["responsible","createdAt"]}'

MCP: ferramenta custom_objects_records_export 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).