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

# Eliminar Afiliado

> Aprende a eliminar un afiliado usando el endpoint DELETE /stores/{storeId}/affiliates/{affiliateId}.

## 📌 Endpoint

`DELETE /stores/{storeId}/affiliates/{affiliateId}`

Elimina un afiliado de la tienda (**soft delete**). El afiliado desaparece de los listados, pero el registro permanece en la base de datos por seguridad — incluyendo la resolución de comisiones, que deja de considerarlo.

> **Requisito:** El afiliado debe estar **pausado** (`status: "inativo"`) durante al menos **7 días** para poder ser eliminado. De lo contrario, la API devuelve `400` (`AFFILIATE_NOT_PAUSED` o `AFFILIATE_PAUSE_PERIOD_NOT_ELAPSED`).

***

## 🔐 Autenticación

* **Ruta privada**.
* Requiere el header `Authorization` con tu API key y plan activo.

```json theme={null}
{
	"Authorization": "TU_API_KEY_AQUI"
}
```

***

## 🧾 Parámetros de ruta

| Parámetro | Tipo | Obligatorio | Descripción |
| - | - | - | - |
| `storeId` | string | Sí | ID de la tienda |
| `affiliateId` | string | Sí | ID del afiliado |

***

## ✅ Ejemplo de solicitud

```bash theme={null}
curl -X DELETE "https://api.cabrapi.com.br/v1/stores/STORE_ID/affiliates/AFFILIATE_ID" \
	-H "Authorization: TU_API_KEY_AQUI"
```

***

## 📦 Respuesta exitosa (200)

```json theme={null}
{
	"code": "AFFILIATE_DELETED"
}
```

***

## ⚠️ Posibles errores

* `400 INVALID_DATA` → parámetros inválidos
* `400 AFFILIATE_NOT_PAUSED` → el afiliado debe estar pausado (`status: "inativo"`) antes de poder eliminarlo
* `400 AFFILIATE_PAUSE_PERIOD_NOT_ELAPSED` → el afiliado debe permanecer pausado al menos 7 días
* `401 API_KEY_NOT_PROVIDED` → header `Authorization` no enviado
* `401 INVALID_API_KEY` → API key inválida
* `401 UNAUTHENTICATED` → usuario no autenticado
* `403 USER_DISABLED` → usuario deshabilitado
* `403 NO_ACTIVE_SUBSCRIPTION` → sin plan activo
* `404 STORE_NOT_FOUND` → tienda no encontrada
* `404 AFFILIATE_NOT_FOUND` → afiliado no encontrado
* `429 RATE_LIMIT_EXCEEDED` → límite de solicitudes por minuto excedido
* `500 INTERNAL_SERVER_ERROR` → error interno
* `503 SERVICE_UNAVAILABLE` → servicio no disponible


## OpenAPI

````yaml DELETE /stores/{storeId}/affiliates/{affiliateId}
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/affiliates/{affiliateId}:
    delete:
      tags:
        - Affiliates
      summary: Delete affiliate
      operationId: deleteAffiliate
      parameters:
        - $ref: '#/components/parameters/StoreId'
        - $ref: '#/components/parameters/AffiliateId'
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: AFFILIATE_DELETED
                    type: string
                required:
                  - code
                type: object
          description: Delete affiliate.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid API key.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden (inactive plan or insufficient permissions).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Rate limit exceeded.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal server error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security:
        - ApiKey: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
    AffiliateId:
      in: path
      name: affiliateId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object
  securitySchemes:
    ApiKey:
      in: header
      name: Authorization
      type: apiKey
      x-default: YOUR_API_KEY_HERE

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.