Fields

Fields are unique data points you collect about subscribers, essential for personalized communication. They range from basic info like first names to complex details like total purchases, preferred currency, interests, or app behavior. Field names remain consistent, but values vary, crafting rich individual profiles.

Fields are unique data points you collect about a subscriber, forming the backbone of personalized data in Bento. These can range from simple information like first names to more complex details such as total purchases, preferred currency, or even behavioral patterns. Each field name remains consistent for every subscriber while the values vary, allowing for rich individual profiles.

Method Endpoint Description
GET /v1/fetch/fields Get Fields
POST /v1/fetch/fields Create Field

The field model

Field records are simple key/value pairs that unlock personalization across campaigns, flows, and integrations.

name · string

Human-readable label for the field (e.g., `Last Name`).

key · string

Slug-safe identifier you reference in API calls and Liquid templates.

whitelisted · boolean | null

Indicates whether the field is synced to Bento's allowlist for integrations.

GET /v1/fetch/fields

Get Fields

Returns every custom field defined for your site, so you can mirror Bento's schema in external systems.

cURL

bash
curl -L -u publishableKey:secretKey \
  -X GET "https://app.bentonow.com/api/v1/fetch/fields?site_uuid=ExampleID1234" \
  -H "Accept: application/json"

JavaScript

javascript
const axios = require('axios');

let config = {
  method: 'get',
  url: 'https://app.bentonow.com/api/v1/fetch/fields',
  params: { site_uuid: 'ExampleID1234' },
  auth: {
    username: 'publishableKey',
    password: 'secretKey'
  },
  headers: {
    'Accept': 'application/json'
  }
};

axios(config)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch((error) => {
    console.error('Error:', error.response ? error.response.data : error.message);
  });

Laravel SDK

php
use Bentonow\BentoLaravel\Facades\Bento;

return Bento::getFields()->json();

Python

python
from bento_api import BentoAPI
import os

api = BentoAPI(
  site_uuid=os.getenv('BENTO_SITE_UUID'),
  username=os.getenv('BENTO_PUBLISHABLE_KEY'),
  password=os.getenv('BENTO_SECRET_KEY')
)
fields = api.get_fields()

C#

csharp
public class FieldExample
{
  private readonly IBentoFieldService _fieldService;

  public FieldExample(IBentoFieldService fieldService)
  {
    _fieldService = fieldService;
  }

  public async Task FieldExamples()
  {
    var getFieldsResponse = await _fieldService.GetFieldsAsync<dynamic>();
  }
}

Go

go
fields, err := client.GetFields(ctx)
if err != nil {
  log.Fatal(err)
}
for _, field := range fields {
  fmt.Printf("Field: %s\n", field.Attributes.Key)
}

Response

Returns an array of field resources with identifiers and attributes.

Response body

json
{
  "data": [
    {
      "id": "1234",
      "type": "visitors-fields",
      "attributes": {
        "name": "Last Name",
        "key": "last_name",
        "whitelisted": null
      }
    }
  ]
}
POST /v1/fetch/fields

Create Field

Creates a new custom field on your site so you can capture fresh data points.

Required attributes

field.key · string
Unique identifier for the field you want to create.

cURL

bash
curl -L -u publishableKey:secretKey \
  -X POST "https://app.bentonow.com/api/v1/fetch/fields?site_uuid=ExampleID1234" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-raw '{
    "field": {
      "key": "example"
    }
  }'

JavaScript

javascript
const axios = require('axios');

let data = {
  field: {
    key: 'example'
  }
};

let config = {
  method: 'post',
  url: 'https://app.bentonow.com/api/v1/fetch/fields',
  params: { site_uuid: 'ExampleID1234' },
  auth: {
    username: 'publishableKey',
    password: 'secretKey'
  },
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  data: JSON.stringify(data)
};

axios(config)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch((error) => {
    console.error('Error:', error.response ? error.response.data : error.message);
  });

Laravel SDK

php
use Bentonow\BentoLaravel\Facades\Bento;
use Bentonow\BentoLaravel\DataTransferObjects\CreateFieldData;

$data = new CreateFieldData(key: "last_name");

return Bento::createField($data)->json();

Python

python
from bento_api import BentoAPI
import os

api = BentoAPI(
  site_uuid=os.getenv('BENTO_SITE_UUID'),
  username=os.getenv('BENTO_PUBLISHABLE_KEY'),
  password=os.getenv('BENTO_SECRET_KEY')
)
new_field = api.create_field(key="favorite_color")

C#

csharp
public class FieldExample
{
  private readonly IBentoFieldService _fieldService;

  public FieldExample(IBentoFieldService fieldService)
  {
    _fieldService = fieldService;
  }

  public async Task FieldExamples()
  {
    var fieldRequest = new FieldRequest("custom_field");
    var createFieldResponse = await _fieldService.CreateFieldAsync<dynamic>(fieldRequest);
  }
}

Go

go
newField, err := client.CreateField(ctx, "purchase_amount")
if err != nil {
  log.Fatal(err)
}
fmt.Printf("Created new field: %s\n", newField.Attributes.Key)

Response

Returns the created field record.

Response body

json
{
  "data": {
    "id": "1234",
    "type": "visitors-fields",
    "attributes": {
      "name": "Last Name",
      "key": "last_name",
      "whitelisted": null
    }
  }
}

Need the original Markdown? Open raw file