Не удается засунуть в нужный этап воронки amocrm

Делаю свою интеграцию с амоцрм, все вроде ок но падают заявки с сайта в неразобранное, а хочу сделать так чтобы заявки падали на другой этап(ID воронки брал с урла, ID статуса брал с кода. Так что они верны абсолютно)

<?php

require_once 'access.php';

$name = 'Имя клиента';
$phone = '+79142918212';
$email = '[email protected]';
$target = 'Цель';
$company = 'Название компании';
$ip = '1.2.3.4';
$domain = 'test.loc';
$price = 0;
$pipeline_id = 5669335;
$status_id = 49897042;
$user_amo = 8448715;

$data = [
 [
 "price" => $price,
 "responsible_user_id" => (int) $user_amo,
  "name" => "Сделка для примера",
  "pipeline_id" => (int) $pipeline_id,
  "status_id" => (int) $status_id,          
 "_embedded" => [
 "metadata" => [
 "category" => "forms",
 "form_id" => 1123,
 "form_name" => "Форма на сайте",
 "form_page" => $target,
 "form_sent_at" => strtotime(date("Y-m-d H:i:s")),
 "ip" => $ip,
 "referer" => $domain
 ]
 ]
 ]
];

$method = "/api/v4/leads/complex";

$headers = [
 'Content-Type: application/json',
 'Authorization: Bearer ' . $access_token,
];

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'amoCRM-API-client/1.0');
curl_setopt($curl, CURLOPT_URL, "https://$subdomain.amocrm.ru".$method);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_COOKIEFILE, 'amo_msk/cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, 'amo_msk/cookie.txt');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$out = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$code = (int) $code;
$errors = [
 301 => 'Moved permanently.',
 400 => 'Wrong structure of the array of transmitted data, or invalid identifiers of custom fields.',
 401 => 'Not Authorized. There is no account information on the server. You need to make a request to another server on the transmitted IP.',
 403 => 'The account is blocked, for repeatedly exceeding the number of requests per second.',
 404 => 'Not found.',
 500 => 'Internal server error.',
 502 => 'Bad gateway.',
 503 => 'Service unavailable.'
];

if ($code < 200 || $code > 204) die( "Error $code. " . (isset($errors[$code]) ? $errors[$code] : 'Undefined error') );


$Response = json_decode($out, true);
$Response = $Response['_embedded']['items'];
$output = 'ID добавленных элементов списков:' . PHP_EOL;
foreach ($Response as $v)
 if (is_array($v))
 $output .= $v['id'] . PHP_EOL;
return $output;

Ответы (0 шт):