# CancelInvoice API Operation (/api/nvp-soap/cancel-invoice)



> **Note:** **Important:** The Adaptive Platform API is not available for
> new integrations. PayPal provides this documentation to support existing
> integrations. If you're starting an integration,
> [we recommend our latest solutions](/).

Cancels an invoice.

## Example [#example]

This example calls `CancelInvoice` to cancel an invoice. PayPal can
notify the payer that the invoice has been canceled.

```bash lineNumbers
curl https://sandbox.svcs.paypal.com/Invoice/CancelInvoice \ -s \ --insecure \ -H "X-PAYPAL-SECURITY-USERID: " \ -H "X-PAYPAL-SECURITY-PASSWORD: " \ -H "X-PAYPAL-SECURITY-SIGNATURE: " \ -H "X-PAYPAL-REQUEST-DA TA-FORMAT: NV" \ -H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \ -H "X-PAYPAL-APPLICATION-ID: "  \ -d requestEnvelope.errorLanguage=en_US \ -d invoiceID=INV2-RVY9-UWTW-64HZ-BR9W" \ -d subject=Cancel+it \ -d noteForPayer=Cancel+it+now \ -d sendCopyToMerchant=true
```

## CancelInvoiceRequest Message [#cancelinvoicerequest-message]

Use the `CancelInvoiceRequest` message to cancel an invoice.

### RequestEnvelope Fields [#requestenvelope-fields]

| Field           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `detailLevel`   | `common:DetailLevelCode&#x60; &#x2A;(Optional)* Level of detail                 required by the client application pertaining to a particular data                 component. The detail level is specified as a detail level code, which                 has all the enumerated values of the detail level for the component. By                 default, the detail level code is `ReturnAll`, which provides                 the maximum level of detail. |
| `errorLanguage` | `xs:string&#x60; &#x2A;(Required)* RFC 3066 language in which                 error messages are returned; by default it is `en_US`, which                 is the only language currently supported.                                                                                                                                                                                                                                                         |

### CancelInvoiceRequest Fields [#cancelinvoicerequest-fields]

| Field                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `requestEnvelope`       | `common:requestEnvelope&#x60; &#x2A;(Required)* Information                 common to each API operation, such as the language in which an error                 message is returned.                                                                                                                                                                                                                                                                                                                                                                               |
| `invoiceID`             | `xs:string&#x60; &#x2A;(Optional)* ID of the invoice.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `subject`               | `xs:string&#x60; &#x2A;(Optional)* Subject of the cancelation                 notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `noteForPayer`          | `xs:string&#x60; &#x2A;(Optional)* Note to send payer within the                 cancelation notification.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `sendCopyToMerchant`    | `xs:boolean&#x60; &#x2A;(Optional)* Indicates whether to send a                 copy of the cancelation notification to the merchant. Also see the                 description of the `sendPayerNotification` field, below. The                 `sendCopyToMerchant` field can be one of the following                 values:<br />                 `false` — Do not send a copy of the cancelation                         notification to the merchant (default).`true` — Send a copy of the cancelation notification to                         the merchant.   |
| `sendPayerNotification` | `xs:boolean&#x60; &#x2A;(Optional)* Indicates whether a                 cancelation email is sent to the payer when the invoice is canceled. The                 `sendPayerNotification` field can contain one of the                 following values:<br />                 `true` — The payer is notified of the invoice cancelation                         (the default).`false` — The payer is not notified of the invoice                         cancelation. Additionally, the value specified in                         `sendCopyToMerchant` is ignored. |

## CancelInvoiceResponse Message [#cancelinvoiceresponse-message]

Use the `CancelInvoiceResponse` message to cancel an invoice.

### ResponseEnvelope Fields [#responseenvelope-fields]

| Field           | Description                                                                                                                                                                                                                                                                                                                                                                                                        |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ack`           | `common:AckCode` Acknowledgment code. Value is:<br />                 `Success` — The operation completed successfully.`Failure` — The operation failed.`SuccessWithWarning` — The operation completed                         successfully; however, there is a warning message.`FailureWithWarning ` — The operation failed with a                         warning message.                                      |
| `build`         | `xs:string` Build number. It is used only by PayPal Merchant                 Technical Support.                                                                                                                                                                                                                                                                                                                    |
| `correlationId` | `xs:string` Correlation identifier. It is a 13-character,                 alphanumeric string (for example, `db87c705a910e`) that is                 used only by PayPal Merchant Technical Support.                 &#x2A;*Note:** You must log and store this data for every                 response you receive. PayPal Technical Support uses the information to                 assist with reported issues. |
| `timestamp`     | `xs:datetime` Date on which the response was sent, for                 example: `2012-04-02T22:33:35.774-07:00`                 &#x2A;*Note:** You must log and store this data for every                 response you receive. PayPal Technical Support uses the information to                 assist with reported issues.                                                                                      |

### CancelInvoiceResponse Fields [#cancelinvoiceresponse-fields]

| Field              | Description                                                                                                                          |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `responseEnvelope` | `common:ResponseEnvelope` Common response information,                 including a timestamp and the response acknowledgment status. |
| `invoiceID`        | `xs:string` ID of the canceled invoice.                                                                                              |
| `invoiceNumber`    | `xs:string` Number of the canceled invoice.                                                                                          |
| `invoiceURL`       | `xs:string` URL location where merchants view the invoice                 details.                                                   |

## PPFault Message [#ppfault-message]

The `PPFaultMessage` returns `ErrorData` and the
`ResponseEnvelope` information to your application if an error
occurs.

### FaultMessage Fields [#faultmessage-fields]

| Field              | Description                                                                                                                          |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `error`            | `common:ErrorData` Detailed error information.                                                                                       |
| `responseEnvelope` | `common:ResponseEnvelope` Common response information,                 including a timestamp and the response acknowledgment status. |

### ErrorData Fields [#errordata-fields]

| Field         | Description                                                                                                                                                                                                                                                                                 |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `category`    | `common:ErrorCategory` The location where the error occurred.                 Value is:<br />                 `System` — The system encountered errors; try again`Application` — The application encountered errors; try                         again`Request` — The request was incorrect |
| `domain`      | `xs:string` The domain to which this service belongs.                                                                                                                                                                                                                                       |
| `errorId`     | `xs:long` A 6-digit number that uniquely identifies a                 particular error.                                                                                                                                                                                                     |
| `exceptionID` | This field is not used.                                                                                                                                                                                                                                                                     |
| `message`     | `xs:string` A description of the error.                                                                                                                                                                                                                                                     |
| `parameter`   | `common:ErrorParameter` Represents contextual information                 about the error.                                                                                                                                                                                                  |
| `severity`    | `common:ErrorSeverity` The severity of the error encountered.                 Value is:<br />                 `Error` — Processing of the request was interrupted`Warning` — Processing of the request was completed                                                                        |
| `subdomain`   | This field is not used.                                                                                                                                                                                                                                                                     |

### ResponseEnvelope Fields [#responseenvelope-fields-1]

| Field           | Description                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ack`           | `common:AckCode` Acknowledgment code. Value is:<br />                 `Success` — The operation completed successfully.`Failure` — The operation failed.`SuccessWithWarning` — The operation completed                         successfully; however, there is a warning message.`FailureWithWarning `— The operation failed with a                         warning message.                                                            |
| `build`         | `xs:string` Build number. It is used only by PayPal Merchant                 Technical Support.                                                                                                                                                                                                                                                                                                                                         |
| `correlationId` | `xs:string` Correlation identifier. It is a 13-character,                 alphanumeric string (for example, `db87c705a910e`) that is                 used only by PayPal Merchant Technical Support.                  > **Note:** &#x2A;*Note:** You must log and store this data for every                     response you receive. PayPal Technical Support uses the information to                     assist with reported issues. |
| `timestamp`     | `xs:datetime` Date on which the response was sent, for                 example: `2012-04-02T22:33:35.774-07:00`                  > **Note:** &#x2A;*Note:** You must log and store this data for every                     response you receive. PayPal Technical Support uses the information to                     assist with reported issues.                                                                                      |

## CancelInvoice API Errors [#cancelinvoice-api-errors]

| Code   | Message                                                                                                                                                                                       | Additional Information |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| 520002 | Internal error.                                                                                                                                                                               |                        |
| 520003 | Authentication failed. API credentials are incorrect.                                                                                                                                         |                        |
| 520009 | Account is restricted.                                                                                                                                                                        |                        |
| 550026 | Partner did not create the invoice but attempted to access or modify it;                 a merchant's invoice can be accessed or modified only by the partner who                 created it. |                        |
| 550027 | Merchant cannot access or modify an invoice they did not create; an                 invoice can only be accessed or modified by the party who created it.                                     |                        |
| 570058 | Authentication failed. User account is not confirmed.                                                                                                                                         |                        |
| 570061 | Invoice cannot be canceled since it has already been paid.                                                                                                                                    |                        |
| 570062 | The invoice has already been canceled.                                                                                                                                                        |                        |
| 570063 | A draft invoice cannot be canceled.                                                                                                                                                           |                        |
| 570099 | Invoice cannot be canceled since it has already been refunded.                                                                                                                                |                        |
| 571001 | The specified invoice ID is invalid because the invoice has already been                 deleted.                                                                                             |                        |
| 580022 | This error code corresponds to validation error messages that deal with                 errors of supplied parameters.                                                                        |                        |
| 580047 | Invoice does not exist.                                                                                                                                                                       |                        |
