---
id: post
title: "Add store credit"
sidebar_label: Add store credit
hide_title: true
unlisted: true
description: "Management API - Store Credit - Add store credit"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
import Ingress from "../../../src/components/ingress/ingress.react";
import Idempotency from "../idempotency.mdx";

<Ingress title="Add store credit">
  Use this endpoint to add store credit to a customer's account. Store credit can be used for loyalty rewards, compensation, trade-ins, or other scenarios where the customer should receive credit to use on future purchases.

  The transaction will be deducted from the next settlement.
</Ingress>

:::info The customer needs an active credit reservation
Store credit only reaches a customer who has an **active credit reservation** with Walley. Without
one, the request is rejected.
:::

## Example

<Tabs defaultValue="req" values={[
{ label: 'Request', value: 'req', },
{ label: 'Response', value: 'res', }
]}>

<TabItem value="req">

```http
POST /manage/storecredits HTTP/1.1
Host: api.uat.walleydev.com // Test environment. Production uses a different hostname.
Content-Type: application/json
Authorization: Bearer {{accessToken}}
Walley-Idempotency: 03304b06-cb33-4f78-bcea-86cb4b202ba0

{
  "amount": 150.00,
  "actionReference": "loyalty-reward-2024-001",
  "description": "Loyalty reward",
  "storeId": 12345,
  "integrationId": "customer-abc-123"
}
```

</TabItem>

<TabItem value="res">

```http
HTTP/1.1 202 Accepted

/* No body */
```

</TabItem>
</Tabs>

## Data Model

### Request

#### Request headers

| Header            | Required | Explanation                                                                                                             |
| ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Authorization** | Yes      | See [Authentication](/docs/manage/getting-started/authentication) for how to generate the Bearer token value            |

#### Request body

| Property            | Required | Explanation                                                                                                              | Type   | Notes                                                                    |
| ------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------- |
| **amount**          | Yes      | The store credit amount to add to the customer's account                                                                 | number | Decimal                                                                  |
| **actionReference** | Yes      | A unique reference for this action, used for tracking and auditing                                                       | string | Displayed in the settlement file                                         |
| **description**     | Yes      | A description of the store credit, such as "Loyalty reward", "Phone trade-in", or "Goodwill compensation"                | string | Displayed on future invoices and in the My Walley app                    |
| **storeId**         | Yes      | The store the store credit is associated with                                                                            | number | Integers only                                                            |
| **integrationId**   | Yes      | The merchant's identifier for the customer (integration ID)                                                              | string |                                                                          |

### Response

Adding store credit answers `202 Accepted` with an empty body. `202` means Walley accepted the
request, not that it has been applied. See
[Asynchronous operations](/docs/manage/concepts/asynchronous-operations) for what that means.

#### Error responses

| Http status code  | Code                             | Description                                                        |
| ----------------- | -------------------------------- | -------------------------------------------------------------------- |
| `400 Bad Request` | `RESERVATION_NOT_ACTIVE`         | The customer does not have an active credit reservation            |
| `400 Bad Request` | `REQUEST_INVALID`                | The request body failed validation                                 |
| `404 Not Found`   |                                  | No customer found for the given `integrationId` and `storeId`      |
| `409 Conflict`    | `STORECREDIT_ALREADY_IN_PROCESS` | A request with the same idempotency key is already being processed |

See [Errors](/docs/manage/errors) for what to do about each of these.

<Idempotency />
