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

# Cancelar campanha

> Cancele uma campanha agendada

Use este endpoint para cancelar uma campanha agendada. A campanha sai da fila, não é enviada a nenhum destinatário e seu status passa para `CANCELLED`.

## Endpoint

```
DELETE https://api.jelou.ai/v1/campaigns/{campaignId}
```

<Warning>
  Só é possível cancelar campanhas com status `SCHEDULED`.
</Warning>

***

## Parâmetros de rota

| Propriedade    | Tipo   | Descrição                                                                            | Obrigatório |
| -------------- | ------ | ------------------------------------------------------------------------------------ | ----------- |
| **campaignId** | string | ID da campanha que você quer cancelar. Obtenha-o com o endpoint `GET /v1/campaigns`. | Sim         |

***

## Exemplo de requisição

```bash theme={null}
curl --request DELETE \
  --url https://api.jelou.ai/v1/campaigns/CAMPAIGN_ID \
  --header 'Authorization: Basic {{Base64EncodedUsername:Password}}'
```

***

## Respostas

<AccordionGroup>
  <Accordion title="200 - Resposta bem-sucedida">
    ```json theme={null}
    {
      "message": ["Campaign has been cancelled."],
      "statusMessage": "success",
      "status": 1
    }
    ```
  </Accordion>

  <Accordion title="401 - Unauthorized">
    ```json theme={null}
    {
      "message": "Authentication failed"
    }
    ```
  </Accordion>

  <Accordion title="404 - Not Found">
    ```json theme={null}
    {
      "message": ["The requested resource was not found."],
      "statusMessage": "failed",
      "status": 0
    }
    ```
  </Accordion>

  <Accordion title="409 - Campanha não cancelável">
    ```json theme={null}
    {
      "message": ["The campaign cannot be cancelled because it is no longer scheduled."],
      "statusMessage": "failed",
      "status": 0
    }
    ```
  </Accordion>

  <Accordion title="422 - Unprocessable Entity">
    ```json theme={null}
    {
      "message": ["Los valores ingresados no son correctos."],
      "statusMessage": "failed",
      "status": 0,
      "validationError": {
        "id": [
          {
            "es": "El ID de la campaña no es válido",
            "en": "The campaign ID is not valid",
            "pt": "O ID da campanha não é válido"
          }
        ]
      }
    }
    ```
  </Accordion>

  <Accordion title="500 - Internal Server Error">
    ```json theme={null}
    {
      "message": ["We are having trouble processing your request. Please try again later."],
      "statusMessage": "failed",
      "status": 0,
      "error": {
        "code": "E0000",
        "key": "UNKNOWN_ERROR",
        "description": "Error to be thrown when it couldn't be determined the reason of failure",
        "developerMessages": {
          "es": "Error inesperado occurido, revisar logs.",
          "en": "Unexpected error occurred, check logs."
        },
        "clientMessages": {
          "es": "Estamos teniendo problemas procesando la solicitud. Por favor intenta más tarde.",
          "en": "We are having trouble processing your request. Please try again later.",
          "pt": "Estamos tendo problemas com o processo da solicitação. Por favor tente mais tarde."
        }
      }
    }
    ```
  </Accordion>
</AccordionGroup>


## OpenAPI

````yaml DELETE /v1/campaigns/{campaignId}
openapi: 3.1.0
info:
  title: Jelou API
  description: >-
    API for the Jelou platform. Send messages, manage campaigns, handle
    conversations, users, databases, and widgets.
  version: 1.0.0
servers:
  - url: https://api.jelou.ai
    description: Production server
security:
  - basicAuth: []
tags:
  - name: Messages
    description: Send messages to users
  - name: Campaigns
    description: HSM campaigns and templates
  - name: Conversations
    description: Chat history and metrics
  - name: Users
    description: User state and cache management
  - name: Resources
    description: Media resource management
  - name: Datum
    description: Database CRUD operations
  - name: Widget
    description: Widget and room management
  - name: PMA Custom
    description: External support panel integration
  - name: Memory
    description: Per-user session memory management (Memory API v2)
paths:
  /v1/campaigns/{campaignId}:
    delete:
      tags:
        - Campaigns
      summary: Cancelar campaña
      description: Cancela una campaña en estado SCHEDULED antes de que se envíe.
      operationId: cancelCampaign
      parameters:
        - name: campaignId
          in: path
          required: true
          description: ID de la campaña (24 caracteres hexadecimales).
          schema:
            type: string
            example: CAMPAIGN_ID
      responses:
        '200':
          description: Campaign cancelled
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: array
                    items:
                      type: string
                    example:
                      - Campaign has been cancelled.
                  statusMessage:
                    type: string
                    example: success
                  status:
                    type: integer
                    example: 1
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: The campaign is no longer scheduled
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  responses:
    Unauthorized:
      description: Unauthorized - Invalid authentication credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not found - Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnprocessableEntity:
      description: Unprocessable entity - Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        message:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusMessage:
          type: string
        status:
          type: integer
        error:
          type: object
          properties:
            code:
              type: string
            key:
              type: string
            description:
              type: string
            developerMessages:
              type: object
            clientMessages:
              type: object
        validationError:
          type: object
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Basic authentication using Base64 encoded clientId:clientSecret

````