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

# Cancel sent invoice

> Cancels a sent invoice, by ID, and, optionally, sends a notification about the cancellation to the payer, merchant, and CC: emails.



## OpenAPI

````yaml /api-reference/invoicing_v2.json post /v2/invoicing/invoices/{invoice_id}/cancel
openapi: 3.0.3
info:
  title: Invoices
  description: >-
    Use the Invoicing API to create, send, and manage invoices. You can also use
    the API or webhooks to track invoice payments. When you send an invoice to a
    customer, the invoice moves from draft to payable state. PayPal then emails
    the customer a link to the invoice on the PayPal website. Customers with a
    PayPal account can log in and pay the invoice with PayPal. Alternatively,
    customers can pay as a guest with a debit card or credit card. For more
    information, see the <a href="/docs/invoicing/">Invoicing Overview</a> and
    the <a href="/docs/invoicing/basic-integration/">Invoicing Integration
    Guide</a>.
  version: '2.7'
  contact: {}
servers:
  - url: https://api-m.sandbox.paypal.com
    description: PayPal Sandbox Environment
  - url: https://api-m.paypal.com
    description: PayPal Live Environment
security: []
tags:
  - name: invoices
    description: >-
      Use the `/invoices` resource to create, update, and send invoices and
      invoice reminders. To manage invoices, you can also list invoices, show
      details for invoices, delete draft invoices, and cancel sent invoices. You
      can also record payments for invoices to mark them as fully or partially
      paid, or record refunds for invoices to mark them as fully or partially
      refunded. You can create QR codes for invoices that can be scanned,
      viewed, and paid by a mobile phone.
  - name: search-invoices
    description: >-
      Use the `/search-invoices` resource to search for and list invoices that
      match search criteria.
  - name: templates
    description: >-
      Use the `/templates` resource to create, list, show details for, update,
      and delete invoice templates. Use the `/templates` resource when you
      create a third-party invoicing application. For instance, a business can
      create a template with predefined invoice data. Later, the business can
      select the template to populate the invoice
      data.<blockquote><strong>Note:</strong> To upload a logo to display on an
      invoice, you can use the <strong>Template Settings</strong> dashboard to
      <a href="https://www.paypal.com/invoice/settings/templates">create a
      template</a>. When you create an invoice, you can use the URI for that
      logo.</blockquote>
  - name: merchant-config
    description: >-
      Use the `/merchant-config` resource to create, update and show details of
      merchant configuration.
  - name: estimates
    description: Use the /estimate resource to create, update, and send estimates.
  - name: batch-tasks
    description: >-
      Use the /batch-tasks resource to create, delete and retrieve batch related
      tasks.
  - name: stored-discounts
    description: >-
      Use the /stored-discounts resource to create and retrieve stored-discounts
      are specific to merchants
  - name: Search Enhancement
    description: >-
      This section contains the list of api, used to power invoicing search
      based on Index Organised Table(s).
  - name: Invoicing Multi Tenancy
    description: This section contains api to get the tenant config details.
  - name: Invoice Notification
    description: >-
      Use the /email-status-feedback resource to post the status update against
      invoicing emails.
  - name: Customer Feedbacks
    description: >-
      Use the /customer-feedbacks resource to create and retrieve feedbacks
      specific to merchants.
  - name: Insights
    description: >-
      Use the /insights resource to retrieve aggregated metrics specific to
      merchants.
  - name: invoicing-product-features
    description: >-
      This section contains the list of invoicing-product-features related
      api's.
  - name: conditional-rules
    description: This section contains api's related to conditional rules.
  - name: invoice-payment-attempt
    description: This section contains api's related to invoice payment attempt.
  - name: connections
    description: >-
      Use the `accounting-sync/merchants/connections` resource to get active
      connections list.
  - name: invoice-connection-details
    description: >-
      Use the `accounting-sync/invoices/{id}/connections` resource to get active
      connections list.
  - name: Invoicing themes
    description: >-
      Use the /themes resource to create, update and get details of themes
      related to merchants.
  - name: Bulk Sync Invoices - Accounting Sync
    description: >-
      Use the /accounting-invoices-batch resource to bulk sync invoices with
      accounting software.
  - name: account closure
    description: >-
      Use the /cancel-user-records resource to cancel open records for a user
      and /get-user-record-count to get count of open records.
  - name: Accounting sync
    description: This section contains invoicing APIs related to accounting sync.
externalDocs:
  url: https://developer.paypal.com/docs/api/invoicing/v2/
paths:
  /v2/invoicing/invoices/{invoice_id}/cancel:
    post:
      tags:
        - invoices
      summary: Cancel sent invoice
      description: >-
        Cancels a sent invoice, by ID, and, optionally, sends a notification
        about the cancellation to the payer, merchant, and CC: emails.
      operationId: invoices.cancel
      parameters:
        - $ref: '#/components/parameters/invoice_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/notification'
        description: >-
          The email or SMS notification that will be sent to the payer on
          cancellation.
        required: true
      responses:
        '204':
          description: >-
            A successful request returns the HTTP `204 No Content` status code
            with no JSON response body.
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/error_400'
                  - $ref: '#/components/schemas/invoices.cancel-400'
        '403':
          description: Authorization Error.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/error_403'
                  - $ref: '#/components/schemas/403'
        '404':
          description: Resource Not Found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_404'
        '422':
          description: Unprocessable Entity.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/error_422'
                  - $ref: '#/components/schemas/invoices.cancel-422'
        '500':
          description: An internal server error has occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_500'
        default:
          $ref: '#/components/responses/default'
      security:
        - Oauth2:
            - https://uri.paypal.com/services/invoicing/invoices/readwrite
components:
  parameters:
    invoice_id:
      name: invoice_id
      in: path
      required: true
      description: The ID of the draft invoice to delete.
      schema:
        type: string
        minLength: 0
        maxLength: 2147483647
        pattern: ^.*$
  schemas:
    '403':
      properties:
        details:
          type: array
          items:
            anyOf:
              - title: PERMISSION_DENIED
                properties:
                  issue:
                    type: string
                    enum:
                      - PERMISSION_DENIED
                  description:
                    type: string
                    enum:
                      - >-
                        The requested invoice is not associated with the
                        requested user.
    notification:
      type: object
      title: Notification
      description: >-
        The email or SMS notification to send to the invoicer or payer on
        sending an invoice.
      properties:
        subject:
          type: string
          description: >-
            The subject of the email that is sent as a notification to the
            recipient.<blockquote><strong>Note:</strong> User-provided values
            for this field will not be honored and the subject will always be
            defaulted to a system-defined value.</blockquote>
          pattern: ^[\S\s]*$
          minLength: 0
          maxLength: 4000
        note:
          type: string
          description: >-
            A note to the payer.<blockquote><strong>Note:</strong> User-provided
            values for this field will not be honored and the note will always
            be defaulted to a system-defined value.</blockquote>
          pattern: ^[\S\s]*$
          minLength: 0
          maxLength: 4000
        send_to_invoicer:
          type: boolean
          description: Indicates whether to send a copy of the email to the merchant.
          default: false
        send_to_recipient:
          type: boolean
          description: Indicates whether to send a copy of the email to the recipient.
          default: true
        additional_recipients:
          $ref: '#/components/schemas/email_address_list'
    error_400:
      type: object
      title: Bad Request Error
      description: Request is not well-formed, syntactically incorrect, or violates schema.
      properties:
        name:
          type: string
          enum:
            - INVALID_REQUEST
        message:
          type: string
          enum:
            - >-
              Request is not well-formed, syntactically incorrect, or violates
              schema.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    invoices.cancel-400:
      properties:
        details:
          type: array
          items:
            anyOf:
              - title: INVALID_STRING_MAX_LENGTH
                properties:
                  issue:
                    type: string
                    enum:
                      - INVALID_STRING_MAX_LENGTH
                  description:
                    type: string
                    enum:
                      - >-
                        Field value exceeded the maximum allowed number of
                        characters.
              - title: INVALID_ARRAY_MAX_ITEMS
                properties:
                  issue:
                    type: string
                    enum:
                      - INVALID_ARRAY_MAX_ITEMS
                  description:
                    type: string
                    enum:
                      - >-
                        Only maximum of 100 email address is supported in
                        additional recipients.
    error_403:
      type: object
      title: Not Authorized Error
      description: >-
        The client is not authorized to access this resource, although it may
        have valid credentials. 
      properties:
        name:
          type: string
          enum:
            - NOT_AUTHORIZED
        message:
          type: string
          enum:
            - Authorization failed due to insufficient permissions.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    error_404:
      type: object
      title: Not found Error
      description: >-
        The server has not found anything matching the request URI. This either
        means that the URI is incorrect or the resource is not available.
      properties:
        name:
          type: string
          enum:
            - RESOURCE_NOT_FOUND
        message:
          type: string
          enum:
            - The specified resource does not exist.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    error_422:
      type: object
      title: Unprocessable Entity Error
      description: >-
        The requested action cannot be performed and may require interaction
        with APIs or processes outside of the current request. This is distinct
        from a 500 response in that there are no systemic problems limiting the
        API from performing the request.
      properties:
        name:
          type: string
          enum:
            - UNPROCESSABLE_ENTITY
        message:
          type: string
          enum:
            - >-
              The requested action could not be performed, semantically
              incorrect, or failed business validation.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    invoices.cancel-422:
      properties:
        details:
          type: array
          items:
            anyOf:
              - title: CANNOT_CANCEL_DRAFT_INVOICE
                properties:
                  issue:
                    type: string
                    enum:
                      - CANNOT_CANCEL_DRAFT_INVOICE
                  description:
                    type: string
                    enum:
                      - Draft invoice cannot be canceled.
              - title: CANNOT_CANCEL_PAID_INVOICE
                properties:
                  issue:
                    type: string
                    enum:
                      - CANNOT_CANCEL_PAID_INVOICE
                  description:
                    type: string
                    enum:
                      - Cannot cancel a paid or partially paid invoice.
              - title: CANNOT_CANCEL_REFUNDED_INVOICE
                properties:
                  issue:
                    type: string
                    enum:
                      - CANNOT_CANCEL_REFUNDED_INVOICE
                  description:
                    type: string
                    enum:
                      - Cannot cancel a refunded or partially refunded invoice.
              - title: CANNOT_CANCEL_SCHEDULED_INVOICE
                properties:
                  issue:
                    type: string
                    enum:
                      - CANNOT_CANCEL_SCHEDULED_INVOICE
                  description:
                    type: string
                    enum:
                      - Cannot cancel a scheduled invoice.
              - title: INVOICE_CANCELED_ALREADY
                properties:
                  issue:
                    type: string
                    enum:
                      - INVOICE_CANCELED_ALREADY
                  description:
                    type: string
                    enum:
                      - Invoice is already cancelled.
    error_500:
      type: object
      title: Internal Server Error
      description: >-
        This is either a system or application error, and generally indicates
        that although the client appeared to provide a correct request,
        something unexpected has gone wrong on the server.
      properties:
        name:
          type: string
          enum:
            - INTERNAL_SERVER_ERROR
        message:
          type: string
          enum:
            - An internal server error occurred.
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
      example:
        name: INTERNAL_SERVER_ERROR
        message: An internal server error occurred.
        debug_id: 90957fca61718
        links:
          - href: >-
              https://developer.paypal.com/api/orders/v2/#error-INTERNAL_SERVER_ERROR
            rel: information_link
    email_address_list:
      type: array
      minItems: 0
      maxItems: 100
      description: >-
        An array of one or more CC: emails to which notifications are sent. If
        you omit this parameter, a notification is sent to all CC: email
        addresses that are part of the
        invoice.<blockquote><strong>Note:</strong> Valid values are email
        addresses in the `additional_recipients` value associated with the
        invoice.</blockquote>
      items:
        $ref: '#/components/schemas/email_address'
    error_details:
      title: Error Details
      type: object
      description: The error details. Required for client-side `4XX` errors.
      properties:
        field:
          type: string
          description: >-
            The field that caused the error. If this field is in the body, set
            this value to the field's JSON pointer value. Required for
            client-side errors.
        value:
          type: string
          description: The value of the field that caused the error.
        location:
          $ref: '#/components/schemas/error_location'
        issue:
          type: string
          description: The unique, fine-grained application-level error code.
        description:
          type: string
          description: >-
            The human-readable description for an issue. The description can
            change over the lifetime of an API, so clients must not depend on
            this value.
      required:
        - issue
    error_link_description:
      title: Link Description
      description: >-
        The request-related [HATEOAS link](/api/rest/responses/#hateoas-links)
        information.
      type: object
      required:
        - href
        - rel
      properties:
        href:
          description: >-
            The complete target URL. To make the related call, combine the
            method with this [URI
            Template-formatted](https://tools.ietf.org/html/rfc6570) link. For
            pre-processing, include the `$`, `(`, and `)` characters. The `href`
            is the key HATEOAS component that links a completed call with a
            subsequent call.
          type: string
          minLength: 0
          maxLength: 20000
          pattern: ^.*$
        rel:
          description: >-
            The [link relation
            type](https://tools.ietf.org/html/rfc5988#section-4), which serves
            as an ID for a link that unambiguously describes the semantics of
            the link. See [Link
            Relations](https://www.iana.org/assignments/link-relations/link-relations.xhtml).
          type: string
          minLength: 0
          maxLength: 100
          pattern: ^.*$
        method:
          description: The HTTP method required to make the related call.
          type: string
          minLength: 3
          maxLength: 6
          pattern: ^[A-Z]*$
          enum:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
    error_default:
      description: The default error response.
      oneOf:
        - $ref: '#/components/schemas/error_400'
        - $ref: '#/components/schemas/error_401'
        - $ref: '#/components/schemas/error_403'
        - $ref: '#/components/schemas/error_404'
        - $ref: '#/components/schemas/error_409'
        - $ref: '#/components/schemas/error_415'
        - $ref: '#/components/schemas/error_422'
        - $ref: '#/components/schemas/error_429'
        - $ref: '#/components/schemas/error_500'
        - $ref: '#/components/schemas/error_503'
    email_address:
      type: string
      description: >-
        The internationalized email address.<blockquote><strong>Note:</strong>
        Up to 64 characters are allowed before and 255 characters are allowed
        after the <code>@</code> sign. However, the generally accepted maximum
        length for an email address is 254 characters. The pattern verifies that
        an unquoted <code>@</code> sign exists.</blockquote>
      format: ppaas_common_email_address_v2
      minLength: 3
      maxLength: 254
      pattern: >-
        ^(?:[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[A-Za-z0-9-]*[A-Za-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$
    error_location:
      type: string
      description: >-
        The location of the field that caused the error. Value is `body`,
        `path`, or `query`.
      enum:
        - body
        - path
        - query
      default: body
    error_401:
      type: object
      title: Unauthorized Error
      description: >-
        Authentication failed due to missing Authorization header, or invalid
        authentication credentials.
      properties:
        name:
          type: string
          enum:
            - AUTHENTICATION_FAILURE
        message:
          type: string
          enum:
            - >-
              Authentication failed due to missing authorization header, or
              invalid authentication credentials.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    error_409:
      type: object
      title: Resource Conflict Error
      description: The server has detected a conflict while processing this request.
      properties:
        name:
          type: string
          enum:
            - RESOURCE_CONFLICT
        message:
          type: string
          enum:
            - The server has detected a conflict while processing this request.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    error_415:
      type: object
      title: Unsupported Media Type Error
      description: The server does not support the request payload's media type.
      properties:
        name:
          type: string
          enum:
            - UNSUPPORTED_MEDIA_TYPE
        message:
          type: string
          enum:
            - The server does not support the request payload's media type.
        details:
          type: array
          items:
            $ref: '#/components/schemas/error_details'
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
    error_429:
      type: object
      title: Too many requests
      description: Too many requests. Blocked due to rate limiting.
      properties:
        name:
          type: string
          enum:
            - RATE_LIMIT_REACHED
        message:
          type: string
          enum:
            - Too many requests. Blocked due to rate limiting.
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
    error_503:
      type: object
      title: Service Unavailable Error
      description: >-
        The server is temporarily unable to handle the request, for example,
        because of planned maintenance or downtime.
      properties:
        name:
          type: string
          enum:
            - SERVICE_UNAVAILABLE
        message:
          type: string
          enum:
            - Service Unavailable.
        debug_id:
          type: string
          description: The PayPal internal ID. Used for correlation purposes.
        links:
          description: >-
            An array of request-related [HATEOAS
            links](https://en.wikipedia.org/wiki/HATEOAS).
          type: array
          minItems: 0
          maxItems: 10000
          items:
            $ref: '#/components/schemas/error_link_description'
      example:
        name: SERVICE_UNAVAILABLE
        message: Service Unavailable.
        debug_id: 90957fca61718
        information_link: >-
          https://developer.paypal.com/docs/api/orders/v2/#error-SERVICE_UNAVAILABLE
  responses:
    default:
      description: The default response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error_default'
  securitySchemes:
    Oauth2:
      type: oauth2
      description: Oauth 2.0 authentication
      flows:
        clientCredentials:
          tokenUrl: /v1/oauth2/token
          scopes:
            https://uri.paypal.com/services/invoicing/invoices/read: For Reading the invoice details.
            https://uri.paypal.com/services/invoicing/invoices/readwrite: For managing (Create, Update, Delete) invoice.
            https://uri.paypal.com/services/invoicing/internal: Manage invoice resource internal clients.

````