Edit and Update Subaccount Details

PATCH Method

Kaleyra.io offers an API that enables you to edit and update the sub-account details associated with a parent account. The sub-account can be identified based on the subaccount's SID and the parent's SID and API-Key.

📘

Note:

PATCH Method allows passing in the API request only the attributes that need to be edited. All attributes not passed in the API request will retain their current value without any modification.

Base URL

**<https://api.kaleyra.io>**

To edit and update the sub-account detail associated with a parent account, perform the following steps:

API request to edit and update the sub-account detail

To edit and update the sub-account detail, use the /subaccounts/<subaccount_sid> endpoint with the following request method:

Request Format

curl --location --request PATCH '<url>/api/v1/<sid>/subaccounts/<subaccount_sid>' \
--header 'api-key: <api-key>' \
--header 'Content-Type: <content-type>' \
--data-raw '{
    "account_name": "<account-name>",
    "credit_amount": <credit-amount>,
    "low_balance_alert": <low-balance-alert>
}'

The following table describes the parameter used for edit and update sub-account details:

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
account_nameString - only alphanumeric, no special charactersUpdate sub-account name.Always applicable.NoJohn Doe1
credit_amountNumberThe credit amount you want to update for the sub-account user.Applicable when subaccount_credit_type = assigned.No5
low_balance_alertBooleanIdentifier to send low balance alerts to specific email addresses
.
Applicable only when subaccount_credit_type = assigned.NoTrue/False
low_balance_limitNumberThe threshold amount to send an alert email if Subaccount’s balance goes below it.Applicable when subaccount_credit_type = assigned and low_balance_alert is true.No5
low_balance_emailsArray of strings - valid emailEmail addresses to which low balance alert is sent. You can add more than one email address separated by a comma (,).Applicable when subaccount_credit_type = assigned and low_balance_alert is true.No[[email protected]]
monthly_limitNumberThe monthly limit you want to update for a sub-account user.Applicable when subaccount_credit_type = shared and monthly_limit is already added while creating the sub-account.No300
statusStringValid statuses are: suspend and reactivate. The valid statuses are: suspend and reactivate.Always applicable.Nosuspend/reactiv
return_budgetBooleanIdentifier to return the credit amount/ monthly limit of sub-account to the parent account.Applicable when status = suspend.NoTrue/False

📘

Note:

At least you must pass one of the parameters listed to get a successful response.

Sample Request

The following is the sample request:

curl --location --request PATCH 'https://api.kaleyra.io/api/v1/HXXXXXXX071IN/subaccounts/HXXXXXXX071IN_1710' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--header 'Content-Type: application/json' \
--data-raw '{
    "account_name": "John Doe1",
    "credit_amount": 5,
    "low_balance_alert": false
}'

Sample Success Response

The following is the sample success response for editing and updating the sub-account details:

{
    "code": "RBC103",
    "message": "Subaccount Edited Successfully",
    "data": {
        "account_name": "John Doe1",
        "email": "[email protected]",
        "status": "active",
        "sid": "HXXXXXXX071IN_1710",
        "api_key": "Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3",
        "channels": [
            "sms"
        ],
        "low_balance_alert": false,
        "subaccount_credit_type": "assigned",
        "balance": 4
    },
    "error": {},
    "status": 200
}

Sample Failure Response

The following is a sample failure response:

{
    "code": "RBC2327",
    "message": "API Key and SID do not belong to parent company",
    "data": {},
    "error": {},
    "status": 401
}

For more information about response codes and statuses related to editing and updating sub-account details, see Response Codes and Statuses for Editing and Updating Subaccount Details and Subaccount Status.