Manage config as code
The console is one way to edit your organization’s draft. The other is a config tree: YAML files in your own
repository that describe features, outcomes, segments, experiments, meters, experiences, products, offers, publications, brands,
link templates and ad types. The edgekit CLI checks the files, compares them with the draft, writes them into the draft and
stages them. You review the change as a diff in a pull request before anything moves.
A config tree changes the same draft the console does. It never changes your sites directly: a change reaches them only when you deploy, exactly as in Stage and deploy a change.
The tree
Section titled “The tree”edgekit.yaml sits at the root of your repository. The tree’s other files are in the edgekit/ folder:
edgekit.yaml tenant, version, and where each folder isedgekit/ products.yaml products, keyed by slug offers.yaml offers, keyed by code brands.yaml brands, keyed by key link-templates.yaml link templates, keyed by key ad-types.yaml ad types, keyed by key experiences.yaml experiences, keyed by site domain, feature and outcome id experiences/ one .js module per experience specs/<kind>/<name>.yaml one file per feature, outcome, segment, experiment, meter, resolution, aggregation or derivation publications/<site>/<slug>.yaml one file per publication, in a folder named for its site's domain envs/qa.yaml values that differ on your QA organization envs/prod.yaml values that differ in production templates/ custom email templatesedgekit.yaml names your organization by its slug, and the tree’s version:
tenant: bofversion: 1paths is optional. It moves the tree and the custom templates to other
folders. Each path is relative to edgekit.yaml and must stay inside the repository. These are the defaults:
paths: config: edgekit templates: edgekit/templatesconfig: . keeps the tree beside edgekit.yaml. Every edgekit config and edgekit templates command takes the
repository root as --dir, the current directory by default, and finds each folder from edgekit.yaml. A file
path in a message is the path in your repository.
A spec file holds the record as the console stores it, plus enabled. Its kind and name must match its path,
and a spec name is unique across kinds. Sites are written by domain. Canvas, rule and outcome ids stay in the file:
they identify parts of one spec, so they are the same in QA and production.
kind: outcomename: allow-allenabled: trueoutcome: id: allow-all reason: defaultproducts.yaml and offers.yaml hold one entry per slug or code. A field you leave out takes its default: for a
product kind: content, rank: 0, status: active and no description, coverage or capabilities; for an offer
purchasable: false, renews: true, status: active, and no prices, edges or discount.
premium: name: Premium sites: [example.com] capabilities: [newsletter-archive]Capabilities are named by key and must already exist. An offer names its product by slug and each edge’s target by offer code.
An offer’s prices follow the rules of the offer’s Prices section in the console. A tree that breaks one is
refused:
- A price must already be in your synced billing catalog and active in your billing provider. To pick up a price you just created, select Sync catalog on Revenue › Billing provider › Pricing, then apply.
- Your billing provider owns a price’s money. List one entry for each currency the provider sells the price in, with
the same
amount,intervalandactiveas the provider holds. A price billed every twelve months has theintervalyear. A price billed on another period, such as every three months, has nointerval. A tree can keep a price the offer already has, unchanged, even if the provider has changed that price since. - An offer sells one price per billing provider. Several offers can list the same price.
- A price that a live user subscription is on cannot be dropped from an offer. Ask EdgeKit to move those user subscriptions to another offer.
- An offer can change its price and its coupon in one apply: the coupon is checked against the prices the file declares.
premium-monthly: product: premium name: Premium monthly purchasable: true prices: - provider: stripe providerPriceId: price_1Pm currency: gbp amount: 900 interval: month - provider: stripe providerPriceId: price_1Pm currency: eur amount: 1000 interval: monthWhat a tree changes, and what it leaves alone
Section titled “What a tree changes, and what it leaves alone”- A record the tree declares is set to what the tree says. A record it does not declare is untouched, so a tree can hold a single feature.
- Removing a record is explicit. Write
remove: truein the spec’s or the publication’s file, or as the product’s, offer’s or ad type’s entry. Deleting a file removes nothing. Once the apply has landed, you can delete the file. - The key is the identity: spec name, product slug, offer code, a publication’s site and slug, a brand’s, link
template’s or ad type’s key. No row id is ever written, so the same tree applies to QA and production. A rename is two edits: a
new record, and
remove: trueon the old one. A brand or a link template is never removed, so a renamed one keeps its old record. - An experiment’s salt never enters the tree. EdgeKit generates it when the experiment is created and keeps it,
so no edit to a file can reshuffle users between arms. A tree that sets
saltis refused.
remove: truelegacy-print: remove: trueSites, capabilities, traits, lists and organization settings are not part of a tree yet. A tree that has
config.yaml, sites.yaml, capabilities.yaml, traits.yaml or lists.yaml is refused as a whole; manage those
in the console. A publication can name lists, feeds, messaging channels, delivery segments and test groups, but a
tree never writes them.
Publications, brands and link templates
Section titled “Publications, brands and link templates”A publication’s file is publications/<site-domain>/<slug>.yaml: the path names its site and its slug, and neither
can change. brands.yaml and link-templates.yaml hold one entry per key.
name: The Dailylist: dailylocale: en-USschedule: days: [1, 2, 3, 4, 5] times: ['06:00'] timezone: America/New_YorklinkTemplate: utmbrand: housechannels: email: messagingChannel: braze-email settings: campaignId: 2b1f… from: The Daily <daily@example.com>variants: main: name: Main template: default channels: email: deliverySegment: subscribers settings: messageVariationId: 7c4a…slots: intro: kind: rich_text title: Good morning block: rich-text top-stories: kind: feed block: story-list-hero props: showByline: true maxItems: 3 feed: top-stories- Fields keep the names of the publication’s settings, with three exceptions: a slot’s
blockandprops, a variant’stemplateandprops, and a channel’ssettings, which hold its Braze ids and sender. - References are keys.
listis the slug of a list on the publication’s site.brand,linkTemplate,feed,messagingChannel,deliverySegmentandtestGroupsname records by key, and a custom template iscustom:<name>. Each must exist in the draft when you plan, except a brand or a link template the same tree declares. A variant may carry its ownlinkTemplate, which tags its links in place of the publication’s; leave it out, or set it tonull, to follow the publication’s. - A brand’s fields are those of Brands:
name,logo,logoOnDark,colors,font,footerAddressandsocialLinks.logoOnDarkis the logo for dark backgrounds; leave it out, or set it tonull, to clear it, and the pages that use it showlogoinstead. - A key is a lowercase letter, then lowercase letters, digits and hyphens, up to 64 characters. The console asks for one when you create a record, and it cannot change later.
- Slots and variants are in order: their order in the file is their position. The first variant is the main variant. It stays first and active, and a tree cannot make another variant the main one.
- A field you leave out takes its default: no list, schedule, subject pattern, link template, channels, test
groups or slots; the site’s brand;
archive: off; and instant send off. A web-only publication,archive: only, is fixed when it is created and has instant send on.
What an apply does to a publication’s parts:
- A slot you leave out is removed.
- A variant you leave out is deleted. A variant that has been sent cannot be deleted: the apply is refused, and you
set
active: falseon it instead. - A channel, on the publication or on a variant, is never removed: a tree that leaves out a channel the draft has is refused, naming it.
remove: truearchives the publication. Declaring an archived publication again restores it.exportskips archived publications.- A brand or a link template is never removed:
removeon one is refused, since a publication may still name it. - Autopilot never enters the tree.
exportleaves it out and a file that sets it is refused; turn it on in the console.
Like every other record in the draft, a publication’s setup reaches its sends only when you deploy.
Experiences
Section titled “Experiences”experiences.yaml holds each experience’s settings, keyed
<site domain>/<feature>/<outcome id>. Its module is a .js file under experiences/, named by module:
www.example.com/paywall/metered-out: display: { kind: inline, width: bleed } trigger: { kind: delay, seconds: 5 } module: experiences/www.example.com/paywall/metered-out.js
www.example.com/paywall/old-offer: remove: truedisplayismodal,banner(withedge),slide-in(withcorner) orinline(withwidth). A bare kind takes its defaults:display: banneris the bottom edge,slide-inthe bottom right,inlinethe column width.triggerisimmediate,exit-intent,{ kind: delay, seconds }or{ kind: scroll, percent }.moduleis a path underexperiences/, relative to the tree’s folder. Several experiences may name one module. Validation runs the same checks on it as saving in the console. See Write the module yourself.
Ad types
Section titled “Ad types”ad-types.yaml holds your organization’s ad types, one entry
per key. Each has a name and its fields in order, each with a key, a label, a type (image, text,
rich_text, url or content_item) and required, false when you leave it out.
partner-spotlight: name: Partner spotlight fields: - key: logo label: Logo type: image required: true - key: tagline label: Tagline type: text required: true - key: link label: Link type: url required: true - key: feature label: Featured story type: content_item- The ad type’s key, and each field’s key and type, cannot change. An apply that changes a field’s type is refused; add a field under a new key instead. A field can be added, relabelled, reordered or removed.
- EdgeKit’s four ad types are not in the tree. They are fixed, and an entry with one of their keys is refused.
remove: truedeletes an ad type once nothing uses it. The apply is refused while an ad slot takes it or a creative uses it, naming each. A publication in the same tree can stop using it in that apply.- A publication’s ad slot names its ad type in its
props, asadType. The tree’s ad types are written before its publications, so a slot can take an ad type the same tree adds.
Advertisers, ad campaigns and creatives are live records, never part of a tree.
QA and production overlays
Section titled “QA and production overlays”envs/<tier>.yaml holds the few values that differ between your QA and production organizations. Each top-level key
is a tree file path, and its value is what to change in that file:
products.yaml: premium: sites: [qa.example.com]specs/feature/paywall.yaml: enabled: falseObjects merge key by key. Everything else, lists included, replaces the value in the file. Only the overlay for the
--tier you pass is applied; without --tier, none is. export never writes an overlay.
A publication’s Braze ids differ per environment, so they belong in the overlay:
publications/example.com/daily.yaml: channels: email: settings: campaignId: 9e0d… variants: main: channels: email: settings: messageVariationId: 4f2b…An overlay cannot remove a slot or a variant, and one it adds goes last.
JSON Schema
Section titled “JSON Schema”Each file shape has a published JSON Schema, generated from the same definitions the CLI and the console check against:
| File | Schema |
|---|---|
edgekit.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/edgekit.json |
specs/<kind>/<name>.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/spec.json |
products.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/products.json |
offers.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/offers.json |
envs/<tier>.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/env.json |
publications/<site>/<slug>.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/publication.json |
brands.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/brands.json |
link-templates.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/link-templates.json |
ad-types.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/ad-types.json |
experiences.yaml |
https://docs.edgekit.ai/schemas/config-tree/v1/experiences.json |
An editor with YAML language support validates a file as you type when its first line names the schema.
edgekit config export writes that line on every file it writes; give a file you add by hand the same line:
# yaml-language-server: $schema=https://docs.edgekit.ai/schemas/config-tree/v1/spec.jsonpublication.json also names every block a slot can use, the slot kinds each one renders and its props, with each
prop’s title and description. Your editor flags a block EdgeKit does not ship, a block on a slot kind it cannot
render, a missing or unknown prop, and a value of the wrong type or outside its choices. edgekit config validate,
plan and apply refuse the same, and also run each block’s own checks, such as an ad’s URLs, or a byline’s authors
being among its people. The rest is shape only: whether a referenced segment, fact, offer, feed or delivery segment
exists, and whether a template’s props are valid, is checked by the console when you plan or apply.
Credentials
Section titled “Credentials”Every command except validate talks to the console. --tier qa or --tier prod picks your QA or production
console; EDGEKIT_CONSOLE_URL, when set, wins over --tier. The CLI sends the first credential it finds:
CONSOLE_API_KEY: a console API key, for a build. An owner issues it in the console with only the permissions it needs, and an expiry of at most one year. The secret is shown once. Each environment’s key comes from that environment’s console.EDGEKIT_TOKEN: a CLI session token.- The CLI session
edgekit loginstored for the organization named by--tenantoredgekit.yaml.
When the console sits behind a service-token gate, set CF_ACCESS_CLIENT_ID and CF_ACCESS_CLIENT_SECRET; the CLI
sends both on every request.
Applying needs deployment:stage, plus:
feature:writewhen the tree has specs, andcatalog:writewhen it has products or offers.brand:writewhen it has brands, andpublication:configurewhen it has link templates or ad types.experience:writewhen it has experiences.publication:writeandpublication:configurewhen it has a publication: every publication file sets its channels and instant send, if only by leaving them out. Publications that are allremove: trueneed onlypublication:write.
Deploying needs deployment:deploy. A key without deployment:deploy can plan and apply but never ship. Every
write is recorded in your organization’s audit log under the key’s name.
Plan, apply, deploy
Section titled “Plan, apply, deploy”1. Start from the draft
Section titled “1. Start from the draft”edgekit config export --tenant bof --tier prodexport writes the draft into the config folder: one file per spec and per publication, products.yaml,
offers.yaml, brands.yaml, link-templates.yaml and ad-types.yaml, and edgekit.yaml at the root if the repository has none. It
never deletes a file. It lists every tree file the draft did not produce, and every record it left out, such as an
experiment run by an experiment provider or an archived publication.
export writes the Braze ids of the organization you export from into the base files. Export from production, then
put QA’s ids in envs/qa.yaml.
2. Validate
Section titled “2. Validate”edgekit config validatevalidate runs offline. It checks every file against its schema, with the overlay for each tier, and reports each
problem with its file and line:
products.yaml:3: premium.sites: Invalid input: expected array, received stringIt exits non-zero when it finds a problem.
3. Plan
Section titled “3. Plan”edgekit config plan --tier prodplan writes nothing. It sends the tree to the console, which compares it with the draft and stages it as a dry
run. The output is shaped like a pull request body:
- Changes: each declared record the apply would create, update or remove.
- Console edits this overwrites: each change someone made in the console since the tree at
--basewas applied that your tree would undo, with the fields it touches, such asslots.intro.title.--basedefaults to your repository’s default branch, read from git, so a tree merged there is the baseline. A console change your tree already matches is not listed.planonly reports these;applyasks before overwriting them. - Edit leases: declared records someone has open for editing in the console. Any one of them refuses the apply.
- Findings: what the deploy gate reports.
- Diff against the deployed document: every record the deploy would change, with its version move.
- Danger: deploying is one-way; the sites, products and offers the change reaches; and every draft change outside the tree that the stage carries too. Staging freezes the whole draft, so a change someone saved in the console ships with your tree.
- Document hash: the hash to pass to
deploy --expect. Its first 8 characters or more are enough.
For a publication, plan also runs every check a save in the console runs: each Braze id is checked with Braze,
and each variant’s props against its template. A Braze id from your other environment is refused at plan.
--json prints the same content as one JSON object. The exit code is non-zero only when the console refuses the
plan or the command fails.
4. Apply
Section titled “4. Apply”edgekit config apply --tier prod --change-ref https://example.com/issues/42apply writes the tree into the draft in one transaction, then stages it. It is all or nothing: a missing
permission, a live edit lease or an invalid record refuses the whole tree and writes nothing.
If your tree would overwrite changes made in the console since the tree at --base (the same list plan prints),
apply writes nothing until you confirm:
2 console edit(s) made since the base tree would be overwritten:- publication `nwp.dev/daily`: slots.intro.title, variants.main.channels.email.deliverySegment- product `weekly`: nameOverwrite them? This can't be undone. [y/N]Answering yes overwrites exactly those changes. If someone changes another record in the console while you are
deciding, the apply is refused again with the new list. Without a terminal, as in CI, pass --yes to overwrite
them; otherwise apply writes nothing and exits non-zero. To keep a console change, run edgekit config export,
commit the result, and apply on top of it. It prints the plan
again with what it created, updated and removed. --change-ref (up to 200 characters, such as an issue URL) is
recorded with the change in your audit log. A tree that changes nothing writes and stages nothing; it prints a
document hash only when the staged preview already holds the draft.
apply never deploys. The staged preview appears in Delivery › Deployments › Versions like any other.
5. Deploy
Section titled “5. Deploy”edgekit deploy staged --tier prod --expect 8f3c…e1 --change-ref https://example.com/issues/42deploy staged appends the staged preview as the next version, but only if it is still the preview you planned. If
another apply or a console stage replaced it, the deploy is refused and nothing ships; plan again.
edgekit config deploy does the same, reading the organization from edgekit.yaml. It is an alias of
edgekit deploy staged until the CLI’s next major version, and says so when it runs.
Deploy without a config tree
Section titled “Deploy without a config tree”The edgekit deploy commands need no config tree. They act on the organization of the credential: the key in
CONSOLE_API_KEY, else the CLI session for the organization edgekit.yaml names when you run them in its
repository, else the CLI session you selected with edgekit use. In a repository whose organization you have no
session for, they refuse rather than reach another organization you are signed in to.
edgekit deploy diff --tier prodedgekit deploy run --tier prod --expect 8f3c…e1diffstages the draft as a dry run and writes nothing. It prints the document hash, the gate’s findings, the diff against the deployed document, and the sites, products and offers it reaches.stagestages the draft into the preview without deploying it, and prints the preview’s document hash.staged --expect <hash>deploys the staged preview if it still has that hash.run --expect <hash>stages the draft, then deploys it. If the draft moved sincediffprinted the hash,runis refused before it stages anything, so the preview is unchanged. If another stage replaces the preview before the deploy, nothing is deployed.listprints the newest deployments, 10 by default (--limit, at most 200), and the staged preview.
diff and stage need deployment:stage, staged needs deployment:deploy, and run needs both. list needs
no permission: any member of the organization, or any of its keys, can read it. Each command takes --json, which
prints one JSON object.
When the console refuses
Section titled “When the console refuses”| Refusal | Cause | What to do |
|---|---|---|
| Open for editing | Someone has a declared record open in the console. Each one is listed. | Wait until they are done, then apply again. |
| Would overwrite console edits | The tree undoes changes made in the console since --base. Each one is listed. |
Confirm, pass --yes, or export and commit them first. |
| Lacks a permission | The credential is missing a permission the tree needs. Each one is named. | Use a key with those permissions. |
| Not supported yet | The tree has a sites, capabilities, traits, lists or settings file. | Remove the file and manage those records in the console. |
| Invalid tree | A record is malformed or names something that does not exist. | Fix the record the message names. |
| Another organization’s tree | edgekit.yaml names an organization the credential does not belong to. |
Check edgekit.yaml, --tenant and the credential. |
| The preview moved | --expect named a preview or a draft that has since changed. |
Plan or diff again and deploy the new hash. |
With --json, a refusal is printed as one object with a reason field, and the exit code is non-zero.