|
| 1 | +--- |
| 2 | +title: Gift Cards |
| 3 | +nav_order: 12 |
| 4 | +--- |
| 5 | + |
| 6 | +## Attributes |
| 7 | + |
| 8 | +<table> |
| 9 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 10 | + <tr><td>id</td><td>Integer</td><td>Automatically set</td></tr> |
| 11 | + <tr><td>created_at</td><td>Datetime</td><td>Automatically set</td></tr> |
| 12 | + <tr><td>updated_at</td><td>Datetime</td><td>Automatically set</td></tr> |
| 13 | + <tr><td>code</td><td>String</td><td>Unique per account. Max 50 characters. Automatically generated if not specified. Format: XXXX-9999-XXXX</td></tr> |
| 14 | + <tr><td>value</td><td>Integer</td><td>Required. Current remaining value. Must be greater than 0 and less than or equal to 10000</td></tr> |
| 15 | + <tr><td>initial_value</td><td>Integer</td><td>Original value when created</td></tr> |
| 16 | + <tr><td>active</td><td>Boolean</td><td>Default: true</td></tr> |
| 17 | + <tr><td>valid_until</td><td>Date</td><td>Expiry date. Gift card is not redeemable after this date</td></tr> |
| 18 | + <tr><td>person_id</td><td>Integer</td><td>Owner of the gift card</td></tr> |
| 19 | + <tr><td>purchased_by_person_id</td><td>Integer</td><td>Person who purchased the gift card</td></tr> |
| 20 | + <tr><td>custom_data</td><td>Object</td><td>Key/value. Stored as strings</td></tr> |
| 21 | +</table> |
| 22 | + |
| 23 | +## Listing |
| 24 | + |
| 25 | +`GET /gift_cards` will return all active gift cards. |
| 26 | + |
| 27 | +Response |
| 28 | + |
| 29 | +```json |
| 30 | +[ |
| 31 | + { |
| 32 | + "gift_card": { |
| 33 | + "id": 1, |
| 34 | + "code": "ABCD-2345-EFGH", |
| 35 | + "initial_value": 500, |
| 36 | + "value": 500, |
| 37 | + "valid_until": null, |
| 38 | + "active": true, |
| 39 | + "custom_data": null, |
| 40 | + "created_at": "2026-03-26T10:00:00+02:00", |
| 41 | + "updated_at": "2026-03-26T10:00:00+02:00" |
| 42 | + } |
| 43 | + } |
| 44 | +] |
| 45 | +``` |
| 46 | + |
| 47 | +### Query Parameters |
| 48 | + |
| 49 | +<table> |
| 50 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 51 | + <tr><td>person_id</td><td>Integer</td><td>Filter by person</td></tr> |
| 52 | +</table> |
| 53 | + |
| 54 | +## Get gift card |
| 55 | + |
| 56 | +`GET /gift_cards/{gift_card_id}` will get a gift card with id `{gift_card_id}`. |
| 57 | + |
| 58 | +## Add new gift card |
| 59 | + |
| 60 | +`POST /gift_cards` will create a new gift card. |
| 61 | + |
| 62 | +<table> |
| 63 | + <tr><th>Name</th><th>Type</th><th>Description</th></tr> |
| 64 | + <tr><td>code</td><td>String</td><td>Not required. Auto-generated if not specified</td></tr> |
| 65 | + <tr><td>value</td><td>Integer</td><td>Required</td></tr> |
| 66 | + <tr><td>initial_value</td><td>Integer</td><td>Not required</td></tr> |
| 67 | + <tr><td>active</td><td>Boolean</td><td>Not required</td></tr> |
| 68 | + <tr><td>valid_until</td><td>Date</td><td>Not required</td></tr> |
| 69 | + <tr><td>person_id</td><td>Integer</td><td>Not required</td></tr> |
| 70 | + <tr><td>custom_data</td><td>Object</td><td>Not required</td></tr> |
| 71 | +</table> |
| 72 | + |
| 73 | +## Update gift card |
| 74 | + |
| 75 | +`PUT /gift_cards/{gift_card_id}` will update existing gift card with id `{gift_card_id}`. |
| 76 | + |
| 77 | +## Delete gift card |
| 78 | + |
| 79 | +`DELETE /gift_cards/{gift_card_id}` will delete existing gift card with id `{gift_card_id}`. |
0 commit comments