Recharge a Subaccount

POST Method

Kaleyra.io offers an API that enables you to recharge a sub-account associated with a parent account. You have both the option available to deposit and withdraw from a sub-account.

Base URL

<https://api.kaleyra.io>

To recharge the sub-account, perform the following steps:

API request to recharge a sub-account

To recharge the sub-account, use the /subaccount/recharge endpoint with the following request method:

Request Format

curl --location --request POST '<url>/api/v1/<sid>/subaccounts/<subaccount_sid>/recharges' \
--header 'api-key: <api-key>' \
--header 'Content-Type: <content-type>' \
--data-raw '{"amount":<amount>}' \
--compressed

The following table describes the parameter used for recharging a sub-account:

Parameter

ParameterData TypeDescriptionApplicableMandatoryExample
sidStringParent account SID (Security Identifier).Always applicable.YesHXXXXXXX071IN
subaccount_sidStringSubaccount SID (Security Identifier).Always applicable.YesHXXXXXXX071IN_1710
content-typeStringThe format in which the data is sent.Always applicable.Yesapplication/json
api-keyStringParent account API key.Always applicable.YesAxxxxxxxxxxxxxxxxxxxxxxxxxxxx3
amountIntegerThe amount to be deposited to/withdrawn from the sub-account

Notes:

- If you use minus (-) sign before the amount, the amount will be deducted from the sub-account and transferred to the parent account.
- Values of 0 or -0 are not allowed.
Always applicable.Yes10

πŸ“˜

Note:

  • You must pass the amount parameter along with the listed parameters to get a successful response.

Sample Request

The following is the sample request:

curl --location --request POST 'https://api.kaleyra.io/api/v1/HXXXXXXX071IN/subaccounts/HXXXXXXX071IN_1710/recharges' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--header 'Content-Type: application/json' \
--data-raw '{"amount":<amount>}' \
--compressed

Sample Success Response

The following is the sample success response for recharging the sub-account:

{
    "code": "RBC2349",
    "message": "Account recharged successfully!",
    "data": {
        "subaccount_balance": 75
    },
    "error": {},
    "status": 200
}

Sample Failure Response

The following is a sample failure response:

{
    "code": "RBC2356",
    "message": "Shared account cannot be recharged",
    "data": {},
    "error": {},
    "status": 400
}

For more information about response codes and statuses related to recharging the sub-account, see Response Codes and Statuses for Recharging Subaccounts.