Get Deal by Id crm.deal.get

Scope: crm

Who can execute the method: any user with "read" access permission for deals

Method Development Stopped

The method crm.deal.get continues to function, but there is a more relevant alternative crm.item.get.

The method crm.deal.get returns a deal by its identifier.

Method Parameters

Required parameters are marked with *

Name
type

Description

id*
integer

Identifier of the deal.

The identifier can be obtained using the methods crm.deal.list or crm.deal.add

Code Examples

How to Use Examples in Documentation

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":410}' \
        https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.deal.get
        
curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"ID":410,"auth":"**put_access_token_here**"}' \
        https://**put_your_bitrix24_address**/rest/crm.deal.get
        
try
        {
        	const response = await $b24.callMethod(
        		'crm.deal.get',
        		{
        			id: 410,
        		}
        	);
        	
        	const result = response.getData().result;
        	result.error()
        		? console.error(result.error())
        		: console.info(result)
        	;
        }
        catch( error )
        {
        	console.error('Error:', error);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'crm.deal.get',
                    [
                        'id' => 410,
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            if ($result->error()) {
                echo 'Error: ' . $result->error();
            } else {
                echo 'Deal data: ' . print_r($result->data(), true);
            }
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error getting deal: ' . $e->getMessage();
        }
        
BX24.callMethod(
            'crm.deal.get',
            {
                id: 410,
            },
            (result) => {
                result.error()
                    ? console.error(result.error())
                    : console.info(result.data())
                ;
            },
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'crm.deal.get',
            [
                'ID' => 410
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Response Handling

HTTP Status: 200

{
            "result": {
                "ID": "410",
                "TITLE": "New Deal #1",
                "TYPE_ID": "COMPLEX",
                "STAGE_ID": "PREPARATION",
                "PROBABILITY": "99",
                "CURRENCY_ID": "EUR",
                "OPPORTUNITY": "1000000.00",
                "IS_MANUAL_OPPORTUNITY": "Y",
                "TAX_VALUE": "0.00",
                "LEAD_ID": null,
                "COMPANY_ID": "9",
                "CONTACT_ID": "84",
                "QUOTE_ID": null,
                "BEGINDATE": "2024-08-30T02:00:00+02:00",
                "CLOSEDATE": "2024-09-09T02:00:00+02:00",
                "ASSIGNED_BY_ID": "1",
                "CREATED_BY_ID": "1",
                "MODIFY_BY_ID": "1",
                "DATE_CREATE": "2024-08-30T14:29:00+02:00",
                "DATE_MODIFY": "2024-08-30T14:29:00+02:00",
                "OPENED": "Y",
                "CLOSED": "N",
                "COMMENTS": "[B]Example comment[\/B]",
                "ADDITIONAL_INFO": "Additional information",
                "LOCATION_ID": null,
                "CATEGORY_ID": "0",
                "STAGE_SEMANTIC_ID": "P",
                "IS_NEW": "N",
                "IS_RECURRING": "N",
                "IS_RETURN_CUSTOMER": "N",
                "IS_REPEATED_APPROACH": "N",
                "SOURCE_ID": "CALLBACK",
                "SOURCE_DESCRIPTION": "Additional information about the source",
                "ORIGINATOR_ID": null,
                "ORIGIN_ID": null,
                "MOVED_BY_ID": "1",
                "MOVED_TIME": "2024-08-30T14:29:00+02:00",
                "LAST_ACTIVITY_TIME": "2024-08-30T14:29:00+02:00",
                "UTM_SOURCE": "google",
                "UTM_MEDIUM": "CPC",
                "UTM_CAMPAIGN": null,
                "UTM_CONTENT": null,
                "UTM_TERM": null,
                "PARENT_ID_1220": "22",
                "LAST_ACTIVITY_BY": "1",
                "UF_CRM_1721244482250": "Hello world!"
            },
            "time": {
                "start": 1725020945.541275,
                "finish": 1725020946.179076,
                "duration": 0.637800931930542,
                "processing": 0.21427488327026367,
                "date_start": "2024-08-30T14:29:05+02:00",
                "date_finish": "2024-08-30T14:29:06+02:00",
                "operating": 0
            }
        }
        

Returned Data

Name
type

Description

result
deal

Root element of the response. Contains information about the deal fields. The structure is described below

time
time

Information about the request execution time

Type deal

Name
type

Description

ID
integer

Identifier of the deal

TITLE
string

Title

TYPE_ID
crm_status

String identifier of the deal type.

To learn more about the obtained deal type, you can use the method crm.status.list, passing the filter:

{
            ENTITY_ID: 'DEAL_TYPE',
            STATUS_ID: TYPE_ID,
        }
        

CATEGORY_ID
crm_category

Funnel. To learn more about this funnel, you can use the method crm.category.get, passing entityTypeId = 2 and id = CATEGORY_ID

STAGE_ID
crm_status

String identifier of the deal stage.

To learn more about the obtained stage, you can use the method crm.status.list, passing the filter:

{
            ENTITY_ID: entityId,
            STATUS_ID: statusId,
        }
        

where:

  • entityId is equal to:
    • DEAL_STAGE if the deal is in the general funnel (CATEGORY_ID = 0)
    • DEAL_STAGE_{categoryId}, where categoryId = CATEGORY_ID
  • statusId is equal to STAGE_ID

STAGE_SEMANTIC_ID
string

Stage group. Possible values:

  • P — in progress
  • S — successful
  • F — unsuccessful

IS_NEW
char

Indicates whether the deal is new. Possible values:

  • Y — yes
  • N — no

IS_RECURRING
char

Indicates whether the deal is recurring. Possible values:

  • Y — yes
  • N — no

IS_RETURN_CUSTOMER
char

Indicates whether the deal is a repeat. Possible values:

  • Y — yes
  • N — no

IS_REPEATED_APPROACH
char

Indicates whether the approach is repeated. Possible values:

  • Y — yes
  • N — no

PROBABILITY
integer

Probability, %

CURRENCY_ID
crm_currency

Currency

OPPORTUNITY
double

Amount

IS_MANUAL_OPPORTUNITY
char

Indicates whether manual mode for calculating the amount is enabled. Possible values:

  • Y — yes
  • N — no

TAX_VALUE
double

Tax rate

COMPANY_ID
crm_company

Identifier of the company.

To learn more about the company, you can use the method crm.item.get, passing entityTypeId = 4 and id = COMPANY_ID

CONTACT_ID
crm_contact

Identifier of the contact. Deprecated.

To get a list of all contacts associated with the deal, use the method crm.deal.contact.items.get or the universal method crm.item.get

QUOTE_ID
crm_quote

Identifier of the estimate based on which the deal was created.

To learn more about the estimate, you can use the method crm.item.get, passing entityTypeId = 7 and id = QUOTE_ID

BEGINDATE
date

Start date

CLOSEDATE
date

Close date

OPENED
char

Indicates whether the deal is available to everyone. Possible values:

  • Y — yes
  • N — no

CLOSED
char

Indicates whether the deal is closed. Possible values:

  • Y — yes
  • N — no

COMMENTS
string

Comment

ASSIGNED_BY_ID
user

Responsible person

CREATED_BY_ID
user

Created by

MODIFY_BY_ID
user

Modified by

MOVED_BY_ID
user

Identifier of the user who last changed the stage

DATE_CREATE
datetime

Creation date

DATE_MODIFY
datetime

Modification date

MOVED_TIME
datetime

Date of the last stage change

SOURCE_ID
crm_status

Source.

To learn more about the obtained source, you can use the method crm.status.list, passing the filter:

{
            ENTITY_ID: 'SOURCE',
            STATUS_ID: SOURCE_ID,
        }
        

SOURCE_DESCRIPTION
string

Additional information about the source

LEAD_ID
crm_lead

Identifier of the lead based on which the deal was created.

To learn more about the lead, you can use the method crm.item.get, passing entityTypeId = 1 and id = LEAD_ID

ADDITIONAL_INFO
string

Additional information

LOCATION_ID
location

Location. System field

ORIGINATOR_ID
string

External source

ORIGIN_ID
string

Identifier of the element in the external source

UTM_SOURCE
string

Advertising system

UTM_MEDIUM
string

Traffic type

UTM_CAMPAIGN
string

Advertising campaign designation

UTM_CONTENT
string

Content of the campaign

UTM_TERM
string

Search condition of the campaign

LAST_ACTIVITY_TIME
datetime

Date of the last activity in the timeline

LAST_ACTIVITY_BY
user

Author of the last activity in the timeline

UF_CRM_...
any

User-defined fields. For example, UF_CRM_25534736.

Depending on the portal settings, deals may have a set of user-defined fields of specific types. Read more in the section about user-defined fields

PARENT_ID_...
crm_entity

Relationship fields.

If there are smart processes associated with deals on the portal, for each such smart process, there is a field that stores the relationship between this smart process and the deal. The field itself stores the identifier of the element of that smart process.

For example, the field PARENT_ID_153 — relationship with the smart process entityTypeId=153, stores the identifier of the element of this smart process associated with the current deal

Error Handling

HTTP Status: 400

{
            "error": "",
            "error_description": "Parameter 'fields' must be array."
        }
        

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

-

ID is not defined or invalid

The id parameter either has no value or is not a positive integer

-

Access denied

The user does not have permission to "read" this deal

-

Not found

No deal exists with the provided id

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