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:
Parameter | Data Type | Description | Applicable | Mandatory | Example |
---|---|---|---|---|---|
sid | String | Parent account SID (Security Identifier). | Always applicable. | Yes | HXXXXXXX071IN |
subaccount_sid | String | Subaccount SID (Security Identifier). | Always applicable. | Yes | HXXXXXXX071IN_1710 |
content-type | String | The format in which the data is sent. | Always applicable. | Yes | application/json |
api-key | String | Parent account API key. | Always applicable. | Yes | Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3 |
account_name | String - only alphanumeric, no special characters | Update sub-account name. | Always applicable. | No | John Doe1 |
credit_amount | Number | The credit amount you want to update for the sub-account user. | Applicable when subaccount_credit_type = assigned. | No | 5 |
low_balance_alert | Boolean | Identifier to send low balance alerts to specific email addresses . | Applicable only when subaccount_credit_type = assigned. | No | True/False |
low_balance_limit | Number | The 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. | No | 5 |
low_balance_emails | Array of strings - valid email | Email 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_limit | Number | The 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. | No | 300 |
status | String | Valid statuses are: suspend and reactivate. The valid statuses are: suspend and reactivate. | Always applicable. | No | suspend/reactiv |
return_budget | Boolean | Identifier to return the credit amount/ monthly limit of sub-account to the parent account. | Applicable when status = suspend. | No | True/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.
Updated about 1 year ago