S
S
Sergey Miller2022-02-07 12:52:09
PHP
Sergey Miller, 2022-02-07 12:52:09

Amo crm api v4 - how to add a deal to a specific stage of a specific funnel?

As the documentation says, this is how I do it:

// создать сделку
$queryUrl = 'https://'.$subdomain.'.amocrm.ru/api/v4/leads'; // сделки




$lead = array(
array(
'name' => $gotFormName,
'status_id '=> 43002655, // вот id колонки
'pipeline_id' => 1828507, // вот id воронки
'price' => 0,
'responsible_user_id '=> 3516160,
'_embedded' => array(
'contacts' => array(
'0' => array(
'id' => $contact_id
)
)
)
),
);





    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_USERAGENT, "amoCRM-API-client/1.0");
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($lead));
    curl_setopt($curl, CURLOPT_URL, $queryUrl);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl,CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT']."/amo-crm/cookie.txt");
    curl_setopt($curl,CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT']."/amo-crm/cookie.txt");
    
    $out = curl_exec($curl);
    curl_close($curl);
    $result = json_decode($out, true);


// $lead_id = $result['_embedded']['leads']['0']['id'];

// echo '<pre>';
// print_r($result);
// echo '</pre>';

But still, the deal is created in the first stage of the first funnel. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark_Dante, 2022-02-07
@Dark_Dante

Well, create in the initial and immediately move to the desired stage

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question