Skip to content

Create Consumer

The purpose of this function is to create a consumer data record in the Brown-Forman CRM database. This is used for newsletter subscriptions and sweeps forms, but not Contact Us.

Path

https://api.b-fonline.com/api/create_consumer

Method

POST

Required Parameters

  • birth_date (YYYY-MM-DD)
  • brand_id (find this id from the brands API call)
  • source_code (get this number from B-F IT)
  • segment_id (use 4 unless instructed to do otherwise)
  • country_iso_3 (ISO3 country code)
  • url (URL of the page using this API call)
  • page_description (short description e.g. "Jack Daniel's newsletter signup")

Optional Parameters

  • first_name
  • first_name2
  • middle_initial
  • last_name
  • last_name2
  • address1
  • address2
  • address3
  • address4
  • address5
  • city
  • state_prov_terr (state, province, or territory (non-us))
  • us_state_abbrv
  • zip_postal
  • gender
  • email
  • phone_number
  • mobile_number
  • title_text (e.g. Mr., Ms., Mrs.)
  • sub_text (e.g. Sr., Jr.)
  • industry_flag (Y or N)
  • send_email (Y or N, if send_email is set to Y then 'email' is required)
  • send_mail (Y or N)
  • send_sms (Y or N, if send_sms is set to Y then 'mobile_number' is required)
  • promotion_response (Array of question/answer pairs, see the cURL example below)

Responses

  • 201 Created
    • {"consumer_id":"123456789"}
  • 422 (Unprocessable Entity)
    • Error message in JSON response
  • 500
    • Something has gone horribly wrong, please let us know.

Code Examples

curl -X POST \
  https://api.b-fonline.com/api/create_consumer \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
    "first_name":"testfirst",
    "first_name2":"testlast",
    "middle_initial":"X",
    "last_name":"TestLast",
    "last_name2":"TestLast2",
    "address1":"Address line 1",
    "address2":"Address line 2",
    "address3":"Address line 3",
    "address4":"Address line 4",
    "address5":"Address line 5",
    "city":"City",
    "state_prov_terr":"State, Province or Territory",
    "us_state_abbrv":"KY",
    "zip_postal":"BH11 8NX",
    "birth_date" : "1980-02-20",
    "gender":"M",
    "country_iso_3":"USA",
    "email":"[email protected]",
    "phone_number":"502-867-5309",
    "mobile_number":"447763376311",
    "title_text":"Mr",
    "sub_text":"Sr.",
    "industry_flag":"Y",
    "brand_id":"52",
    "source_code":"22",
    "send_email":"Y",
    "send_mail":"Y",
    "send_sms":"N",
    "page_description":"Jack daniels registration page",
    "url":"www.jackdaniels.com\/en-us\/become-a-friend",
    "segment_id":"4",
    "promotion_response": [
      {"question": "What is your favorite color?", "answer": "Clear"},
      {"question": "How much wood could a woodchuck chuck if a woodchuck could chuck wood?", "answer": "7"},
      {"question": "What is the answer to life the universe and everything?", "answer": "42"}
    ]
}'
var data = {
    first_name: 'testfirst',
    last_name: 'testlast',
    email: '[email protected]',
    country_iso_3: 'usa',
    zip_postal: '40202',
    birth_date: '1980-01-24',
    send_email : 'Y',
    page_description : 'Sonoma-Cutrer newsletter signup',
    url: 'http://example.com',
    segment_id : '4',
    source_code : '4577',
    brand_id : '36'
};

var settings = {
    url: 'https://api.b-fonline.com/api/create_consumer',
    method: 'POST',
    data: JSON.stringify(data),
    contentType: 'application/json',
    dataType: 'json'
};

$.ajax(settings).done(function(response){
    console.log(response);
});
<?php

$api_url = 'https://api.b-fonline.com/api/create_consumer';

$data = array(
  'first_name' => 'testfirst',
  'last_name' => 'testlast',
  'email' => '[email protected]',
  'country_iso_3' => 'US',
  'zip_postal' => '11111',
  'birth_date' => '1980-01-01',
  'send_email' => 'Y',
  'page_description' => 'Sonoma-Cutrer newsletter signup',
  'url' => 'https://www.sonomacutrer.com',
  'segment_id' => '4',
  'source_code' => '4577',
  'brand_id' => '36'
);

$data_string = json_encode($data);

$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json',
  'Content-Length: ' . strlen($data_string))
);

$result = curl_exec($ch);
curl_close($ch);
var_dump($result);