# Receipt Notification Webhook 

### for receipt-issued-events

The `receipt-issued-events` CSP (Consumer Service Partner) Webhook is designed to alert partners when receipts are successfully added to the anybill system for a designated user. <br> 

> **Tip: User Registration and Receipt Endpoints**
>
> To register an anybill user use the [user endpoints](api_v3.md#user-endpoints). <br>
> To query and display receipts in your frontend application use the [receipt endpoints](api_v3.md#receipt-endpoints) or the anybill SDKs.
>

After adding a receipt, anybill sends the receipt information to the endpoint URL you provide.
For further information, please contact us via our **Email contact**.

### Authentication

For authentication, we use the **X-API-KEY** header. Please provide us with your API key.

### Webhook Request Structure

#### Headers

| Header Name    | Value                  |
|----------------|------------------------|
| `Content-Type` | `application/json`     |
| `User-Agent`   | `anybill`              |
| `keep-alive`   | `timeout=60, max=3600` |
| `X-API-KEY`    | `<your-key>`           |

The endpoint will provide you the following properties a JSON formatted payload. \
All property names are a **camelCased**, **ASCII** encoded strings.

### Properties

| Property Name   | Type          | Description                                                                                                       | 
|-----------------|---------------|-------------------------------------------------------------------------------------------------------------------|
| `receiptId`     | String        | A GUID representing an identifier for the receipt. This ID can be used for further interactions with the receipt. |
| `receiptNr`     | String        | Identifier of the receipt issued by the POS that created the receipt. |
| `storeId`       | String        | A GUID representing an identifier for the store in the anybill system for which the receipt was issued.           |
|`externalStoreId`| String        | The external store id of the store where the receipt was issued           |
| `externalId`    | String        | Identifies the user in your system.                                                                               | 
| `vendorName`    | String        | The name of the vendor who issued the receipt.                                                                    | 
| `amount`        | Decimal       | The total amount of the receipt, including VAT.                                                                   | 
| `date`        | DateTimeOffset      | The date and time when the receipt was issued                                                                   | 
| `vendorAddress` | Object        | The address object corresponding to the store that issued the receipt. (defined below)  <br/>                     |
| `lines`         | Array[Object] | An array of line objects (defined below)                                                                          |

#### VendorAddress
| Property Name   | Type    | Description                                                                                                              | 
|-----------------|---------|--------------------------------------------------------------------------------------------------------------------------|
| `street`        | String  | The street name and number of the vendor's location.                                                                     |
| `postalCode`    | String  | The postal code of the vendor's location.                                                                                |
| `city`          | String  | The city where the vendor's store is located.                                                                            | 
| `countryCode`   | String  | The country code (ISO 3166-1 alpha-3 format) corresponding to the vendor's location.                                                    |

#### Lines
| Property Name    | Type            | Description                                                                                  |
|------------------|-----------------|----------------------------------------------------------------------------------------------|
| `amount`           | decimal         | The total amount including VAT for the product group purchased.                              |
| `name`             | string          | The product's name as it appears on the receipt, maintaining the original formatting.        |
| `number`           | string          | The SKU (Stock Keeping Unit) number identifying the product.                                 |
| `qty`         | decimal         | The quantity of the product purchased |
| `quantityMeasure`  | QuantityMeasure | A nullable enum or class indicating the unit of measure for the quantity (e.g., liters, kg). |
| `pricePerUnit`     | decimal         | The price per unit of the product, allowing calculation of total cost based on quantity.     |

> **Warning**
> The string parameter "quantity" in the Line object was deprecated and replaced with the decimal parameter "qty"

####
The `QuantityMeasure` is an enum with the following values:
Count,
Kilogram,
Lbs,
Meters,
Inches,
Liter,
CubicMeters,
SquareMeters,
KilowattHour,
Seconds

#### Example

```json
{
  "receiptId": "123e4567-e89b-12d3-a456-426614174000",
  "receiptNr": "32048",
  "storeId": "123e4567-e89b-12d3-a456-426614174000",
  "externalStoreId": "23123",
  "externalId": "user_001",
  "date": "2024-07-07T16:18:43+02:00",
  "vendorName": "Examplemarket XYZ",
  "amount": 95.27,
  "vendorAddress": {
    "street": "123 Example Street",
    "postalCode": "12345",
    "city": "Example City",
    "countryCode": "DEU"
  },
  "lines": [
    {
      "amount": 50.00,
      "name": "Organic Milk 1L",
      "number": "SKU123456",
      "qty": 2.0,
      "quantityMeasure": "Count",
      "pricePerUnit": 25.00
    },
    {
      "amount": 45.27,
      "name": "Whole Wheat Bread",
      "number": "SKU654321",
      "qty": 3.0,
      "quantityMeasure": "Count",
      "pricePerUnit": 15.09
    }
  ]
}
```
