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

# Cancel a contact's enrollment in the campaign

> Identify the enrollment by `enrollment_id` or by the contact (`contact_id`), exactly one of the two; both or neither return 400. An ACTIVE or WAITING_CONNECTION enrollment becomes COMPLETED with `completion_reason: CANCELLED_BY_API`, the sends still scheduled are removed from the queue, and the response has `cancelled: true` with the `previous_status`. A send that's already in progress at the time of the cancellation can still go out. Cancelling doesn't complete the campaign, even if no pending enrollment is left. An enrollment that already ended (for any reason) returns 200 with `cancelled: false` and `reason: already_completed`, without changing anything. An enrollment or contact outside this campaign of the company returns 404 (`CAMPAIGN_ENROLLMENT_NOT_FOUND`). Requires the `campaign-enrollments:update` scope on the API key.



## OpenAPI

````yaml /en/openapi.json post /v1/campaigns/{campaignId}/enrollments/cancel
openapi: 3.0.0
info:
  title: Nuvia API - Company
  description: API documentation for companies
  version: '1.0'
  contact: {}
servers:
  - url: https://api.nuvia.ai
security: []
tags:
  - name: messages
    x-group: Messages
  - name: contacts
    x-group: Contacts
  - name: campaigns
    x-group: Campaigns
  - name: tables
    x-group: Tables and lists
  - name: agents
    x-group: Agents
  - name: conversations
    x-group: Conversations
  - name: inboxes
    x-group: Inboxes
  - name: knowledge
    x-group: Knowledge base
  - name: Webhooks
    x-group: Webhooks
  - name: campaign-enrollments
    x-group: Campaign enrollments
  - name: custom-fields
    x-group: Custom fields
  - name: resources
    x-group: Files and attachments
  - name: hubspot
    x-group: HubSpot
  - name: users
    x-group: Users
paths:
  /v1/campaigns/{campaignId}/enrollments/cancel:
    post:
      tags:
        - campaign-enrollments
      summary: Cancel a contact's enrollment in the campaign
      description: >-
        Identify the enrollment by `enrollment_id` or by the contact
        (`contact_id`), exactly one of the two; both or neither return 400. An
        ACTIVE or WAITING_CONNECTION enrollment becomes COMPLETED with
        `completion_reason: CANCELLED_BY_API`, the sends still scheduled are
        removed from the queue, and the response has `cancelled: true` with the
        `previous_status`. A send that's already in progress at the time of the
        cancellation can still go out. Cancelling doesn't complete the campaign,
        even if no pending enrollment is left. An enrollment that already ended
        (for any reason) returns 200 with `cancelled: false` and `reason:
        already_completed`, without changing anything. An enrollment or contact
        outside this campaign of the company returns 404
        (`CAMPAIGN_ENROLLMENT_NOT_FOUND`). Requires the
        `campaign-enrollments:update` scope on the API key.
      operationId: CampaignEnrollmentController_cancel
      parameters:
        - name: x-company-id
          in: header
          description: >-
            Target company identifier. Required only for global API keys
            (type=global). Ignored for company API keys and human users.
          required: false
          schema:
            type: string
        - name: campaignId
          required: true
          in: path
          description: Campaign ID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelEnrollmentBodyDto'
            examples:
              inscricao:
                summary: Cancelar pela inscrição
                value:
                  enrollment_id: 6650f1a2b3c4d5e6f7a8b9c6
              contato:
                summary: Cancelar pelo contato
                value:
                  contact_id: 6650f1a2b3c4d5e6f7a8b9c1
      responses:
        '200':
          description: >-
            `{ cancelled: true, enrollment_id, previous_status }` or `{
            cancelled: false, reason: "already_completed" }`
        '400':
          description: Body without exactly one of enrollment_id and contact_id
        '404':
          description: Enrollment or contact outside this campaign of the company
      security:
        - JWT-auth: []
components:
  schemas:
    CancelEnrollmentBodyDto:
      type: object
      properties:
        enrollment_id:
          type: string
          description: >-
            ID of the enrollment to cancel. Don't send it together with
            `contact_id`.
          pattern: ^[a-f0-9]{24}$
        contact_id:
          type: string
          description: >-
            ID of the contact whose enrollment in this campaign will be
            cancelled. Don't send it together with `enrollment_id`.
          pattern: ^[a-f0-9]{24}$
  securitySchemes:
    JWT-auth:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: JWT authentication token

````

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