Add Currency crm.currency.add
Scope:
crmWho can execute the method: any user with access to modify CRM settings
This method adds a new currency.
For the languages used on the account, localization parameters must be specified. If not provided, default parameters will be used. Localization parameters for a specific language can be set using the crm.currency.localizations.set method.
Method Parameters
Required parameters are marked with *
|
Name |
Description |
|
fields* |
Field values (detailed description provided below) for adding a new currency in the form of a structure:
|
Parameter fields
Required parameters are marked with *
|
Name |
Description |
|
CURRENCY* |
Currency identifier. Corresponds to the ISO 4217 standard |
|
BASE |
Indicates whether the currency is base. Possible values:
Default value is Warning It is not recommended to change the base currency via REST. Otherwise, it will be necessary to change the rates of all currencies. |
|
AMOUNT_CNT* |
Denomination. Typically, |
|
AMOUNT* |
Exchange rate relative to the base currency. |
|
SORT |
Position in the currency list. Default value is |
|
LANG |
Currency localization parameters. An object in the format If not all languages are specified, default localization parameters will be used for the remaining ones. |
Parameter LANG
|
Name |
Description |
|
DECIMALS* |
Number of decimal places in the fractional part. |
|
DEC_POINT |
Decimal point for output. |
|
FORMAT_STRING |
Format template. |
|
FULL_NAME |
Name of the currency in the language for which localization is added. |
|
HIDE_ZERO |
Indicates whether to hide insignificant zeros. |
|
THOUSANDS_SEP |
Thousands separator. |
|
THOUSANDS_VARIANT |
Code for the thousands separator. Allowed values are described in the reference. |
Code Examples
-
Creating the yuan with localization parameters (Russian and English languages)
The base currency is the ruble. The exchange rate for the yuan is 12.2251 rubles for 1 yuan.
How to Use Examples in Documentation
cURL (Webhook)cURL (OAuth)JSPHPcurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"fields":{"CURRENCY":"CNY","BASE":"N","AMOUNT":12.2251,"AMOUNT_CNT":1,"SORT":9000,"LANG":{"ru":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# CNY","FULL_NAME":"yuan","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"S"},"en":{"DECIMALS":2,"DEC_POINT":",","FORMAT_STRING":"# CNY","FULL_NAME":"yuan","HIDE_ZERO":"Y","THOUSANDS_SEP":"."}}}}' \ https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.currency.addcurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"fields":{"CURRENCY":"CNY","BASE":"N","AMOUNT":12.2251,"AMOUNT_CNT":1,"SORT":9000,"LANG":{"ru":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# CNY","FULL_NAME":"yuan","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"S"},"en":{"DECIMALS":2,"DEC_POINT":",","FORMAT_STRING":"# CNY","FULL_NAME":"yuan","HIDE_ZERO":"Y","THOUSANDS_SEP":"."}}},"auth":"**put_access_token_here**"}' \ https://**put_your_bitrix24_address**/rest/crm.currency.addBX24.callMethod( "crm.currency.add", { fields: { CURRENCY: 'CNY', BASE: 'N', AMOUNT: 12.2251, AMOUNT_CNT: 1, SORT: 9000, LANG: { ru: { DECIMALS: 2, DEC_POINT: '.', FORMAT_STRING: '# CNY', FULL_NAME: 'yuan', HIDE_ZERO: 'Y', THOUSANDS_VARIANT: 'S', }, en: { DECIMALS: 2, DEC_POINT: ',', FORMAT_STRING: '# CNY', FULL_NAME: 'yuan', HIDE_ZERO: 'Y', THOUSANDS_SEP: '.', }, }, } }, ) .then( function(result) { if (result.error()) { console.error(result.error()); } else { console.log(result); } }, function(error) { console.info(error); } );require_once('crest.php'); $result = CRest::call( 'crm.currency.add', [ 'fields' => [ 'CURRENCY' => 'CNY', 'BASE' => 'N', 'AMOUNT' => 12.2251, 'AMOUNT_CNT' => 1, 'SORT' => 9000, 'LANG' => [ 'ru' => [ 'DECIMALS' => 2, 'DEC_POINT' => '.', 'FORMAT_STRING' => '# CNY', 'FULL_NAME' => 'yuan', 'HIDE_ZERO' => 'Y', 'THOUSANDS_VARIANT' => 'S', ], 'en' => [ 'DECIMALS' => 2, 'DEC_POINT' => ',', 'FORMAT_STRING' => '# CNY', 'FULL_NAME' => 'yuan', 'HIDE_ZERO' => 'Y', 'THOUSANDS_SEP' => '.', ], ], ] ] ); echo '<PRE>'; print_r($result); echo '</PRE>'; -
Creating the Indonesian rupiah
Assuming the base currency is the ruble. The currency has a very low exchange rate — 1 rupiah is equivalent to 0.00548 rubles. In this case, we increase the denomination (AMOUNT_CNT) to set the rate with the required precision.
How to Use Examples in Documentation
cURL (Webhook)cURL (OAuth)JSPHPcurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"fields":{"CURRENCY":"IDR","AMOUNT":54.8738,"AMOUNT_CNT":10000,"SORT":8000,"LANG":{"ru":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"Rp#","FULL_NAME":"rupiah","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"},"en":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# CNY","FULL_NAME":"rupee","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"}}}}' \ https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.currency.addcurl -X POST \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"fields":{"CURRENCY":"IDR","AMOUNT":54.8738,"AMOUNT_CNT":10000,"SORT":8000,"LANG":{"ru":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"Rp#","FULL_NAME":"rupiah","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"},"en":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# CNY","FULL_NAME":"rupee","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"}}},"auth":"**put_access_token_here**"}' \ https://**put_your_bitrix24_address**/rest/crm.currency.addBX24.callMethod( "crm.currency.add", { fields: { CURRENCY: 'IDR', AMOUNT: 54.8738, AMOUNT_CNT: 10000, SORT: 8000, LANG: { ru: { DECIMALS: 2, DEC_POINT: '.', FORMAT_STRING: 'Rp#', FULL_NAME: 'rupiah', HIDE_ZERO: 'Y', THOUSANDS_VARIANT: 'C' }, en: { DECIMALS: 2, DEC_POINT: '.', FORMAT_STRING: '# CNY', FULL_NAME: 'rupee', HIDE_ZERO: 'Y', THOUSANDS_VARIANT: 'C' } } } }, ) .then( function(result) { if (result.error()) { console.error(result.error()); } else { console.log(result); } }, function(error) { console.info(error); } );require_once('crest.php'); $result = CRest::call( 'crm.currency.add', [ 'fields' => [ 'CURRENCY' => 'IDR', 'AMOUNT' => 54.8738, 'AMOUNT_CNT' => 10000, 'SORT' => 8000, 'LANG' => [ 'ru' => [ 'DECIMALS' => 2, 'DEC_POINT' => '.', 'FORMAT_STRING' => 'Rp#', 'FULL_NAME' => 'rupiah', 'HIDE_ZERO' => 'Y', 'THOUSANDS_VARIANT' => 'C', ], 'en' => [ 'DECIMALS' => 2, 'DEC_POINT' => '.', 'FORMAT_STRING' => '# CNY', 'FULL_NAME' => 'rupee', 'HIDE_ZERO' => 'Y', 'THOUSANDS_VARIANT' => 'C', ] ] ] ] ); echo '<PRE>'; print_r($result); echo '</PRE>';
Response Handling
HTTP status: 200
{
"result": "CNY",
"time": {
"start": 1717684463.467685,
"finish": 1717684465.282238,
"duration": 1.8145530223846436,
"processing": 0.12580394744873047,
"date_start": "2024-06-06T16:34:23+02:00",
"date_finish": "2024-06-06T16:34:25+02:00",
"operating": 0
}
}
Returned Data
|
Name |
Description |
|
result |
Identifier of the created currency. |
|
time |
Information about the request execution time. |
Error Handling
HTTP status: 400
{
"error": "",
"error_description": "Access denied."
}
|
Name |
Description |
|
error |
String error code. It may consist of digits, Latin letters, and underscores |
|
error_description |
Textual description of the error. The description is not intended to be shown to the end user in its raw form |
Possible Error Codes
|
Code |
Description |
Value |
|
Empty string |
Access denied. |
Insufficient access rights. |
|
Empty string |
The "Currency" module is not found! Please install the "Currency" module. |
|
|
|
Undefined array key "#FIELD#" |
Required field #FIELD# is not specified (the missing field code will be substituted instead of #FIELD#) |
|
|
Other errors in the data for creating the currency. |
Statuses and System Error Codes
HTTP Status: 20x, 40x, 50x
The errors described below may occur when calling any method.
|
Status |
Code |
Description |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
An internal server error has occurred, please contact the server administrator or Bitrix24 technical support |
|
|
|
The request intensity limit has been exceeded |
|
|
|
The current method is not allowed to be called using batch |
|
|
|
The maximum length of parameters passed to the batch method has been exceeded |
|
|
|
Invalid access token or webhook code |
|
|
|
The methods must be called using the HTTPS protocol |
|
|
|
The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support |
|
|
|
The REST API is available only on commercial plans |
|
|
|
The user whose access token or webhook was used to call the method lacks permissions |
|
|
|
The manifest is not available |
|
|
|
The request requires higher privileges than those provided by the webhook token |
|
|
|
The provided access token has expired |
|
|
|
The user does not have access to the application. This means that the application is installed, but the account administrator has allowed access to this application only for specific users |
|
|
|
The public part of the site is closed. To open the public part of the site on an on-premise installation, disable the option "Temporary closure of the public part of the site". Path to the setting: Desktop > Settings > Product Settings > Module Settings > Main Module > Temporary closure of the public part of the site |
Continue Learning
- Update Currency crm.currency.update
- Get Currency by ID crm.currency.get
- Get the list of currencies crm.currency.list
- Delete Currency crm.currency.delete
- Get Currency Fields crm.currency.fields