Update Currency crm.currency.update

Scope: crm

Who can execute the method: any user with access to modify CRM settings

This method updates an existing currency.

Parameters

Name
type

Description

ID
string

Currency identifier.

Corresponds to the ISO 4217 standard.

The identifier can be obtained using the crm.currency.list method.

fields
object

Field values (detailed description provided below) for updating the currency in the following structure:

fields: {
            SORT: 'value'
            AMOUNT_CNT: 'value',
            AMOUNT: 'value'
            BASE: 'value',
            LANG: {
                lang_1: {
                    DECIMALS: 'value',
                    DEC_POINT: 'value',
                    ...
                },
                ...
                lang_N: {
                    ...
                }
            }
        }
        

Parameter fields

Required parameters are marked with *

Name
type

Description

SORT
integer

Position in the currency list.

Default value is 100

AMOUNT_CNT*
integer

Denomination. Typically, 1 or a multiple of 10 is used as the denomination.

AMOUNT*
double

Exchange rate relative to the base currency.

BASE
string

Indicates whether the currency is a base currency.

Possible values:

  • Y — yes
  • N — no

Default value is N.

Warning

It is not recommended to change the base currency via REST. Otherwise, you will need to change the rates of all currencies.

LANG
object

Currency localization parameters.

An object in the format {"lang_1": "value_1", ... "lang_N": "value_N"}, where lang_N is the language identifier, and value is an object of type crm_currency_localization.

If not all languages are specified, the remaining ones will use default localization parameters.

Parameter LANG

Name
type

Description

DECIMALS*
int

Number of decimal places in the fractional part.

DEC_POINT
string

Decimal point for output.

FORMAT_STRING
string

Format template.

FULL_NAME
string

Name of the currency in the language for which localization is added.

HIDE_ZERO
string

Indicates whether to hide insignificant zeros.

THOUSANDS_SEP
string

Thousands separator.

THOUSANDS_VARIANT
string

Code for the thousands separator.

Refer to the crm_currency_localization documentation for acceptable values.

Examples

  1. Changing the exchange rate of the yuan relative to the base currency.

    How to Use Examples in Documentation

    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{"ID":"CNY","fields":{"AMOUNT":15.3449}}' \
            https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.currency.update
            
    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{"ID":"CNY","fields":{"AMOUNT":15.3449},"auth":"**put_access_token_here**"}' \
            https://**put_your_bitrix24_address**/rest/crm.currency.update
            
    BX24.callMethod(
                "crm.currency.update",
                {
                    ID: 'CNY',
                    fields: {
                        AMOUNT: 15.3449,
                    }
                },
            )
            .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.update',
                [
                    'ID' => 'CNY',
                    'fields' => [
                        'AMOUNT' => 15.3449,
                    ]
                ]
            );
            
            echo '<PRE>';
            print_r($result);
            echo '</PRE>';
            
  2. Changing the localizations of the currency (using the example of the US dollar)

    After executing this example, the localizations for the currency USD will be changed (or added) only for English and German languages. Localizations for other languages, if they existed, will not be changed.

    This example is similar to the operation of the crm.currency.localizations.set method.

    How to Use Examples in Documentation

    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{"ID":"USD","fields":{"LANG":{"en":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"$#","FULL_NAME":"US Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"S"},"de":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# $","FULL_NAME":"US-Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"}}}}' \
            https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.currency.update
            
    curl -X POST \
            -H "Content-Type: application/json" \
            -H "Accept: application/json" \
            -d '{"ID":"USD","fields":{"LANG":{"en":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"$#","FULL_NAME":"US Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"S"},"de":{"DECIMALS":2,"DEC_POINT":".","FORMAT_STRING":"# $","FULL_NAME":"US-Dollar","HIDE_ZERO":"Y","THOUSANDS_VARIANT":"C"}}},"auth":"**put_access_token_here**"}' \
            https://**put_your_bitrix24_address**/rest/crm.currency.update
            
    BX24.callMethod(
                "crm.currency.update",
                {
                    ID: 'USD',
                    fields: {
                        LANG: {
                            en: {
                                DECIMALS: 2,
                                DEC_POINT: '.',
                                FORMAT_STRING: '$#',
                                FULL_NAME: 'US Dollar',
                                HIDE_ZERO: 'Y',
                                THOUSANDS_VARIANT: 'S'
                            },
                            de: {
                                DECIMALS: 2,
                                DEC_POINT: '.',
                                FORMAT_STRING: '# $',
                                FULL_NAME: 'US-Dollar',
                                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.update',
                [
                    'ID' => 'USD',
                    'fields' => [
                        'LANG' => [
                            'en' => [
                                'DECIMALS' => 2,
                                'DEC_POINT' => '.',
                                'FORMAT_STRING' => '$#',
                                'FULL_NAME' => 'US Dollar',
                                'HIDE_ZERO' => 'Y',
                                'THOUSANDS_VARIANT' => 'S',
                            ],
                            'de' => [
                                'DECIMALS' => 2,
                                'DEC_POINT' => '.',
                                'FORMAT_STRING' => '# $',
                                'FULL_NAME' => 'US-Dollar',
                                'HIDE_ZERO' => 'Y',
                                'THOUSANDS_VARIANT' => 'C',
                            ]
                        ]
                    ]
                ]
            );
            
            echo '<PRE>';
            print_r($result);
            echo '</PRE>';
            

Response Handling

HTTP status: 200

{
            "result": true,
            "time": {
                "start": 1717764521.938284,
                "finish": 1717764522.516576,
                "duration": 0.5782921314239502,
                "processing": 0.07656002044677734,
                "date_start": "2024-06-07T14:48:41+02:00",
                "date_finish": "2024-06-07T14:48:42+02:00",
                "operating": 0
            }
        }
        

Returned Data

Name
type

Description

result
boolean

Result of the currency update.

time
time

Information about the request execution time.

Error Handling

HTTP status: 400

{
        	"error": "",
        	"error_description": "Access denied."
        }
        

Name
type

Description

error
string

String error code. It may consist of digits, Latin letters, and underscores

error_description
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.

ERROR_CODE

Other errors in the data for changing the currency.

Statuses and System Error Codes

HTTP Status: 20x, 40x, 50x

The errors described below may occur when calling any method.

Status

Code
Error Message

Description

500

INTERNAL_SERVER_ERROR
Internal server error

An internal server error has occurred, please contact the server administrator or Bitrix24 technical support

500

ERROR_UNEXPECTED_ANSWER
Server returned an unexpected response

An internal server error has occurred, please contact the server administrator or Bitrix24 technical support

503

QUERY_LIMIT_EXCEEDED
Too many requests

The request intensity limit has been exceeded

405

ERROR_BATCH_METHOD_NOT_ALLOWED
Method is not allowed for batch usage

The current method is not allowed to be called using batch

400

ERROR_BATCH_LENGTH_EXCEEDED
Max batch length exceeded

The maximum length of parameters passed to the batch method has been exceeded

401

NO_AUTH_FOUND
Wrong authorization data

Invalid access token or webhook code

400

INVALID_REQUEST
Https required

The methods must be called using the HTTPS protocol

503

OVERLOAD_LIMIT
REST API is blocked due to overload

The REST API is blocked due to overload. This is a manual individual block, to remove it you need to contact Bitrix24 technical support

403

ACCESS_DENIED
REST API is available only on commercial plans

The REST API is available only on commercial plans

403

INVALID_CREDENTIALS
Invalid request credentials

The user whose access token or webhook was used to call the method lacks permissions

404

ERROR_MANIFEST_IS_NOT_AVAILABLE
Manifest is not available

The manifest is not available

403

insufficient_scope
The request requires higher privileges than provided by the webhook token

The request requires higher privileges than those provided by the webhook token

401

expired_token
The access token provided has expired

The provided access token has expired

403

user_access_error
The user does not have access to the application

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

500

PORTAL_DELETED
Portal was deleted

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