> For the complete documentation index, see [llms.txt](https://help.openloyalty.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.openloyalty.io/api-reference/reward/buy-a-reward.md).

# Buy a reward

Management\
\
This method allows buying a specific Reward by Member.\
With error 'No coupons left' returned when reward cannot be bought because of lack of coupons. With error 'Not enough points' returned when reward cannot be bought because of not enough points on customer account. With empty error returned when reward limits exceeded. An optional `shippingAddress` ships this redemption to an address other than the member's profile address. It is stored on the issued reward only and shown in the redemption details; the member's profile is not changed. Without it, the issued reward keeps the member's profile address. For a fortune wheel the address is stored on the issued fortune wheel only; the reward won with `/draw` keeps the member's profile address. A member buying a reward that is not visible to them gets 404.

````json
{"openapi":"3.0.0","info":{"title":"Open Loyalty","version":"0.0.1"},"tags":[{"name":"Reward","description":"These endpoints allow you to easily manage rewards."}],"servers":[{"url":"http://openloyalty.localhost"}],"security":[{"Bearer":[]},{"token":[]}],"components":{"securitySchemes":{"Bearer":{"type":"http","description":"Open Loyalty has the JWT authorization.\nTo learn what a JSON Web Token is and how it works, check out Introduction to JSON Web Tokens <https://jwt.io/introduction/>\n\n### Obtain an access token\n\nSend a request with the parameters username and password\n\n#### Definition\n\n`POST /api/admin/login_check` [Go to definition](#operation/adminLoginCheck)\\\n`POST /api/{storeCode}/member/login_check` [Go to definition](#operation/memberLoginCheck)\n\n#### Example\n\n```bash\ncurl {HOST}/api/admin/login_check\n    -H 'Content-Type: application/json;charset=UTF-8'\n    -H 'Accept: application/json, text/plain, */*'\n    --data-binary '{\"username\":\"admin\",\"password\":\"password\"}'\n```\n\n#### Example Response\n\n```json\n{\n    \"token\":\"eyJhbGciOiJSUzI1NiIsInR5cCI6...\",\n    \"refresh_token\":\"0558f8bb29948c4e54c443f...\"\n}\n```\n\n### Using JSON Web Token\n\nAdd authorization header to each request\\\n`Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...`\\\nYou can now access any API method you want under the /api prefix.\n\n#### Example\n```bash\ncurl {HOST}/api/{storeCode}/analytics/members\n    -H 'Accept: application/json'\n    -H 'Content-type: application/x-www-form-urlencoded'\n    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...'\n```\n\n### Refresh JSON Web Token\nYou can refresh token using refresh_token that was given during login.\\\nThere are two endpoints\\\nTo refresh admin token `POST /api/token/refresh` [Go to definition](#operation/tokenRefresh)\\\nTo refresh member token `POST /api/{storeCode}/token/refresh` [Go to definition](#operation/tokenRefreshMember)\n","bearerFormat":"JWT","scheme":"bearer"},"token":{"type":"apiKey","name":"X-AUTH-TOKEN","in":"header"}},"parameters":{"storeCode":{"name":"storeCode","in":"path","description":"Store code","required":true,"schema":{"type":"string"}},"reward":{"name":"reward","in":"path","description":"Reward ID","required":true,"schema":{"type":"string","format":"uuid"}}},"schemas":{"StaticCoupon":{"required":["customerId","quantity","withoutPoints"],"properties":{"customerId":{"type":"string","format":"uuid"},"quantity":{"type":"integer"},"couponValue":{"type":"number","format":"float"},"dateValid":{"type":"string","format":"date-time"},"withoutPoints":{"type":"boolean"},"rewardWalletCode":{"type":"string"},"shippingAddress":{"$ref":"#/components/schemas/ShippingAddress"}},"type":"object"},"ShippingAddress":{"description":"Optional shipping address of this redemption. When given, it is stored on the issued reward in place of the member's profile address; the member's profile is not changed. When omitted, or when no field is filled in, the issued reward keeps the member's profile address. A given address replaces the profile address as a whole: fields left out stay empty. For a fortune wheel it is stored on the issued fortune wheel only; the reward won with `/draw` keeps the member's profile address.\n","properties":{"street":{"type":"string","maxLength":255},"address1":{"type":"string","maxLength":255},"address2":{"type":"string","maxLength":255},"province":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":255},"postal":{"type":"string","maxLength":32},"country":{"description":"ISO 3166-1 alpha-2 country code.","type":"string","maxLength":255}},"type":"object"},"DynamicCoupon":{"required":["customerId","quantity","couponValue","withoutPoints"],"properties":{"customerId":{"type":"string","format":"uuid"},"quantity":{"type":"integer"},"couponValue":{"type":"number","format":"float"},"dateValid":{"type":"string","format":"date-time"},"withoutPoints":{"type":"boolean"},"rewardWalletCode":{"type":"string"},"shippingAddress":{"$ref":"#/components/schemas/ShippingAddress"}},"type":"object"},"ConversionCoupon":{"required":["customerId"],"properties":{"customerId":{"type":"string","format":"uuid"},"dateValid":{"type":"string","format":"date-time"},"units":{"type":"number","format":"float"},"shippingAddress":{"$ref":"#/components/schemas/ShippingAddress"}},"type":"object"},"MaterialReward":{"required":["customerId","quantity","withoutPoints"],"properties":{"customerId":{"type":"string","format":"uuid"},"quantity":{"type":"integer"},"withoutPoints":{"type":"boolean"},"rewardWalletCode":{"type":"string"},"shippingAddress":{"$ref":"#/components/schemas/ShippingAddress"}},"type":"object"},"FortuneWheelReward":{"description":"Buys a fortune wheel. A `shippingAddress` is stored on the issued fortune wheel only; the reward later won with `/draw` is issued with the member's profile address.\n","required":["customerId","quantity","withoutPoints"],"properties":{"customerId":{"type":"string","format":"uuid"},"quantity":{"type":"integer"},"withoutPoints":{"type":"boolean"},"rewardWalletCode":{"type":"string"},"shippingAddress":{"$ref":"#/components/schemas/ShippingAddress"}},"type":"object"}},"responses":{"BadRequest":{"description":"Bad request.","content":{"application/json":{"schema":{"required":["code","message","errors"],"properties":{"code":{"type":"integer"},"message":{"type":"string"},"errors":{"type":"array","items":{"required":["message","parameters","plural","code","path"],"properties":{"message":{"type":"string"},"parameters":{},"plural":{"type":"integer","nullable":true},"code":{"type":"string"},"path":{"type":"string"}},"type":"object"}}},"type":"object"}}}},"Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"AccessDenied":{"description":"Forbidden.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"NotFound":{"description":"Not found.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"ConcurrencyLockTimeout":{"description":"Service Unavailable — a concurrency lock protecting this operation could not be acquired in time. The request lost a race with a concurrent request for the same resource (for example the same member) and was rolled back without any side effects. Nothing about the submitted payload is wrong: the request may be retried, ideally after a short backoff. The response body deliberately carries only the generic status text — the internal lock key is never exposed.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}}}},"paths":{"/api/{storeCode}/reward/{reward}/buy":{"post":{"tags":["Reward"],"summary":"Buy a reward","description":"<label style=\"background-color: #D4EDBC;padding:5px;\">Management</label><br><br>\nThis method allows buying a specific Reward by Member.<br>\nWith error 'No coupons left' returned when reward cannot be bought because of lack of coupons.\nWith error 'Not enough points' returned when reward cannot be bought because of not enough points on customer account. With empty error returned when reward limits exceeded.\nAn optional `shippingAddress` ships this redemption to an address other than the member's profile address. It is stored on the issued reward only and shown in the redemption details; the member's profile is not changed. Without it, the issued reward keeps the member's profile address. For a fortune wheel the address is stored on the issued fortune wheel only; the reward won with `/draw` keeps the member's profile address.\nA member buying a reward that is not visible to them gets 404.\n","operationId":"rewardPostBuy","parameters":[{"$ref":"#/components/parameters/storeCode"},{"$ref":"#/components/parameters/reward"}],"requestBody":{"description":"","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/StaticCoupon"},{"$ref":"#/components/schemas/DynamicCoupon"},{"$ref":"#/components/schemas/ConversionCoupon"},{"$ref":"#/components/schemas/MaterialReward"},{"$ref":"#/components/schemas/FortuneWheelReward"}]}}}},"responses":{"200":{"description":"Return created reward ID.","content":{"application/json":{"schema":{"type":"array","items":{"properties":{"issuedRewardId":{"description":"Created reward identity","type":"string"}},"type":"object"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/AccessDenied"},"404":{"$ref":"#/components/responses/NotFound"},"503":{"$ref":"#/components/responses/ConcurrencyLockTimeout"}}}}}}
````


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.openloyalty.io/api-reference/reward/buy-a-reward.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
