Pular para o conteúdo principal

Risk Bands

Gerenciamento de faixas de risco baseadas em score de credito.

Endpoints

MétodoEndpointDescriçãoPermissão
POST/api/v1/risk-bandsCriar risk bandPRICING_RISK_BANDS_CREATE
GET/api/v1/risk-bandsListar risk bandsPRICING_RISK_BANDS_READ
GET/api/v1/risk-bands/:idObter risk bandPRICING_RISK_BANDS_READ
PATCH/api/v1/risk-bands/:idAtualizar risk bandPRICING_RISK_BANDS_UPDATE
DELETE/api/v1/risk-bands/:idExcluir risk bandPRICING_RISK_BANDS_DELETE

Atributos

CampoTipoObrigatórioDescrição
productIdstring (UUID)SimID do produto associado
namestringSimNome da faixa (ex: LOW_RISK, HIGH_RISK)
displayLabelstringNãoLabel para exibicao
minScoreintegerSimScore mínimo (0-1000)
maxScoreintegerSimScore máximo (0-1000)
baseRatenumberSimTaxa base mensal (0-1, ex: 0.0199 = 1.99%)
maxRatenumberNãoTaxa maxima
rateSpreadnumberNãoSpread sobre a taxa base (-1 a 1)
priorityintegerNãoPrioridade para ordenacao
isActivebooleanNãoSe a faixa esta ativa

Criar Risk Band

POST /api/v1/risk-bands

Cria uma nova faixa de risco.

Request

curl -X POST 'https://pricing.stg.catalisa.app/api/v1/risk-bands' \
-H 'Authorization: Bearer SEU_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"type": "risk-bands",
"attributes": {
"productId": "550e8400-e29b-41d4-a716-446655440000",
"name": "LOW_RISK",
"displayLabel": "Baixo Risco",
"minScore": 700,
"maxScore": 850,
"baseRate": 0.0199,
"rateSpread": 0.005,
"priority": 1,
"isActive": true
}
}
}'

Response (201 Created)

{
"data": {
"type": "risk-bands",
"id": "550e8400-e29b-41d4-a716-446655440001",
"attributes": {
"productId": "550e8400-e29b-41d4-a716-446655440000",
"name": "LOW_RISK",
"displayLabel": "Baixo Risco",
"minScore": 700,
"maxScore": 850,
"baseRate": 0.0199,
"rateSpread": 0.005,
"priority": 1,
"isActive": true,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
"links": {
"self": "/api/v1/risk-bands/550e8400-e29b-41d4-a716-446655440001"
}
}
}

Listar Risk Bands

GET /api/v1/risk-bands

Lista risk bands com suporte a paginação e filtros.

Query Parameters

ParâmetroTipoDescrição
page[number]integerNúmero da pagina
page[size]integerItens por pagina
productIdstringFiltrar por produto
isActivebooleanFiltrar por status ativo
curl 'https://pricing.stg.catalisa.app/api/v1/risk-bands?productId=550e8400-e29b-41d4-a716-446655440000&isActive=true' \
-H 'Authorization: Bearer SEU_TOKEN'

Response (200 OK)

{
"data": [
{
"type": "risk-bands",
"id": "550e8400-e29b-41d4-a716-446655440001",
"attributes": {
"productId": "550e8400-e29b-41d4-a716-446655440000",
"name": "LOW_RISK",
"minScore": 700,
"maxScore": 850,
"baseRate": 0.0199,
"isActive": true
}
},
{
"type": "risk-bands",
"id": "550e8400-e29b-41d4-a716-446655440002",
"attributes": {
"productId": "550e8400-e29b-41d4-a716-446655440000",
"name": "MEDIUM_RISK",
"minScore": 500,
"maxScore": 699,
"baseRate": 0.0299,
"isActive": true
}
}
],
"meta": {
"totalItems": 3,
"totalPages": 1,
"currentPage": 1
},
"links": {
"self": "/api/v1/risk-bands?page[number]=1&page[size]=20"
}
}

Obter Risk Band

GET /api/v1/risk-bands/:id

Obtém detalhes de uma risk band específica.

curl 'https://pricing.stg.catalisa.app/api/v1/risk-bands/550e8400-e29b-41d4-a716-446655440001' \
-H 'Authorization: Bearer SEU_TOKEN'

Response (200 OK)

{
"data": {
"type": "risk-bands",
"id": "550e8400-e29b-41d4-a716-446655440001",
"attributes": {
"productId": "550e8400-e29b-41d4-a716-446655440000",
"name": "LOW_RISK",
"displayLabel": "Baixo Risco",
"minScore": 700,
"maxScore": 850,
"baseRate": 0.0199,
"rateSpread": 0.005,
"priority": 1,
"isActive": true,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
"links": {
"self": "/api/v1/risk-bands/550e8400-e29b-41d4-a716-446655440001"
}
}
}

Atualizar Risk Band

PATCH /api/v1/risk-bands/:id

Atualiza uma risk band existente.

curl -X PATCH 'https://pricing.stg.catalisa.app/api/v1/risk-bands/550e8400-e29b-41d4-a716-446655440001' \
-H 'Authorization: Bearer SEU_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"data": {
"type": "risk-bands",
"id": "550e8400-e29b-41d4-a716-446655440001",
"attributes": {
"baseRate": 0.0179,
"isActive": false
}
}
}'

Response (200 OK)

{
"data": {
"type": "risk-bands",
"id": "550e8400-e29b-41d4-a716-446655440001",
"attributes": {
"productId": "550e8400-e29b-41d4-a716-446655440000",
"name": "LOW_RISK",
"baseRate": 0.0179,
"isActive": false,
"updatedAt": "2024-01-15T11:00:00Z"
}
}
}

Excluir Risk Band

DELETE /api/v1/risk-bands/:id

Remove uma risk band.

curl -X DELETE 'https://pricing.stg.catalisa.app/api/v1/risk-bands/550e8400-e29b-41d4-a716-446655440001' \
-H 'Authorization: Bearer SEU_TOKEN'

Response (204 No Content)

Sem corpo de resposta.


Exemplo de Configuração de Faixas

// Configurar 3 faixas de risco para um produto
const riskBands = [
{ name: 'EXCELLENT', minScore: 800, maxScore: 1000, baseRate: 0.0149 },
{ name: 'GOOD', minScore: 650, maxScore: 799, baseRate: 0.0199 },
{ name: 'FAIR', minScore: 500, maxScore: 649, baseRate: 0.0299 },
];

for (const band of riskBands) {
await fetch('https://pricing.stg.catalisa.app/api/v1/risk-bands', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
data: {
type: 'risk-bands',
attributes: {
productId: 'product-uuid',
...band,
isActive: true,
},
},
}),
});
}

Erros Comuns

CódigoErroDescrição
400VALIDATIONCampos obrigatorios ausentes ou inválidos
404NOT_FOUNDRisk band nao encontrada
409CONFLICTFaixas de score sobrepostas para o mesmo produto