Introduction
Welcome to the Merit API! You can use our API to access Merit Giftcard platform.
This API has been created for partners to connect to the Gift Card Platform to create gift cards and send it to customers
- Current version of the API is V3 and the endpoints will be prefixed by v3/.
Authentication
Merit uses token based authentication. API keys to allow access to the API.
The client needs to send HTTP requests with the Authorization header that contains the word ‘Bearer’ followed by a space and the Key Secret.
Merit expects for the API key to be included in all API requests to the server in a header that looks like the following:
Authorization: Bearer secret_token
To authorize, use this code:
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here" \
-H "Authorization: Bearer secret_key"
Make sure to replace
secret_key
with your API key.
Base URL
Base URL for Merit API endpoints
Description | URL |
---|---|
Staging | https://testapi.meritincentives.com/api/v3 |
Host | https://testapi.meritincentives.com/ |
Content-Type | application/json |
Authorization | Bearer secret_token |
Giftcard Fulfillment
Single Order Async
curl --location --request POST 'https://testapi.meritincentives.com/api/v3/giftcard/orders/async' \
--header 'Authorization: Bearer secret_key' \
--header 'Content-Type: application/json' \
--header 'idempotency-key: b8e0183f-51a8-49cc-96be-189fc9a4a4ee' \
--data-raw '{
"quantity": 1,
"denomination": 10,
"product_id": "product_c92jlkj234h4b3kb8c3d",
"reference_id": "referenceId123",
"recipient": {
"first_name": "A",
"last_name": "B",
"email": "example@example.com",
"lang":"fr"
},
"send_email": false
}'
The above command returns JSON structured like this:
{
"id": "f6ecc851-3aef-4a74-b03a-83fd6e22c8bc",
"status": "PROCESSING"
}
This request is for creating gift cards for a particular brand. The corresponding product_id
for the brand needs to be known. This will be provided by Merit.
Once an order has been successfully placed using the "Single Order Async" API, you can use the "Get Order Details" API to get the order status.
HTTP request
POST https://testapi.meritincentives.com/api/v3/giftcard/orders/async
Query Parameters
Parameter | Required | Description |
---|---|---|
quantity | Yes | Integer (max of 10 quantity is allowed and min of 1) |
denomination | Yes | Float |
product_id | Yes | String |
reference_id | Yes | String (Must be case sensitive, Maximum length of 128, Allowed characters are A-Z, a-z, 0-9, :, -, @) |
recipient | No | Json Object (Recipient) |
send_email | No | Boolean , default : false (if send email is true, recipient.email is required and an email will be sent to the recipient) Note: ** Do not use this flag if you don't intend Merit to send an email to the recipient** |
Single Order Async Response
Parameter | Type | Description |
---|---|---|
id | UUID | Unique order id |
status | String | Order status |
Get Order Details
This request is for getting order status and gift card details. To request this endpoint you will need to provide an order_id
parameter which you can obtain in the response to the Single Order Async API
.
An exponential backoff strategy is recommended for getting the order details. Typically, an order completes within 2 minutes. In rare occurences, if an order remains in processing status after 30 minutes, please contact our support team for assistance.
Please note that the only way to determine in advance how a particular gift card product fulfills—whether by link, code, link and pin, or code and pin—is by inspecting the order details. To avoid this complexity, we recommend using gift card links (Giftcard.url), as this field will always be present.
HTTP request
GET https://testapi.meritincentives.com/api/v3/giftcard/orders/{{order_id}}
curl --location --request GET 'https://testapi.meritincentives.com/api/v3/giftcard/orders/f6ecc851-3aef-4a74-b03a-83fd6e22c8bc' \
--header 'Authorization: Bearer secret_key' \
--header 'idempotency-key: b8e0183f-51a8-49cc-96be-189fc9a4a4ee' \
The above command returns JSON structured like this:
{
"status": "COMPLETED",
"total_count": 1,
"success_count": 1,
"failed_count": 0,
"id": "f6ecc851-3aef-4a74-b03a-83fd6e22c8bc",
"reference_id": "referenceId123",
"items": [
{
"status": "COMPLETED",
"product_id": "product_c92jlkj234h4b3kb8c3d",
"currency_code": "AED",
"denomination": 10,
"giftcard": {
"number": "giftcard_number",
"card_id": "20230208-12345678",
"original_value": "10.0",
"remaining_value": "10.0",
"expiration_date": "2024-02-08",
"url": "https://giftcardpreviewlink",
"pin": null
},
"recipient": {
"email": "example@example.com",
"last_name": "B",
"first_name": "A",
"lang":"fr"
},
"send_email": false,
"created_at": "2023-02-08T10:14:42.000Z"
}
],
"created_at": "2023-02-08T10:14:42.000Z",
"total_pages": 1,
"current_page": 1
}
Get Order Response
Parameter | Type | Description |
---|---|---|
status | String | Order status |
total_count | Integer | Total count of the order items |
success_count | Integer | Total count of Successful order items |
failed_count | Integer | Total count of Failed order items |
id | UUID | Unique order id |
reference_id | String | The reference_id sent by the client while placing the order |
items | Array of (Order Item) | Order items status and Gift Card details |
created_at | String | Timestamp Format ISO_8601 example “2022-10-19T14:21:00.000Z” |
total_pages | Integer | The total number of pages that are available for the given set of data. Note: If an order has less than 100 items, the total_pages, current_page fields can be ignored as the API response will return all items. |
current_page | Integer | Field represents the page number of the current set of data that is being returned |
Order Item
Parameter | Type | Description |
---|---|---|
status | String | Order Item status |
product_id | String | |
currency_code | String | ISO 4217 Currency Codes |
denomination | Integer | |
giftcard | Giftcard | Gift card details |
recipient | Recipient | |
send_email | Bool | |
created_at | String | Timestamp Format ISO_8601 example “2022-10-19T14:21:00.000Z” |
Giftcard
Parameter | Type | Description |
---|---|---|
number | String | Gift card number |
card_id | String | Internal Gift card id |
original_value | String | |
remaining_value | String | |
expiration_date | String | Date In YYYY-MM-DD Format |
url | String | Web preview link |
pin | Integer or NULL | Will be present if the giftcard needs a pin to be redeemed |
Order Reprocess
curl --location --request POST 'https://testapi.meritincentives.com/api/v3/giftcard/orders/6e755c0d-23d0-48a3-a047-0a754bca41b8/reprocess' \
--header 'Authorization: Bearer secret_key' \
--header 'idempotency-key: b8e0183f-51a8-49cc-96be-189fc9a4a4ee' \
The above command returns JSON structured like this:
{
"id": "6e755c0d-23d0-48a3-a047-0a754bca41b8",
"status": "PROCESSING"
}
This request is for reprocessing the order that was FAILED or PARTIALLY_COMPLETED. The corresponding id
from the create giftcard response needs to be provided.
HTTP request
POST https://testapi.meritincentives.com/api/v3/giftcard/orders/:id/reprocess
Query Parameters
Parameter | Required | Description |
---|---|---|
id | Yes | Unique order id that was provided in the response of create API |
Reprocess Response
Parameter | Type | Description |
---|---|---|
id | UUID | Unique order id |
status | String | Order status |
Vendor Account
Get Account Balance
This Api returns the account balance.
HTTP request
GET https://testapi.meritincentives.com/api/v3/vendor/balance
curl --location --request GET 'https://testapi.meritincentives.com/api/v3/vendor/balance' \
--header 'Authorization: Bearer key'
The above command returns JSON structured like this:
{
"availableFunds": {
"amount": 47,
"currencyCode": "AED"
}
}
Get Account Balance Response
Parameter | Type |
---|---|
availableFunds | Available Funds |
Types
Available Funds
Parameter | Type |
---|---|
amount | Float |
currencyCode | String ISO_4217 |
Recipient
Parameter | Required | Type |
---|---|---|
first_name | No | String |
last_name | No | String |
Yes | String | |
lang | No (Default en - english) | String ISO 639-1 |
Note: Language codes supported by the product will be shared by the Merit team
Order Status
Value | Description |
---|---|
ACCEPTED | The order is accepted by Merit System |
PROCESSING | The order is currently being processed. |
COMPLETED | The order has been fulfilled. (All requested gift cards have been placed.) |
FAILED | The creation of all gift cards requested in an order has failed. |
PARTIALLY_COMPLETED | A portion of the gift cards requested in the order were successfully created, while others failed. |
Order Item Status
Value | Description |
---|---|
ACCEPTED | The order item is accepted by Merit System |
PROCESSING | The order item is currently being processed. |
COMPLETED | The order item has been fulfilled. |
FAILED | The order item failed. |
Errors
Merit uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx
range indicate success. Codes in the 4xx
range indicate an error that failed given the information provided (e.g., a required parameter was omitted). Codes in the 5xx
range indicate an error with Merit's servers (these are rare).
Error Attributes
Parameter | Required | Type |
---|---|---|
errorType | Yes | String |
errorCode | Yes | Integer |
errorMessage | Yes | String |
Error Types
Type | Description |
---|---|
VALIDATION_ERROR | there was an issue with the data that was sent to an API |
INVALID_REQUEST_ERROR | one or more field is missing from the request |
FUND_ERROR | your account doesn't have enough credit to perform the action |
ACCESS_DENIED_ERROR | don't have access to perform the action |
SERVER_ERROR | something unexpected happened on server while processing the request. |
HTTP Status Codes
Code | Description |
---|---|
200 - OK | Everything worked as expected. |
400 - Bad Request | The request was unacceptable, often due to missing a required parameter. |
401 - Unauthorized | Invalid Security Credentials Or IP not whitelisted. |
404 - Not Found | The requested resource doesn't exist. |
409 - Conflict | The requested resource already exist. |
429 - Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
500, 502, 503, 504 - Server Errors | Something went wrong on Merit's end. (These are rare.) |
Error codes
Code | Description |
---|---|
2001 | insufficient fund. |
2002 | unauthorized |
2003 | forbidden |
2004 | some required field is missing from the request |
2005 | invalid denomination |
2006 | invalid product |
2007 | invalid email |
2008 | invalid quantity |
2009 | invalid page number |
2010 | order not found |
2011 | invalid language |
2012 | idempotency-key should be in 20 - 64 characters |
2013 | request with idempotency-key is in-progress. Please wait! |
2050 | something unexpected happened on server while processing the request. |
Example: Unauthorized Response - HTTP Status Code 401
{
"errorType": "ACCESS_DENIED_ERROR",
"errorCode": 2002,
"errorMessage": "unauthorized"
}
Idempotency
Merit support idempotency to provides protection against accidental duplicate calls causing unintended consequences.
The client needs to send HTTP requests with the idempotency-key header that contains unique identifier string with a maximum of 20 - 64 characters.
If the idempotency-key is not provided, the request will be processed without considering idempotency, potentially leading to duplicate request processing.
Idempotency is applicable only to POST and DELETE calls; idempotency keys sent in GET calls will be ignored.
idempotency key header that looks like the following:
idempotency-key: XXXX-XXXXX-XXXXXX-XXXX
curl "api_endpoint_here" \
-H "idempotency-key: XXXX-XXXXX-XXXXXX-XXXX"
Throttle rate
Merit API will throttle/decline incoming requests to prevent misuse of the system. The request rate cannot exceed more than specified below.
API | Throttle rate (# of requests) |
---|---|
Single Order Async | 10 per 10 seconds |
Get Order | 60 per 10 seconds |
Reprocess Order | 10 per 10 seconds |
When requests from your code exceed a throttle rate, your request fails and a ThrottlingException is returned with a HTTP status code 429 (Too Many Request)
Response will contain following headers.
RateLimit-Limit: The maximum number of requests you're permitted to make per hour.
RateLimit-Reset: the time at which the current rate limit window resets in UTC epoch seconds