To insert a new deal with the API, send a POST HTTP request including the name, pipeline, and stage, as well as any other optional fields you would like.

Each record you create via the API, you will be returned with the full newly created record.

// Snapforce API token
$api_token = 'your api token goes here';

// Snapforce username
$api_user = 'your username goes here';

// Module name
$module = 'Deals';

// Pass custom field API key as parameter and add the new value
$data = array(
        'name' => '25 License Deal',
        'amount' => '500.00',
        'pipeline_id' => 4,
        'stage_id' => 16,
        'owner' => 2
);

// URL for updating a Deal
$url = 'https://app.snapforce.com/prodigy/api/v1/request.php?module='.$module.'&api_token=' . $api_token . '&api_username=' . $api_user;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

echo 'Sending request...' . PHP_EOL;

$output = curl_exec($ch);
curl_close($ch);

// json decode new deal object and print to terminal
print_r(json_decode($output));