V2
Vendas
Nova Venda

Integração com API de Nova Venda.

Este guia explica como utilizar a API de criação de uma nova venda para as concessionárias homologadas no MOTOR de recorrência.

🔐 Autenticação

A API exige autenticação via token JWT no cabeçalho da requisição:

Authorization: Bearer {token}

📬 Endpoint

POST /sales
Content-Type: application/json
Authorization: Bearer {token}

📥 Corpo da Requisição

{
  "clientId": "string",
  "productId": 101,
  "installationId": "abc123",
  "dealershipId": 11,
  "providerId": 3,
  "externalId": null,
  "shouldChargeFee": true,
  "shouldGiveDiscount": false,
  "startChargingAt": "2025-06-01",
  "isClientFinancialResponsible": true,
  "financialResponsible": {
    "cpf": "12345678900",
    "rg": "MG123456",
    "numberOnDealership": "987654",
    "firstName": "João",
    "lastName": "Silva",
    "email": "joao@email.com",
    "birthdate": "1980-05-01",
    "enrollment": "998877",
    "phoneNumber": "11999999999"
  },
  "tags": [
    { "legado": true },
    { "creationDate": "2025-08-21" },
  ]
}
O campo financialResponsible só deve ser enviado se isClientFinancialResponsible for false.

🏷️ dealershipId (Concessionárias)

NomeDealershipIdTipoCompanhia
ENERGISA1numberENERGISA
CPFL - Leste Paulista2numberCPFL
CPFL - Santa Cruz3numberCPFL
CPFL - Sul Paulista4numberCPFL
CPFL - Jaguari5numberCPFL
CPFL - Mococa6numberCPFL
CPFL - Paulista7numberCPFL
CPFL - Piratininga8numberCPFL
CPFL - RGE9numberCPFL
CPFL - RGE SUL10numberCPFL
NEOENERGIA - COELBA11numberNEOENERGIA
NEOENERGIA - COSERN12numberNEOENERGIA
NEOENERGIA - ELEKTRO13numberNEOENERGIA
NEOENERGIA - CELPE14numberNEOENERGIA
ENEL CE15numberENEL
ENEL RJ16numberENEL
ENEL São Paulo17numberENEL

✅ Regras Importantes

  • Se isClientFinancialResponsible for false, o campo financialResponsible é obrigatório
  • Se isClientFinancialResponsible for true, o campo financialResponsible não deve ser enviado
  • O campo startChargingAt define a data de início da cobrança (opcional)

🧾 Exemplo – Sem Responsável Financeiro

{
  "clientId": "cli-001",
  "productId": 202,
  "installationId": "abc-123",
  "dealershipId": 12,
  "providerId": 3,
  "externalId": null,
  "shouldChargeFee": false,
  "isClientFinancialResponsible": true
}

🧾 Exemplo – Com Responsável Financeiro

{
  "clientId": "cli-002",
  "productId": 303,
  "installationId": "xyz-789",
  "dealershipId": 13,
  "providerId": 3,
  "externalId": null,
  "shouldChargeFee": true,
  "isClientFinancialResponsible": false,
  "financialResponsible": {
    "cpf": "12345678900",
    "rg": "SP998877",
    "numberOnDealership": "654321",
    "firstName": "Maria",
    "lastName": "Souza",
    "email": "maria@email.com",
    "birthdate": "1990-01-01",
    "enrollment": "112233",
    "phoneNumber": "11988887777"
  }
}

📤 Resposta de Sucesso

{
  "message": "Sale created successfully!",
  "saleId": "uuid-gerado-pela-api"
}

❌ Erros Comuns

CódigoMotivo
400Corpo da requisição ausente ou inválido
401Token inválido ou ausente
422Campo financialResponsible enviado indevidamente ou omitido de forma incorreta

🛠️ Suporte

Entre em contato com o time responsável pela API de vendas caso surjam dúvidas ou erros inesperados.