This page covers API endpoints that allow merchants to retrieve and modify user credits.
Internally, credits are stored with a long list of attached data-values used for internal operations. For the purposes of this documentation, credit
entries are represented with the following structure:
GET
https://public.inveterateapi.com/customers/credits
This endpoint will pull all credit history for a given user. For batch operations, each customerId
should be its own API call. Ensure that query parameter customerId
is included after the endpoint path, in the form of:
.../customers/credits?customerId=1234567890
In the case of a success, you will see a return that looks like the following:
NOTE: Please keep in mind that the response is exactly as it appears in the credit ledger. This means that all credits, even expired credits, will appear in the response. If you are using the Expiring Credits benefit and you want to calculate an accurate balance for a customer, ensure that you check the returned entries for expired entries and deduct those values.
In the case of a missing customerId
parameter, you will receive the following:
In the case of a missing or invalid X-Inveterate-Api-Key
, you will receive the following:
POST
https://public.inveterateapi.com/customers/credits
This endpoint will create a ledger entry for a given customerId
, enabling you to add credits to a customer. For batch operations, each customerId
should be its own API call. Ensure that the query parameters, customerId
and credit
, are included in the path in the form:
.../customers/credits?customerId=1234567890&credit=5
Please note that 200 does not guarantee that the request was actually successful. It means that our back-end successfully received the request and it is being processed. The only place where this could serve to be an issue is the case that you enter an incorrect customerId
.
If you are manually inputting all customerId
values for batch calls, you can ensure that the call was successful by performing a GET
call and confirming the createdAt
date. Please keep in mind that there may be a few-second delay before the credits are fully processed and added in our back-end.
You will receive a number of different errors, similar to the ones in the GET
endpoint (please review those two errors for reference), if you don't include the two query parameters or if your X-Inveterate-Api-Key
is invalid.
POST
https://public.inveterateapi.com/redemption-discount-code
Create a request to redeem credits as a discount code that can be used by a customer. All data should be passed through the request body (see parameters).
On failure, you will receive a code 400. There are a few reasons this may be. Primarily, an incomplete body in the request.
On success, you will receive a response code 200 and the response body will contain the discount code generated by our back-end.
Referencing an inexistent customerId
or the referenced customer having insufficient funds are the two main reasons for failures.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
customerId*
Number
The customer ID which you intend to pull the data of.
X-Inveterate-Api-Key*
String
Required to access all protected endpoints on this API. Obtained from merchant's Inveterate dashboard.
customerId*
Number
The ID which identifies the customer you intend to add credits to.
credit*
Number
The credit amount you intend to add to the customer.
X-Inveterate-Api-Key
String
Required to access all protected endpoints on this API. Obtained from merchant's Inveterate dashboard.
customerId*
number
The customer ID for which you intend to create a redemption request for.
amount*
number
The amount of credits you would like to redeem to this discount code.
string
The email for the customer. This may not be required. If a request fails, attempt the request with the customers email.
merchantId*
string
The merchant ID for the store.