# custom_objects.create

Criar objeto personalizado. Cria o objeto. `singularName`/`pluralName` (até 60 caracteres), `gender` (`masculine` ou `feminine`, padrão masculino), `icon` (casa, prédio, carro… ver `custom_objects.list`) e `color` (teal, blue, violet, pink, orange, amber, green, slate). `apiName` sai do nome no plural (sem acento, minúsculo, `_` entre palavras; repetido ganha `_2`, `_3`) e nunca muda. `fields` cria os campos juntos (os modelos Imóveis, Veículos, Contratos e Turmas da tela são listas de campos): um deles, de tipo `text`, é o campo-título (`isTitle: true`; sem marca, o primeiro texto). Sem `fields`, nasce só o campo texto "Nome" como título. Tipos: text, textarea, number, currency, percentage, date, select, multi_select, radio, link, rating, boolean, file, image; os de seleção levam `options`. Exige a migration de objetos (`migration_pendente` sem ela).

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `singularName` | string | sim |  |
| `pluralName` | string | sim |  |
| `gender` | "masculine" \| "feminine" | não |  |
| `icon` | "home" \| "building" \| "car" \| "contract" \| "graduation" \| "box" \| "key" \| "tag" \| "calendar" \| "pin" \| "wrench" \| "heart" \| "star" \| "plane" \| "paw" \| "grid" | não |  |
| `color` | "teal" \| "blue" \| "violet" \| "pink" \| "orange" \| "amber" \| "green" \| "slate" | não |  |
| `fields` | object[] | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "singularName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60
    },
    "pluralName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60
    },
    "gender": {
      "type": "string",
      "enum": [
        "masculine",
        "feminine"
      ]
    },
    "icon": {
      "type": "string",
      "enum": [
        "home",
        "building",
        "car",
        "contract",
        "graduation",
        "box",
        "key",
        "tag",
        "calendar",
        "pin",
        "wrench",
        "heart",
        "star",
        "plane",
        "paw",
        "grid"
      ]
    },
    "color": {
      "type": "string",
      "enum": [
        "teal",
        "blue",
        "violet",
        "pink",
        "orange",
        "amber",
        "green",
        "slate"
      ]
    },
    "fields": {
      "maxItems": 60,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "displayName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "fieldName": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,39}$"
          },
          "fieldType": {
            "type": "string",
            "enum": [
              "text",
              "textarea",
              "number",
              "currency",
              "percentage",
              "date",
              "select",
              "multi_select",
              "radio",
              "link",
              "rating",
              "boolean",
              "file",
              "image"
            ]
          },
          "options": {
            "maxItems": 100,
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "label"
                  ]
                }
              ]
            }
          },
          "description": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 300
              },
              {
                "type": "null"
              }
            ]
          },
          "required": {
            "type": "boolean"
          },
          "filterable": {
            "type": "boolean"
          },
          "pinned": {
            "type": "boolean"
          },
          "groupName": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 60
              },
              {
                "type": "null"
              }
            ]
          },
          "unique": {
            "type": "boolean"
          },
          "isTitle": {
            "type": "boolean"
          }
        },
        "required": [
          "displayName",
          "fieldType"
        ]
      }
    }
  },
  "required": [
    "singularName",
    "pluralName"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/custom_objects.create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"singularName":"Imóvel","pluralName":"Imóveis","gender":"masculine","icon":"home","color":"teal","fields":[{"displayName":"Endereço","fieldType":"text","isTitle":true},{"displayName":"Status","fieldType":"select","options":["Disponível","Vendido"]}]}'
```

CLI:

```bash
node cli/atomiks.mjs custom_objects.create --json '{"singularName":"Imóvel","pluralName":"Imóveis","gender":"masculine","icon":"home","color":"teal","fields":[{"displayName":"Endereço","fieldType":"text","isTitle":true},{"displayName":"Status","fieldType":"select","options":["Disponível","Vendido"]}]}'
```

MCP: ferramenta `custom_objects_create` com a mesma entrada.

## Saída

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "singularName": {
      "type": "string"
    },
    "pluralName": {
      "type": "string"
    },
    "icon": {
      "type": "string"
    },
    "color": {
      "type": "string"
    },
    "gender": {
      "type": "string",
      "enum": [
        "masculine",
        "feminine"
      ]
    },
    "apiName": {
      "type": "string"
    },
    "archivedAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "titleFieldId": {
      "type": [
        "string",
        "null"
      ]
    },
    "titleField": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "displayName": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "displayName"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "recordCount": {
      "type": "number"
    },
    "fieldCount": {
      "type": "number"
    },
    "relationCount": {
      "type": "number"
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "singularName",
    "pluralName",
    "icon",
    "color",
    "gender",
    "apiName",
    "archivedAt",
    "titleFieldId",
    "titleField",
    "recordCount",
    "fieldCount",
    "relationCount",
    "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).
