API

Clientes

Gerenciar clientes Pessoa Física (PF) e Jurídica (PJ) via API.

Clientes

Gerencie o cadastro de clientes da sua agência. Suporta Pessoa Física (PF) e Pessoa Jurídica (PJ).

GET /v1/clients

Lista todos os clientes do time.

Query Parameters

ParâmetroTipoPadrãoDescrição
pagenumber1Página atual
limitnumber20Itens por página (máx: 100)
typestringFiltrar por tipo: PF, PJ
statusstringFiltrar: active, inactive
searchstringBuscar por nome, email, CPF ou CNPJ
sortstring-created_atOrdenação. Campos: full_name, email, created_at, updated_at, is_active

Request

curl -X GET "https://app.sonar.marketing/api/v1/clients?type=PJ&status=active" \
  -H "Authorization: Bearer snr_live_sua_chave_aqui"

Response

{
  "success": true,
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": "PJ",
      "name": "TechStore Brasil Ltda",
      "display_name": "TechStore",
      "email": "marketing@techstore.com.br",
      "phone": "+55 11 99999-8888",
      "mobile_phone": null,
      "whatsapp": "+55 11 99999-8888",
      "cpf": null,
      "cnpj": "12.345.678/0001-90",
      "legal_name": "TechStore Brasil Comércio Digital Ltda",
      "trade_name": "TechStore",
      "source": "indicacao",
      "status": "active",
      "notes": null,
      "tags": ["ecommerce"],
      "address": {
        "street": "Av. Paulista",
        "number": "1000",
        "complement": "Sala 101",
        "neighborhood": "Bela Vista",
        "city": "São Paulo",
        "state": "SP",
        "zip_code": "01310-100",
        "country": "Brasil"
      },
      "created_at": "2026-01-15T10:30:00Z",
      "updated_at": "2026-02-04T14:20:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "pages": 8
  }
}

POST /v1/clients

Cria um novo cliente.

Request Body

CampoTipoObrigatórioDescrição
namestringSimNome completo ou razão social
typestringSimPF ou PJ
display_namestringNãoNome de exibição
emailstringNãoEmail
phonestringNãoTelefone
mobile_phonestringNãoCelular
whatsappstringNãoWhatsApp
cpfstringNãoCPF (apenas PF)
rgstringNãoRG (apenas PF)
birth_datestringNãoData nascimento YYYY-MM-DD (apenas PF)
genderstringNãoGênero (apenas PF)
cnpjstringNãoCNPJ (apenas PJ)
legal_namestringNãoRazão social (apenas PJ)
trade_namestringNãoNome fantasia (apenas PJ)
state_registrationstringNãoInscrição estadual (apenas PJ)
addressobjectNãoEndereço (street, number, complement, neighborhood, city, state, zip_code, country)
sourcestringNãoOrigem do cliente
notesstringNãoObservações
tagsarrayNãoTags

Request

curl -X POST https://app.sonar.marketing/api/v1/clients \
  -H "Authorization: Bearer snr_live_sua_chave_aqui" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "PJ",
    "name": "TechStore Brasil Ltda",
    "email": "marketing@techstore.com.br",
    "cnpj": "12.345.678/0001-90",
    "phone": "+55 11 99999-8888",
    "tags": ["ecommerce"]
  }'

Response (201)

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "type": "PJ",
    "name": "TechStore Brasil Ltda",
    "email": "marketing@techstore.com.br",
    "cnpj": "12.345.678/0001-90",
    "status": "active",
    "tags": ["ecommerce"],
    "created_at": "2026-02-04T10:30:00Z",
    "updated_at": "2026-02-04T10:30:00Z"
  }
}

GET /v1/clients/:id

Busca um cliente específico por ID (UUID).

curl -X GET https://app.sonar.marketing/api/v1/clients/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer snr_live_sua_chave_aqui"

PUT /v1/clients/:id

Atualiza campos de um cliente. Envie apenas os campos que deseja alterar.

curl -X PUT https://app.sonar.marketing/api/v1/clients/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer snr_live_sua_chave_aqui" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+55 11 88888-7777",
    "notes": "Cliente VIP"
  }'

DELETE /v1/clients/:id

Desativa o cliente (soft delete — seta is_active = false).

curl -X DELETE https://app.sonar.marketing/api/v1/clients/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer snr_live_sua_chave_aqui"

Response

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "inactive",
    "deactivated_at": "2026-02-04T15:30:00Z"
  }
}

Erros Comuns

CódigoErroSolução
400Campo 'name' é obrigatórioInclua o campo name
400Campo 'type' é obrigatórioUse PF ou PJ
404Cliente não encontradoVerifique o UUID
422CPF já cadastradoCPF duplicado no team
422CNPJ já cadastradoCNPJ duplicado no team

On this page