# companies.create

Criar empresa. Cria a empresa com a razão social (`legalName`, única na conta sem diferenciar maiúsculas) e, se quiser, o resto do cadastro. `taxId` é o CNPJ; `sizeTier` é `SMB`, `MID` ou `ENTERPRISE`. Sem a atualização do banco só a razão social é aceita (`migration_pendente` nos demais campos).

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `legalName` | string | sim |  |
| `tradeName` | string \| null | não |  |
| `taxId` | string \| null | não |  |
| `taxIdType` | string \| null | não |  |
| `email` | string \| null | não |  |
| `phone` | string \| null | não |  |
| `website` | string \| null | não |  |
| `addressStreet` | string \| null | não |  |
| `addressCity` | string \| null | não |  |
| `addressState` | string \| null | não |  |
| `addressPostalCode` | string \| null | não |  |
| `countryCode` | string \| null | não |  |
| `industry` | string \| null | não |  |
| `sizeTier` | "SMB" \| "MID" \| "ENTERPRISE" \| null | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "legalName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "tradeName": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 120
        },
        {
          "type": "null"
        }
      ]
    },
    "taxId": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 32
        },
        {
          "type": "null"
        }
      ]
    },
    "taxIdType": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 16
        },
        {
          "type": "null"
        }
      ]
    },
    "email": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 254
        },
        {
          "type": "null"
        }
      ]
    },
    "phone": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 40
        },
        {
          "type": "null"
        }
      ]
    },
    "website": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 300
        },
        {
          "type": "null"
        }
      ]
    },
    "addressStreet": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "addressCity": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ]
    },
    "addressState": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2
        },
        {
          "type": "null"
        }
      ]
    },
    "addressPostalCode": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 16
        },
        {
          "type": "null"
        }
      ]
    },
    "countryCode": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 3
        },
        {
          "type": "null"
        }
      ]
    },
    "industry": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ]
    },
    "sizeTier": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "SMB",
            "MID",
            "ENTERPRISE"
          ]
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "legalName"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/companies.create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"legalName":"Acme Comércio Ltda","tradeName":"Acme","taxId":"12.345.678/0001-90","taxIdType":"CNPJ","sizeTier":"SMB"}'
```

CLI:

```bash
node cli/atomiks.mjs companies.create --json '{"legalName":"Acme Comércio Ltda","tradeName":"Acme","taxId":"12.345.678/0001-90","taxIdType":"CNPJ","sizeTier":"SMB"}'
```

MCP: ferramenta `companies_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"
    },
    "legalName": {
      "type": "string"
    },
    "tradeName": {
      "type": [
        "string",
        "null"
      ]
    },
    "taxId": {
      "type": [
        "string",
        "null"
      ]
    },
    "taxIdType": {
      "type": [
        "string",
        "null"
      ]
    },
    "email": {
      "type": [
        "string",
        "null"
      ]
    },
    "phone": {
      "type": [
        "string",
        "null"
      ]
    },
    "website": {
      "type": [
        "string",
        "null"
      ]
    },
    "addressStreet": {
      "type": [
        "string",
        "null"
      ]
    },
    "addressCity": {
      "type": [
        "string",
        "null"
      ]
    },
    "addressState": {
      "type": [
        "string",
        "null"
      ]
    },
    "addressPostalCode": {
      "type": [
        "string",
        "null"
      ]
    },
    "countryCode": {
      "type": [
        "string",
        "null"
      ]
    },
    "industry": {
      "type": [
        "string",
        "null"
      ]
    },
    "sizeTier": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "SMB",
            "MID",
            "ENTERPRISE"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    },
    "enrichment": {
      "type": "null"
    }
  },
  "required": [
    "id",
    "legalName",
    "tradeName",
    "taxId",
    "taxIdType",
    "email",
    "phone",
    "website",
    "addressStreet",
    "addressCity",
    "addressState",
    "addressPostalCode",
    "countryCode",
    "industry",
    "sizeTier",
    "createdAt",
    "updatedAt",
    "enrichment"
  ],
  "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).
