Skip to content

bidsmith export

export is the offline renderer. It reads a JSON description of the campaigns you want, or a raw SearchStream dump from pull, and writes a fmt-canonical .bid file. No API calls.

Two input modes (mutually exclusive):

  • --from-json — a flat bidsmith-shaped JSON document. Useful when generating .bid programmatically (e.g. from a spreadsheet or a data warehouse).
  • --from-gads-search-response — raw SearchStream JSON. Used by refresh under the hood; useful on its own for testing the renderer against a pull dump.

Synopsis

Terminal window
bidsmith export --from-json FILE [flags]
bidsmith export --from-gads-search-response FILE [flags]

Flags

FlagDescription
--from-json FILEFlat bidsmith JSON. See examples/exports/basic.json for the shape. Mutually exclusive with --from-gads-search-response.
--from-gads-search-response FILERaw Google Ads SearchStream JSON (the output of bidsmith pull). Mutually exclusive with --from-json.
-o, --output FILEWrite to a file. Defaults to stdout.
--include-removedInclude resources whose status is REMOVED. Default: drop them.
--login-customer-id IDOverride the provider login_customer_id (MCC) in the output.
--customer-id IDOverride the provider customer_id in the output.

Environment variables

None required. If --login-customer-id and --customer-id aren’t provided, bidsmith falls back to GOOGLE_ADS_LOGIN_CUSTOMER_ID and GOOGLE_ADS_CUSTOMER_ID from the environment to fill in the provider block.

Exit codes

CodeMeaning
0Successful render.
1Invalid input JSON, conflicting flags, file write error, or other.

Examples

Render from a flat JSON description

Terminal window
bidsmith export --from-json campaign.json -o campaign.bid

Where campaign.json follows the flat bidsmith shape (see the example in the repo). The output is a fmt-canonical .bid file that validate accepts.

Round-trip a live account through the renderer

Terminal window
bidsmith pull -o /tmp/dump.json
bidsmith export --from-gads-search-response /tmp/dump.json -o /tmp/roundtrip.bid
bidsmith validate /tmp/roundtrip.bid

A useful integration test: the result of rendering a live dump should always parse cleanly.

Generate .bid from a script

Terminal window
python build_campaigns.py > generated.json
bidsmith export --from-json generated.json -o generated.bid

Common pattern for teams that bulk-generate campaigns from internal data (product catalogs, market lists, etc.). The Python script writes JSON; bidsmith handles the HCL rendering.

Output shape

The renderer emits the compact form of every resource type:

  • One google_ads_ad_group_criterion per (ad_group, match_type) group, with N keyword {} sub-blocks (rather than N separate resources).
  • One negatives resource per ad-group or campaign with N negative_keyword {} sub-blocks.
  • RSAs as headlines = [...] / descriptions = [...] list attributes when more concise than per-headline blocks.

The output is always canonical — bidsmith fmt --check on the result is a no-op.

See also