|
| 1 | +--- |
| 2 | +title: Get a Promotion Code Usage |
| 3 | +nav_label: Get a Promotion Code Usage |
| 4 | +sidebar_position: 7 |
| 5 | +--- |
| 6 | + |
| 7 | +## `GET` Get a Promotion Code Usage |
| 8 | + |
| 9 | +```http |
| 10 | +https://useast.api.elasticpath.com/v2/rule-promotions/:promotionID/codes/:code/usages |
| 11 | +``` |
| 12 | + |
| 13 | +This endpoint retrieves the usage history of a specific promotion code within a specific promotion, including details like `order_id`, `code`, and `times_used`. |
| 14 | + |
| 15 | +## Parameters |
| 16 | + |
| 17 | +### Path parameters |
| 18 | + |
| 19 | +| Name | Required | Type | Description | |
| 20 | +|:-----|:---------|:---------|:---------------------------------| |
| 21 | +| `promotionID` | Required | `string` | The unique identifier for the rule promotion. | |
| 22 | +| `code` | Required | `string` | Specifies the name of the code. For example, `10OFF`. | |
| 23 | + |
| 24 | +### Headers |
| 25 | + |
| 26 | +| Name | Required | Type | Description | |
| 27 | +|:----------------|:---------|:---------|:-------------------------------------| |
| 28 | +| `Authorization` | Required | `string` | The Bearer token required to get access to the API. | |
| 29 | + |
| 30 | +### Query parameters |
| 31 | + |
| 32 | +| Name | Required | Type | Description | |
| 33 | +| ---- | -------- | -------- | -------------------------------- | |
| 34 | +| `filter` | Optional | `string` | Filter attributes. For more information, see [Filtering](/docs/promotions-builder/promotions-builder-codes/get-promotion-usages#filtering). | |
| 35 | +| `page[limit]` | Optional | `integer` | The number of records per page. | |
| 36 | +| `page[offset]` | Optional | `integer` | The number of records to offset the results by. | |
| 37 | +| `sort` | Optional | `string` | Supported attribute is `used_on`. When specified, the results are sorted in an ascending order. To sort in descending order, prefix the attribute with -, for example, `-used_on`. See [Sorting](/guides/Getting-Started/sorting). | |
| 38 | + |
| 39 | +## Filtering |
| 40 | + |
| 41 | +The following operators and attributes are available for filtering usages: |
| 42 | + |
| 43 | +| Attribute | Type | Operators | Example | |
| 44 | +| ---------| --------- | ---------------------------| -------- | |
| 45 | +| `id` | `string` | `eq` | `eq(id,8dac76b3-9282-4730-b1dd-bdd2a95610cb)` | |
| 46 | +| `code` | `string` | `eq` | `eq(code,cart1off)` | |
| 47 | +| `used_on` | `string` | `gt`,`ge`,`le` and `lt` | `gt(used_on,2023-07-11)` | |
| 48 | + |
| 49 | +## Request Example |
| 50 | + |
| 51 | +```bash |
| 52 | +curl https://useast.api.elasticpath.com/v2/rule-promotions/:promotionID/codes/:code/usages \ |
| 53 | + -H "Authorization: Bearer XXXX" \ |
| 54 | + -H "Content-Type: application/json" \ |
| 55 | +``` |
| 56 | + |
| 57 | +## Response Example |
| 58 | + |
| 59 | +When a cart with a promotion is checked out using an `accountID`, the `accountID` will be included in the response. |
| 60 | + |
| 61 | +`200 OK` |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "data": [ |
| 66 | + { |
| 67 | + "id": "96a80700-4895-4d74-b96f-3ea39417ed29", |
| 68 | + "order_id": "5728c924-cd08-4b4a-a36a-1a926ee92ad3", |
| 69 | + "code_id": "fd23fcc6-e2cc-4900-9505-d38147c3019a", |
| 70 | + "code": "bxgy", |
| 71 | + "times_used": 1, |
| 72 | + "used_on": "2024-08-15T18:25:41.209Z", |
| 73 | + "customer_email": "[email protected]", |
| 74 | + "meta": { |
| 75 | + "timestamps": { |
| 76 | + "updated_at": "2024-08-15T18:25:41.209Z" |
| 77 | + } |
| 78 | + }, |
| 79 | + "anonymized": false, |
| 80 | + "account_id": "c40ee30c-f5f9-4a40-8f3f-08f7c652b0c5" |
| 81 | + } |
| 82 | + ], |
| 83 | + "links": { |
| 84 | + "current": "https://useast.api.elasticpath.com/v2/rule-promotions/26067b82-a50c-462c-b3ed-1ca77aa13bd1/usages?page[offset]=0&page[limit]=10", |
| 85 | + "first": "https://useast.api.elasticpath.com/v2/rule-promotions/26067b82-a50c-462c-b3ed-1ca77aa13bd1/usages?page[offset]=0&page[limit]=10", |
| 86 | + "last": "https://useast.api.elasticpath.com/v2/rule-promotions/26067b82-a50c-462c-b3ed-1ca77aa13bd1/usages?page[offset]=0&page[limit]=10", |
| 87 | + "prev": "https://useast.api.elasticpath.com/v2/rule-promotions/26067b82-a50c-462c-b3ed-1ca77aa13bd1/usages?page[offset]=0&page[limit]=10", |
| 88 | + "next": "https://useast.api.elasticpath.com/v2/rule-promotions/26067b82-a50c-462c-b3ed-1ca77aa13bd1/usages?page[offset]=0&page[limit]=10" |
| 89 | + }, |
| 90 | + "meta": { |
| 91 | + "page": { |
| 92 | + "limit": 10, |
| 93 | + "offset": 0, |
| 94 | + "current": 1, |
| 95 | + "total": 1 |
| 96 | + }, |
| 97 | + "results": { |
| 98 | + "total": 1 |
| 99 | + } |
| 100 | + } |
| 101 | +} |
| 102 | +``` |
0 commit comments