# Cancel product assignment

POST `https://app.iteras.dk/api/customers/cancelproductassignment/`

The API key must allow "Change subscriber data".

Cancels a product assignment, optionally crediting an amount.

## Parameters

- `id` (string, required): ID of the customer.
- `product_assignment_id` (string, required): ID of the product assignment.

  Find it with the [customer data](/api/docs/server/retrievingcustomers.md) or [assign product](/api/docs/server/assignproduct.md) endpoint.
- `credit_amount` (integer, Defaults to `0`): Integer amount to credit while cancelling the product assignment, e.g. `"credit_amount": 1050` for €10.50. It cannot exceed the amount invoiced when the product was assigned.
- `exclude_from_webhooks` (bool, Defaults to `false`): Set to `true` to keep every event the request causes from being sent to webhooks, invoice and payment events included, e.g. `"exclude_from_webhooks": true`. The events are still added to the history.

## Examples

```http
POST /api/customers/cancelproductassignment/ HTTP/1.1
Content-Type: application/json
```

```json
{
  "id": "12345",
  "product_assignment_id": "9989892798",
  "credit_amount": 1050
}
```

## Return value

On success the endpoint returns the ID of the cancelled product assignment:

```json
{ "product_assignment_id": "9989892798" }
```

## Errors

Invalid requests due to programming error, e.g. invalid JSON, returns 400.

A well-formed operation where a supplied value is invalid is not executed and returns an HTTP 422 error. The response is a JSON object with the errors keyed by the field they concern, e.g. an invalid `credit_amount`:

```json
{
  "credit_amount": ["Amount too large."]
}
```

Errors that are not specific to a field are returned with the empty string as key, e.g. an unknown product assignment:

```json
{
  "": ["Product assignment does not exist."]
}
```