> For the complete documentation index, see [llms.txt](https://docs.premsoft.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.premsoft.de/en/plugins/bonus-system/admin-api/updating-customer-points-with-api.md).

# Updating customer points with API

We are providing the API for updating customer points.\
Following, you can find a postman collection with all the necessary data.\
The postman collection contains these variables:

```
SHOPWARE_DOMAIN - The domain of the shopware project, without the http/https protocol.
SW_ACCESS_KEY - The shopware access key. (It's defined in the shopware integration)
SW_SECRET_ACCESS_KEY - The shopware secret key. (It's defined in the shopware integration)
ACCESS_TOKEN - The bearer token. (It's filled automatically by running the "1. Obtain API access token" post from the collection)
```

The test process using a postman:

Create a JSON file with the collection code posted bellow.\
1\. Import a collection. (a JSON format file)\
2\. Fill the collection variables.\
3\. Run the "1. Obtain API access token" post to fill the required ACCESS\_TOKEN variable.\
4\. Run other posts from the collection. (Update bonus points by customer ID or number)

```
{
	"info": {
		"_postman_id": "55d7c3c5-bd28-44ad-bb5a-093a40ccd426",
		"name": "PremsBonusSystem: Update bonus points",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "5184947"
	},
	"item": [
		{
			"name": "1. Obtain API access token",
			"event": [
				{
					"listen": "test",
					"script": {
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"pm.collectionVariables.set(\"ACCESS_TOKEN\", jsonData.access_token);"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"grant_type\": \"client_credentials\",\n  \"client_id\": \"{{SW_ACCESS_KEY}}\",\n  \"client_secret\": \"{{SW_SECRET_ACCESS_KEY}}\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/oauth/token",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"oauth",
						"token"
					]
				}
			},
			"response": []
		},
		{
			"name": "Update bonus points by customer number",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{ACCESS_TOKEN}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"customerNumber\": \"10382\",      // Customer number\n    \"description\": \"Test points\",   // Description for added/removed bonus points\n    \"points\": 5,                    // Amount of points, can be positive or negative\n    \"salesChannelId\": \"\"            // Optional: If it's not defined, it's obtained from the customer\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/v2/prems-bonus-system/create-bonus-booking",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"v2",
						"prems-bonus-system",
						"create-bonus-booking"
					]
				}
			},
			"response": []
		},
		{
			"name": "Update bonus points by customer ID",
			"request": {
				"auth": {
					"type": "bearer",
					"bearer": [
						{
							"key": "token",
							"value": "{{ACCESS_TOKEN}}",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"customerId\": \"019685763d44731cb4ac5938f107993e\",   // Customer ID\n    \"description\": \"Test points\",                       // Description for added/removed bonus points\n    \"points\": 5,                                        // Amount of points, can be positive or negative\n    \"salesChannelId\": \"\"                                // Optional: If it's not defined, it's obtained from the customer\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "https://{{SHOPWARE_DOMAIN}}/api/_action/prems/create-bonus-booking-by-customer-id",
					"protocol": "https",
					"host": [
						"{{SHOPWARE_DOMAIN}}"
					],
					"path": [
						"api",
						"_action",
						"prems",
						"create-bonus-booking-by-customer-id"
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"packages": {},
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "SHOPWARE_DOMAIN",
			"value": "domain.dev",
			"type": "string"
		},
		{
			"key": "SW_ACCESS_KEY",
			"value": "xxx",
			"type": "string"
		},
		{
			"key": "SW_SECRET_ACCESS_KEY",
			"value": "xxx",
			"type": "string"
		},
		{
			"key": "ACCESS_TOKEN",
			"value": "",
			"type": "string"
		}
	]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.premsoft.de/en/plugins/bonus-system/admin-api/updating-customer-points-with-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
