Skip to content
Last updated

Batch Export Integration

This integration exports customer profile data from Treasure AI directly to Batch using the Batch Profile Mass Update API. Batch is a customer engagement platform (CEP) for omnichannel campaigns across mobile push, web push, in-app messaging, email, and SMS.

The integration maps each query result row to a Batch profile operation. Identity, native attributes, custom attributes, and events are all declared through a column-name prefix convention in your query, so no per-column configuration is needed. You can run the integration in Attributes mode (one row updates one profile) or Events mode (one row records one event, grouped by identifier).

Prerequisites

  • Basic knowledge of Treasure AI.
  • Basic knowledge of Batch profiles, custom IDs, installation identities, native attributes, and events.
  • A Batch REST API key.
  • A Batch project key.
  • A query that exposes a profile identity through the identifier__ column-name prefix (identifier__custom_id, or identifier__apikey together with identifier__installation_id).

Static IP Address of Treasure Data Integration

If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection.

Please find the complete list of static IP addresses, organized by region, at the following document

Limitations

  • All array-valued attributes are replace-only. string_array__ custom attributes and $topic_preferences are always sent as the complete array. Incremental $add/$remove operations are not supported in this version, even though the Batch API supports them. Your query must emit the full desired array.
  • There is no opt-out for the batch__ prefix. A column named batch__region always maps to the native $region attribute. To send a custom attribute instead, alias the column to a name without the prefix.
  • The Profile Mass Update API is synchronous. There is no async indexing token or polling. (The Batch Audience API has async tokens; do not conflate the two.)
  • Throughput (10,000 profile updates per second) is not actively throttled client-side. Only 429 responses trigger a back-off.
  • Column names are normalized to lower case automatically, so uppercase or mixed-case names are accepted. Names that still do not match ^[a-z0-9_]{1,30}$ after lower-casing (for example, names containing hyphens or dots, or longer than 30 characters) must be aliased in the query. No runtime rename beyond case-folding is supported.
  • Rate-limit (429) and server errors (5xx, network timeouts) are retried with exponential back-off. 400 and 401 responses fail fast because they indicate a payload or authentication problem.

Create a New Authentication

In Treasure AI, you must create and configure the data connection before running your query. As part of the data connection, you provide authentication to access Batch.

  1. Open TD Console.
  2. Navigate to Integrations Hub > Catalog.
  3. Click the search icon on the far right of the Catalog screen and enter Batch.
  4. Hover over the Batch connector and select Create Authentication.

The New Authentication dialog opens.

  1. Enter your Batch REST API Key.
  2. Enter your Batch Project Key.
  3. Enter a name for your connection.
  4. Select Continue.
Parameter Required Description
rest_api_keyYesBatch REST API key.
project_keyYesBatch project key.

Configure Export Results

To configure the integration:

  1. Open TD Console.
  2. Navigate to Data Workbench > Queries.
  3. Click New Query to create a query, or open a saved query that you want to export.
  4. At the top of the query editor, select Export Results.
  5. Select the Batch authentication that you created.
  6. Configure the export parameters.

How the Export Works

  1. Column prefix detection: The integration inspects each query result column name and classifies it as an identifier (identifier__), a native attribute (batch__), a type-prefixed custom attribute (date__, url__, string_array__, object__, array__), or a plain custom attribute (no prefix, type inferred from the Embulk column type).
  2. Identity extraction: For each row, the integration reads the identifier__ value and builds the identifiers block, using either custom_id or the installation form (apikey + installation_id).
  3. Attribute or event mapping: In Attributes mode, native columns are emitted under their reserved $… wire keys and custom columns under wrapped or plain keys. In Events mode, each row builds one event, and events are grouped by identifier into the events[] array.
  4. Per-row validation: The integration validates key formats, value limits, native attribute types, and the 25 kB serialized attributes size before sending.
  5. Batching: Operations are buffered and flushed in batches (up to batch_size, maximum 10,000 operations per request).
  6. Retry and partial errors: 429 and server errors are retried with back-off. Batch's SUCCESS_WITH_PARTIAL_ERRORS response is handled according to ignore_partial_errors.

Export Parameters

Parameter Required Default Description
targetNoProfileFixed constant identifying this as a Profile connector. Reserved for forward compatibility. An unknown value causes a configuration error.
profile_sync_typeNoAttributesExport mode. Attributes maps one row to one profile update. Events maps one row to one event, grouped by identifier.
batch_sizeNo10000Number of profile operations per request. Must be an integer from 1 to 10000. A value of 0 or greater than 10000 causes a configuration error.
omit_null_fieldsNotrueWhen true, null-valued fields are stripped from the payload and the attribute is left unmodified. When false, null fields are emitted as JSON null so Batch erases the attribute. Applies to both profile attributes and event properties.
skip_invalid_recordsNotrueWhen true, rows that fail client-side validation are skipped, logged, and counted, and valid rows continue. When false, the task fails on the first invalid row and nothing is sent.
ignore_partial_errorsNotrueGoverns Batch's server-side SUCCESS_WITH_PARTIAL_ERRORS response only. When true, per-record errors are logged and the task continues. When false, the task aborts.

Data Mapping

Identity and attribute type are declared by column-name prefixes in the query result schema. No column configuration is needed. Columns fall into three groups.

Column names are matched and serialized case-insensitively. The integration lower-cases each column name before detecting its prefix and deriving the Batch wire key, so IDENTIFIER__Custom_Id, BATCH__Email_Address, and a plain LoyaltyTier are treated as identifier__custom_id, batch__email_address, and loyaltytier respectively. Custom attribute keys are therefore always sent to Batch in lower case (Batch requires them to match ^[a-z0-9_]{1,30}$). In Events mode the batch__name value is also lower-cased before it is validated and sent, so Purchase_Completed becomes purchase_completed.

Treasure AI query result Batch destination Description
identifier__custom_ididentifiers.custom_idProfile identity. Use this form, or the installation form below. Exactly one form must be present. String, 512 characters maximum.
identifier__apikey + identifier__installation_ididentifiers.installation.apikey and identifiers.installation.installation_idInstallation identity form. Both columns must appear together.
batch__<native_name>$<native_name>Native profile attribute. The batch__ prefix is stripped and the reserved $… wire key is emitted. See the native attribute list below.
date__<name>date(<name>)Custom date attribute. Value is epoch seconds or an RFC 3339 string.
url__<name>url(<name>)Custom URL attribute. Value must include a scheme (://) and be 2048 characters maximum.
string_array__<name><name>Custom string array attribute (replace-only). JSON array of non-empty strings, each 300 characters maximum, 25 items maximum.
object__<name> / array__<name><name>Custom object or array attribute. The cell must be a well-formed JSON object or array string.
<name> (no prefix)<name>Custom attribute, type inferred from the Embulk column type. The key must match ^[a-z0-9_]{1,30}$.

In Attributes mode, the supported batch__ native attribute names are email_address, email_marketing, phone_number, sms_marketing, email_open_tracking_consent, language, timezone, region, and topic_preferences. In Events mode, the batch__ prefix instead carries the reserved event fields name (required), time, label, and tags. The native attribute set is gated by profile_sync_type: profile-native names are rejected in Events mode and event-reserved names are rejected in Attributes mode.

The connector infers Batch types for plain (no-prefix) custom attributes from the Treasure AI column type.

Treasure AI type Batch data type
stringstring
longnumber
doublenumber
booleanboolean
timestampUse date__<name> to send as a Batch date(<name>) attribute.

Sync Modes

Parameter Value Behavior
profile_sync_typeAttributesOne input row maps to one profile update. Native and custom attributes are written to the profile.
profile_sync_typeEventsOne input row maps to one event. Events are grouped by identifier into the events[] array. Up to 15 events accumulate per identifier before a flush.
omit_null_fieldstrueNull-valued fields are stripped client-side; the attribute is left unmodified on the Batch profile.
omit_null_fieldsfalseNull-valued fields are emitted as JSON null; Batch erases the attribute. For typed date__/url__ attributes, the plain unwrapped key is emitted for deletion.

Sample Queries

Profile Attributes Export

This example exports customer profiles with native attributes (email, language, region) and custom attributes (a signup date, a profile URL, and a loyalty tier).

SELECT
  customer_id          AS identifier__custom_id,
  email                AS batch__email_address,
  marketing_consent    AS batch__email_marketing,
  phone                AS batch__phone_number,
  preferred_language   AS batch__language,
  timezone             AS batch__timezone,
  country_code         AS batch__region,
  CAST(signup_ts AS VARCHAR) AS date__signup_date,
  profile_url          AS url__profile_url,
  loyalty_tier,
  interests            AS string_array__interests,
  preferences_json     AS object__preferences
FROM customer_profiles
WHERE TD_TIME_RANGE(time, TD_DATE_TRUNC('day', TD_SCHEDULER_TIME() - 86400, 'UTC'), NULL)

Sample query result

identifier__custom_id batch__email_address batch__language batch__region loyalty_tier
abc123user@example.comenFRgold
def456jane@example.comfrfrsilver

This produces one POST /2.11/profiles/mass-update request. Each row becomes one operation with an identifiers.custom_id block and an attributes object using the $email_address, $language, $region, date(signup_date), url(profile_url), and loyalty_tier wire keys. The batch__region value fr is normalized to FR.

Required configuration

Parameter Value
targetProfile
profile_sync_typeAttributes
skip_invalid_recordstrue
omit_null_fieldstrue

Events Export

This example records one purchase event per row in Events mode. The batch__name column is required; events are grouped under each identifier.

SELECT
  customer_id          AS identifier__custom_id,
  'purchase'           AS batch__name,
  CAST(purchased_at AS VARCHAR) AS batch__time,
  product_category     AS category,
  order_amount         AS amount
FROM purchases
WHERE TD_TIME_RANGE(time, TD_DATE_TRUNC('day', TD_SCHEDULER_TIME() - 86400, 'UTC'), NULL)

Sample query result

identifier__custom_id batch__name batch__time category amount
abc123purchase2026-06-21T10:00:00Zelectronics299
abc123purchase2026-06-21T14:30:00Zbooks42

Both rows share custom_id abc123, so they are grouped into a single operation with two entries in the events[] array. The category and amount columns become event attributes under events[].attributes.

Required configuration

Parameter Value
targetProfile
profile_sync_typeEvents
skip_invalid_recordstrue
Event recency window

Batch enforces a 24-hour recency window on batch__time server-side: an event can be at most 24 hours old and cannot be in the future. For scheduled syncs, ensure event timestamps fall within the last 24 hours of the connector run time, not the data's logical day. Omit batch__time to let Batch stamp the request arrival time instead.

Schedule the Query Export Jobs (Optional)

You can use Scheduled Jobs with Result Export to periodically write the output result to Batch.

Treasure AI's scheduler feature supports periodic query execution to achieve high availability.

(Optional) Schedule Query Export Jobs

You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify.

Treasure Data's scheduler feature supports periodic query execution to achieve high availability.

When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored.

For example, if the cron schedule is '0 0 1 * 1', then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed.

Scheduling your Job Using Treasure Console

  1. Navigate to Data Workbench > Queries

  2. Create a new query or select an existing query.

  3. Next to Schedule, select None.

  4. In the drop-down, select one of the following schedule options:

    Drop-down ValueDescription
    Custom cron...Review Custom cron... details.
    @daily (midnight)Run once a day at midnight (00:00 am) in the specified time zone.
    @hourly (:00)Run every hour at 00 minutes.
    NoneNo schedule.

Custom cron... Details

Cron ValueDescription
0 * * * *Run once an hour.
0 0 * * *Run once a day at midnight.
0 0 1 * *Run once a month at midnight on the morning of the first day of the month.
""Create a job that has no scheduled run time.
 *    *    *    *    *
 -    -    -    -    -
 |    |    |    |    |
 |    |    |    |    +----- day of week (0 - 6) (Sunday=0)
 |    |    |    +---------- month (1 - 12)
 |    |    +--------------- day of month (1 - 31)
 |    +-------------------- hour (0 - 23)
 +------------------------- min (0 - 59)

The following named entries can be used:

  • Day of Week: sun, mon, tue, wed, thu, fri, sat.
  • Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.

A single space is required between each field. The values for each field can be composed of:

Field Value Example Example Description
A single value, within the limits displayed above for each field.
A wildcard '*' to indicate no restriction based on the field.'0 0 1 * *'Configures the schedule to run at midnight (00:00) on the first day of each month.
A range '2-5', indicating the range of accepted values for the field.'0 0 1-10 * *'Configures the schedule to run at midnight (00:00) on the first 10 days of each month.
A list of comma-separated values '2,3,4,5', indicating the list of accepted values for the field.'0 0 1,11,21 * *'Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month.
A periodicity indicator '*/5' to express how often based on the field's valid range of values a schedule is allowed to run.'30 */2 1 * *'Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. '0 0 */5 * *' configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month.
A comma-separated list of any of the above except the '*' wildcard is also supported '2,*/5,8-10'.'0 0 5,*/10,25 * *'Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month.
  1. (Optional) You can delay the start time of a query by enabling the Delay execution.

Execute the Query

Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination.

Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications.

(Optional) You can delay the start time of a query by enabling the Delay execution.

Activate a Segment in Audience Studio

You can also send segment data to the target platform by creating an activation in the Audience Studio.

  1. Navigate to Audience Studio.
  2. Select a parent segment.
  3. Open the target segment, right-mouse click, and then select Create Activation.
  4. In the Details panel, enter an Activation name and configure the activation according to the previous section on Configuration Parameters.
  5. Customize the activation output in the Output Mapping panel.

  • Attribute Columns
    • Select Export All Columns to export all columns without making any changes.
    • Select + Add Columns to add specific columns for the export. The Output Column Name pre-populates with the same Source column name. You can update the Output Column Name. Continue to select + Add Columnsto add new columns for your activation output.
  • String Builder
    • + Add string to create strings for export. Select from the following values:
      • String: Choose any value; use text to create a custom value.
      • Timestamp: The date and time of the export.
      • Segment Id: The segment ID number.
      • Segment Name: The segment name.
      • Audience Id: The parent segment number.
  1. Set a Schedule.

  • Select the values to define your schedule and optionally include email notifications.
  1. Select Create.

If you need to create an activation for a batch journey, review Creating a Batch Journey Activation.

Configure Export Results in Workflow (Optional)

Within Treasure Workflow, you can specify the use of a data connector to export data.

Learn more at Using Workflows to Export Data with the TD Toolbelt.

Sample Workflow Configuration

timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-batch:
  td>: queries/batch_export.sql
  result_connection: batch
  result_settings:
    target: Profile
    profile_sync_type: Attributes
    batch_size: 10000
    skip_invalid_records: true
    ignore_partial_errors: true
    omit_null_fields: true

Troubleshooting

Error or symptom Cause Solution
Authentication fails with 401.The rest_api_key or project_key is incorrect, or the credentials do not have access to the project.Verify the REST API key and project key in the Batch console under Settings.
The export fails at configuration time with "unknown Batch native attribute".A batch__ column uses a suffix that is not a supported native attribute, or it is used in the wrong mode (for example, a profile-native name in Events mode).Check the supported native attribute names and confirm they match profile_sync_type. Incremental forms such as batch__topic_preferences__add are not supported.
The export fails because no identity column is present.The query has no identifier__custom_id and no installation columns, or it includes both identity forms.Provide exactly one identity form: identifier__custom_id, or identifier__apikey together with identifier__installation_id.
The export fails with a custom key error.A custom attribute column name does not match ^[a-z0-9_]{1,30}$ even after lower-casing (for example, it contains hyphens or dots, or is longer than 30 characters). Uppercase alone does not cause this error, because names are lower-cased automatically.Alias the column in the query to a name that uses only lowercase letters, digits, and underscores, 30 characters or fewer.
Rows are skipped.A row fails client-side validation (for example, an invalid email format or an attributes object larger than 25 kB) and skip_invalid_records is true.Review the job logs for the row index, column, and rule, then correct the source data. Set skip_invalid_records to false to fail the export instead of skipping rows.
The export is rate limited.Batch returned 429 Too Many Requests.No action is required. The connector waits at least 5 seconds and retries automatically.
Batch returns SUCCESS_WITH_PARTIAL_ERRORS.Batch accepted the request but rejected some records.Review the per-record diagnostics (bulk index, category, attribute, reason) in the job logs and correct the source data. Set ignore_partial_errors to false to fail the export when partial errors occur.

See Also