> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pierre.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Spending Limit

> Exclui permanentemente um limite de gastos. O usuário só pode excluir seus próprios limites. Esta operação não pode ser desfeita. Requer API key para autenticação e assinatura ativa.

<Note>
  Este endpoint deleta permanentemente um alerta de gastos existente.
</Note>

## Descrição

O endpoint `DELETE /tools/api/delete-spending-limit` remove permanentemente um alerta de gastos do sistema. Esta ação não pode ser desfeita.

## Autenticação

Este endpoint requer autenticação via Bearer token.

<ParamField header="Authorization" type="string" required>
  Bearer token com a API key do usuário. Formato: `Bearer sk-your-api-key-here`
</ParamField>

## Parâmetros de Query

<ParamField query="s" type="string" required="false">
  Parâmetro interno para indicar requisições via MCP. Use `s=s` para requisições MCP.
</ParamField>

## Body Parameters

<ParamField body="limitId" type="string" required>
  ID do alerta a ser deletado
</ParamField>

## Resposta

### Sucesso (200)

<ResponseExample>
  ```json Success theme={null}
  {
    "success": true,
    "message": "Spending limit for \"Alimentação\" deleted successfully",
    "deletedLimit": {
      "id": "limit_123456789",
      "category": "Alimentação",
      "limitAmount": 1000.00,
      "period": "monthly"
    },
    "timestamp": "2024-11-04T15:30:00Z"
  }
  ```
</ResponseExample>

### Erro de Validação (400)

<ResponseExample>
  ```json Error theme={null}
  {
    "error": "Invalid or missing limitId",
    "message": "limitId must be a non-empty string"
  }
  ```
</ResponseExample>

### Erro de Autenticação (401)

<ResponseExample>
  ```json Error theme={null}
  {
    "error": "Invalid or inactive API key",
    "message": "Please check your API key and try again",
    "type": "invalid_api_key"
  }
  ```
</ResponseExample>

### Erro de Permissão (403)

<ResponseExample>
  ```json Error theme={null}
  {
    "error": "Access denied",
    "message": "You can only delete your own spending limits"
  }
  ```
</ResponseExample>

### Erro - Alerta Não Encontrado (404)

<ResponseExample>
  ```json Error theme={null}
  {
    "error": "Spending limit not found",
    "message": "No spending limit found with ID: limit_123456789"
  }
  ```
</ResponseExample>

## Campos da Resposta

<ResponseField name="success" type="boolean" required>
  Indica se a requisição foi bem-sucedida
</ResponseField>

<ResponseField name="message" type="string" required>
  Mensagem de confirmação da deleção
</ResponseField>

<ResponseField name="deletedLimit" type="object" required>
  Objeto com informações básicas do alerta deletado

  <Expandable title="Deleted Limit Object">
    <ResponseField name="id" type="string" required>
      Identificador único do alerta deletado
    </ResponseField>

    <ResponseField name="category" type="string" required>
      Categoria que estava sendo monitorada
    </ResponseField>

    <ResponseField name="limitAmount" type="number" required>
      Valor limite que estava configurado em BRL
    </ResponseField>

    <ResponseField name="period" type="string" required>
      Período que estava configurado: `daily`, `weekly`, `biweekly`, ou `monthly`
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="timestamp" type="string" required>
  Timestamp da requisição em formato ISO 8601
</ResponseField>

## Exemplos de Uso

### cURL

```bash theme={null}
# Deletar um alerta
curl -X DELETE 'https://www.pierre.finance/tools/api/delete-spending-limit' \
  -H 'Authorization: Bearer sk-your-api-key-here' \
  -H 'Content-Type: application/json' \
  -d '{
    "limitId": "limit_123456789"
  }'
```

### JavaScript

```javascript theme={null}
const API_KEY = 'sk-your-api-key-here';
const BASE_URL = 'https://www.pierre.finance/tools/api';

async function deleteSpendingLimit(limitId) {
  const response = await fetch(`${BASE_URL}/delete-spending-limit`, {
    method: 'DELETE',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ limitId })
  });
  
  return await response.json();
}

// Exemplo de uso
deleteSpendingLimit('limit_123456789');
```

### Python

```python theme={null}
import requests

API_KEY = 'sk-your-api-key-here'
BASE_URL = 'https://www.pierre.finance/tools/api'

headers = {
    'Authorization': f'Bearer {API_KEY}',
    'Content-Type': 'application/json'
}

def delete_spending_limit(limit_id):
    data = {'limitId': limit_id}
    response = requests.delete(f'{BASE_URL}/delete-spending-limit',
                             headers=headers, json=data)
    return response.json()

# Exemplo de uso
result = delete_spending_limit('limit_123456789')
print(result['message'])
```

## Códigos de Status

* `200`: Sucesso - Alerta deletado
* `400`: limitId inválido ou ausente
* `401`: Erro de autenticação
* `403`: Acesso negado - alerta pertence a outro usuário
* `404`: Alerta não encontrado
* `500`: Erro interno do servidor

<Warning>
  **Esta ação é irreversível!** Uma vez deletado, o alerta não pode ser recuperado. Todos os dados relacionados ao histórico de alertas também serão removidos. Se você deseja apenas pausar temporariamente um alerta, considere usar o endpoint `update-spending-limit` com `isActive: false` ao invés de deletar.
</Warning>

<Note>
  Você só pode deletar alertas que pertencem ao seu usuário. Tentar deletar alertas de outros usuários resultará em erro 403 (Access denied).
</Note>

<Tip>
  Após deletar um alerta, o slot na quota do seu plano fica disponível imediatamente para criar um novo alerta.
</Tip>


## OpenAPI

````yaml DELETE /tools/api/delete-spending-limit
openapi: 3.1.0
info:
  title: Pierre Finance API
  description: >-
    API para acessar dados financeiros do Pierre Finance, incluindo contas,
    transações, parcelas e sincronização.
  version: v1.0.0
servers:
  - url: https://www.pierre.finance
security: []
tags:
  - name: Authentication
    description: API key management and authentication
  - name: Accounts
    description: Financial accounts management
  - name: Transactions
    description: Financial transactions
  - name: Installments
    description: Credit card installments and purchases
  - name: Bills
    description: Credit card bills and current bill summaries
  - name: Balance
    description: Account balance information
  - name: Closing Dates
    description: Credit card closing date management
  - name: Sync
    description: Account synchronization
  - name: Spending Limits
    description: Personal spending limits and alerts management
  - name: Payment Reminders
    description: Payment reminders management with WhatsApp and Email notifications
  - name: Analytics
    description: Financial analytics and insights
  - name: Memories
    description: User memory management for personalized AI interactions
  - name: Open Finance
    description: Open Finance connection and integration
paths:
  /tools/api/delete-spending-limit:
    delete:
      tags:
        - Spending Limits
      description: >-
        Exclui permanentemente um limite de gastos. O usuário só pode excluir
        seus próprios limites. Esta operação não pode ser desfeita. Requer API
        key para autenticação e assinatura ativa.
      operationId: deleteSpendingLimit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - limitId
              properties:
                limitId:
                  type: string
                  description: ID do limite de gastos a ser excluído
      responses:
        '200':
          description: Limite de gastos excluído com sucesso
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Spending limit for "Alimentação" deleted successfully
                  deletedLimit:
                    type: object
                    properties:
                      id:
                        type: string
                      category:
                        type: string
                      limitAmount:
                        type: string
                      period:
                        type: string
                  timestamp:
                    type: string
                    format: date-time
        '400':
          description: Parâmetros inválidos
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid or missing limitId
                  message:
                    type: string
                    example: limitId must be a non-empty string
        '401':
          $ref: '#/components/responses/AuthError'
        '403':
          description: Acesso negado
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Access denied
                  message:
                    type: string
                    example: You can only delete your own spending limits
        '404':
          description: Limite não encontrado
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Spending limit not found
                  message:
                    type: string
                    example: 'No spending limit found with ID: sl_123abc'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - BearerAuth: []
components:
  responses:
    AuthError:
      description: Authentication or subscription error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
    ServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ServerError'
  schemas:
    AuthError: {}
    ServerError: {}
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: string
      description: 'API key in Bearer token format. Example: Bearer sk-your-api-key-here'

````