API Reference

The Update Wallet API enables you to add/deduct points to a customer's wallet

Rehook Platform API provides resource oriented URLs to work with your business data. Our API uses JSON for request and response. API errors are returned using standard HTTP response codes.

Introduction

This API will enable you to add or deduct point to a customer wallet when customer have used wallet points to complete a transaction or customer have recharged their wallet on your application.

API details

API Endpoint: https://api.rehook.ai/wallets/customer/{source_id}/transactions/{wallet_id}

HTTP Method: PUT

Prerequisites

  1. API Key and Secret Key for your application
  2. If you don't know the API key and secret key, please go to setting module on admin panel to view API details for your application. To know more about application settings, please visit Application setting
  3. API key and secret key are auto generated and cannot be changed.
  4. Custom wallet to be created for your application. To know more about how to create wallet, please visit Wallet setting

Authentication

You need to provide the API key and Secret of your application in every new request as Authorization. Rehook use Basic authentication method to authenticate the API calls.

AuthorizationValue
UsernameAPI Key of your application
PasswordSecret key of your application

Parameters

Query parameter

This API doesn't have any query parameter.

Path URL

Please pass the below parameter in the path URL

ParameterInDefinitionexample
source_idPathrequired
Rehook Id or source id of a customer
KMN@123
wallet_idPathrequired
wallet id of your custom wallet. you will get this id in Get customer wallet API
123459_jdks

Body parameter

FieldDefinitionExample
descriptionDescription is the description of the transaction.customer have credited his wallet
pointswallet points to be debited or credited20
typetransaction type - credit or debitcredit

Sample request and response

Path: https://api.rehook.ai/wallets/customer/krishna123/transactions/waty_XbgBcerLwjoMhAGcmAHhZ

In above URL path, 'krishna123' is the source id and 'waty_XbgBcerLwjoMhAGcmAHhZ' is the wallet id

request body

{
  "description": "Customer have credited his wallet with 20 points",
  "points": 20,
  "type": "credit"
}

response

On successful API call, rehook will debit or credit the customer wallet based on the transaction type passed in the request body.

{
    "requestId": "59ab618b-3c16-9a8d-9577-db4676513188",
    "txn_id": "trhi_wcufiD5LRWQ067dDhBGA9",
    "id": "cust_SbwItbqREfhaj2UWdc42X",
    "wallet_id": "waty_XbgBcerLwjoMhAGcmAHhZ",
    "loyalty_points": 60,
    "previous_loyalty_points": 40,
    "points": 20,
    "description": "Customer have credited his wallet with 20 points"
}

Below table shows the definition of response body

Field nameDefinitionExample
txn_idtransaction id assigned to a wallet transaction when it's credited or debitedtrhi_wcufiD5LRWQ067dDhBGA9
idrehook id of customercust_SbwItbqREfhaj2UWdc42X
request_idAPI request id assigned by rehook59ab618b-3c16-9a8d-9577
wallet_idwallet id of custom wallet created on rehook in which transaction to be updatedwaty_XbgBcerLwjoMhAGcmAHhZ
loyalty_pointsCurrent loyalty points of customer60
previous_loyalty_pointsPrevious loyalty points of customer before this transaction happened40
pointspoints added/deducted in this transaction20
descriptiondescription of the transactionCustomer have credited his wallet with 20 points

In the above transaction, customer wallet is credited with 20 points.

Error cases

If API call is failed, then Rehook will return the following HTTP success code with response body as given below:

HTTP CodeMessage
400bad request

error response body

field namedescriptionexample
CodeError code400
detailsError detailsGiven resource Id is wrong
messageerror messageResource Id not found
request_idAPI request Id assigned by Rehookabc_123

Sample error response

  1. When source_id in path is wrong
{
    "code": 404,
    "message": "resource not found",
    "details": "customer not found",
    "request_id": "9d06ea48-1b7e-984d-9557-9e69d24233af"
}
  1. When wallet_id in path is wrong

    You will get empty response
    
  2. When parameter is missing

Cannot PUT /wallets/customer/krishna123/transactions
  1. When type field is missing
{
    "code": 401,
    "key": "type",
    "message": "type field is required",
    "details": "type field is required",
    "request_id": "157b9904-ac33-93e2-8860-8bf9e9ba98ba"
}
  1. when points are not passed
{
    "code": 400,
    "key": "invalid_payload",
    "message": "Invalid payload",
    "details": "The payload cannot be empty",
    "request_id": "6b26ebac-5c04-95e8-84cb-9b7df3024055"
}
Language
Credentials
Basic
base64
:
Click Try It! to start a request and see the response here!