Skip to main content

Delete Restriction

Soft delete a restriction rule. The rule is marked as inactive but not permanently removed.

Endpoint

DELETE /api/v1/restrictions/:id
Authorization: ADMIN only

Path Parameters

id
string
required
UUID of the restriction rule to delete

Request Body

reason
string
Optional reason for deletion (3-200 characters)Stored for audit purposes and compliance.

Response

success
boolean
Indicates if the request was successful
data
object
Deleted restriction rule with:
  • isActive = false
  • deletedAt timestamp
  • deletedReason (if provided)

Examples

curl -X DELETE "https://api.example.com/api/v1/restrictions/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "Número 25 ya no es popular, eliminando restricción"
  }'

Response Example

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "bancaId": "banca-uuid",
    "number": "25",
    "maxAmount": 5000,
    "isActive": false,
    "deletedAt": "2025-03-15T14:30:00.000Z",
    "deletedReason": "Número 25 ya no es popular, eliminando restricción"
  }
}

Implementation Details

From src/api/v1/controllers/restrictionRule.controller.ts:24-31:
async delete(req: AuthenticatedRequest, res: Response) {
  const rule = await RestrictionRuleService.remove(
    req.user!.id,
    req.params.id,
    req.body?.reason
  );
  res.json({ success: true, data: rule });
}

Restore Restriction

Restore a soft-deleted restriction rule, making it active again.

Endpoint

PATCH /api/v1/restrictions/:id/restore
Authorization: ADMIN only

Path Parameters

id
string
required
UUID of the restriction rule to restore

Response

success
boolean
Indicates if the request was successful
data
object
Restored restriction rule with:
  • isActive = true
  • deletedAt = null
  • deletedReason = null

Example

curl -X PATCH "https://api.example.com/api/v1/restrictions/550e8400-e29b-41d4-a716-446655440000/restore" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response Example

{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "bancaId": "banca-uuid",
    "number": "25",
    "maxAmount": 5000,
    "isActive": true,
    "deletedAt": null,
    "deletedReason": null,
    "updatedAt": "2025-03-15T15:00:00.000Z"
  }
}

Implementation Details

From src/api/v1/controllers/restrictionRule.controller.ts:33-38:
async restore(req: AuthenticatedRequest, res: Response) {
  const rule = await RestrictionRuleService.restore(
    req.user!.id,
    req.params.id
  );
  res.json({ success: true, data: rule });
}

Best Practices

Providing a clear reason helps with:
  • Compliance and auditing
  • Understanding historical decisions
  • Debugging configuration issues
Good reasons:
  • “Número ya no es de alto riesgo”
  • “Promoción temporal finalizada”
  • “Error de configuración, recreando correctamente”
Instead of deleting and recreating, use:
  1. Delete with reason: “Deshabilitado temporalmente durante mantenimiento”
  2. Restore when ready
This preserves the rule ID and audit history.
Use the List endpoint with isActive=false to review deleted rules:
GET /api/v1/restrictions?isActive=false&bancaId=uuid

Error Responses

{
  "success": false,
  "error": "Restriction rule not found",
  "code": "NOT_FOUND"
}

Create Restriction

Create new restriction rule

Update Restriction

Modify existing rule

List Restrictions

View all restriction rules

Build docs developers (and LLMs) love