Push and Remove
The foir push and foir remove commands manage the lifecycle of your config on the platform. Push creates or updates resources; remove tears them down.
foir push
Reads your config file, sends it to the platform, and creates or updates all declared resources (models, operations, hooks, placements, schedules, segments).
foir pushHow Discovery Works
By default, foir push looks for a config file in the current directory. It checks the following file names in order:
foir.config.tsfoir.config.jsfoir.config.mjsfoir.config.json
The first file found is loaded and pushed.
Specifying a Config File
Use the --config flag to point to a specific file:
foir push --config ./path/to/my-config.tsOverwriting Console Edits
foir push three-way-merges your config against the platform’s current state and the
snapshot of your last push. When a field was changed both in your config and in the
console app, push cannot tell which one you meant, so it stops and reports the conflict.
--force resolves every such conflict in your config’s favour, overwriting the
console edit, and skips the optimistic-lock check that would otherwise reject a
push against a model someone else has since edited:
foir push --forceThe alternative is foir pull to take the platform’s state into your config, then
re-push.
--force is not a way to reset records. It decides who wins a conflict, and one
conflict is about a deletion: on a pruning push, an omitted model that someone edited
in the console since your last push stops the push, and with --force it is deleted,
records and all.
Caution: Renaming a model key is a create plus a delete, not a rename — push matches resources by key and has nothing to infer a rename from. On a pruning push the old key is deleted and its records go with it. A model’s key cannot be changed in the console either, so create the new model, move the content across, and remove the old one deliberately.
What Happens on Push
When you run foir push:
- The CLI loads and validates your config file (must have
keyandnamefields). - It reads any migration decision files from the config directory — your answers to the removed-field questions — and sends them with the push.
- It runs a server-side dry-run preflight. This happens on every push, not only with
--dry-run: the platform is asked what the change would do before it is asked to do it, so a refusal arrives before anything is written. - The bundle is resolved and applied transactionally, family by family.
- Provisioned secrets and API keys are written to your
.env. The project’s signing secret is written only when the credential running the push holdsopsecrets:read. A key without it still applies the push, skips the signing secret and says so. - The CLI prints the resulting config ID and key.
Steps 4 and 5 are the ones to keep in mind when a push fails partway: the bundle applies before the keys are reconciled, so a refusal at the key stage leaves the rest of the config already applied. Fix and re-run.
Loading foir.config.ts...
Pushing config "my-app" to platform...
Config applied successfully.
Config ID: cfg_abc123
Config Key: my-appIdempotent Updates
Pushing the same config multiple times is safe. The platform reconciles the declared state with the current state:
- New resources are created
- Existing resources are updated to match the config
What happens to a resource you remove from the config and push depends on how you authenticated, because that decides the default prune rule:
- An interactive session push (
foir login) treats your config as the desired state. A resource this config owns that is no longer declared is deleted — models, operations, hooks, schedules and segments alike. One production is served leaves the draft now and production with the release that carries the deletion (a push with--publishis that release); declaring it again takes it back. See Deleting a released definition. - An API-key push (
FOIR_API_KEY, the usual CI setup) is additive. Omitted resources are left in place and reported as unchanged.
The split exists because a hand-authored manifest in version control genuinely is the desired state, while a generated one is often written from a partial read — there, omitting something is far more likely to mean “I did not look at that” than “delete it”.
Every push prints which rule it is running under, before the plan. Pass --prune or
--no-prune to decide explicitly, so the config’s meaning is a property of the command
rather than of the credential:
foir push --no-prune # keep omitted resources, even on a session push
foir push --prune # delete omitted resources, even with FOIR_API_KEYA push that deletes anything lists what it will delete and asks you to confirm. Without
a terminal to ask on, as in CI, it stops instead, so pass --allow-delete to let a
pruning push delete without the prompt:
foir push --prune --allow-deleteCaution: Deleting a model takes its records with it once the release carries the deletion, and that cannot be undone by re-declaring the model afterwards. To retire something without losing content, remove it from the console app deliberately, or keep it in the config paused (e.g.
isActive: false/enabled: false) rather than omitting it.
Removing a Field
Removing a field from a model is not the same as removing a model. The field is retained on the schema as deprecated rather than dropped outright, for a 30-day window before a reaper removes it for good. During that window:
- The field still appears in the GraphQL schema, marked
@deprecated, so queries that still select it keep working and keep returning their stored values. - It is not offered on create or update inputs — it accepts no new values.
- Its stored data is protected. Record writes strip any key the model no longer declares, and a deprecated field still counts as declared; that is precisely what keeps the values intact while you migrate them.
This is what makes an expand-and-contract rename possible: add the new field, read both, copy the values across, then remove the old one once nothing depends on it.
You do not have to do that by hand. When a field you removed still holds data, push applies the rest of your change, keeps the field deprecated, and writes a decision file asking what should happen to the values — a rename, a conversion, a deliberate drop. Answer it and push again. See Migrations.
foir push --drop-now--drop-now skips the deprecation window and drops omitted fields immediately.
Caution: Only use
--drop-nowwhen the data has already been dealt with. Without the deprecation window holding the field open, the next ordinary write to each record — an unrelated edit in the console, an API update touching a different field — permanently removes that record’s value for the dropped field, one record at a time, with no error and no report.
Publishing
Schema-shaping resources (models, operations, auth providers), design tokens, hooks, cron schedules and everything a user signs in, signs up or is mailed through (auth clients, roles, the project’s settings and email, email copy, locales, the variant catalog and context dimensions) have a draft and a published channel. Production is served the published copy: an operation dispatches to its published endpoint under its published gates and quotas, a published hook fires, a published schedule runs, and the hosted sign-in offers the released providers under the released signup rules. A push writes drafts, and releases, in its own transaction, only what cannot change the traffic already flowing:
- New models and operations are released as they are created. A brand-new type or mutation can’t break an existing query: nothing writes to a new model or calls a new operation yet.
- A model update that only adds optional fields is released with the push, for the same reason.
- Everything else waits for a release: a breaking model change (dropping, renaming or retyping a field, or moving the model onto an owned plane), a change flagged for review (a new lookup, a different default visibility, a new required field), updated operations and design tokens, new and updated hooks and cron schedules (a new hook would fire on events already flowing, a new schedule would start running), auth providers, auth clients, roles, context dimensions, locales, variant catalog entries, email copy, and the project’s settings and email.
The plan, dry run included, says what the push releases and what waits. What the push released is recorded as a release like any other, attributed to you, so it can be rolled back the same way; after the push it lists what is still waiting for a release at your level.
A model’s configuration waits for the release like its fields do: until it is released, the storefront keeps writing under the published owner plane and default visibility. A manifest that leaves defaultVisibility out keeps the model’s current one, including a visibility set in the console; a project model created without one starts public. Turning a provider off or setting signupMode to closed without --publish leaves the hosted sign-in as it was released; push it with --publish to close sign-up at once.
Pass --publish to release everything the manifest declares in the same step, breaking changes included:
foir push --publishThe release happens on the server, in the same transaction as the push: every definition the config declares whose draft production is not yet served is released, the ones this push changed and the ones an earlier push left as drafts. A push refused for any reason releases nothing. An agent applying the same config with publish gets the same release.
Without it, release the drafts when you are ready with foir release publish, now or --at a time, or from the unpublished list on the home page. (Drafts are visible to a key holding drafts:read that requests the draft channel, which is a preview environment’s own key; see Schema Publishing.)
A model that moves onto an owned plane while some of its records name no owner is held back from every release, --publish included, until a migration file says who owns them. See Migrations.
foir remove
Removes a config and all resources it provisioned (models, operations, hooks, schedules, placements, auth providers, context dimensions), and revokes the API keys it created. The keys go at once. A resource production is served stays there until the release that carries its deletion (foir release publish); until then the config is out of every list, and pushing it again brings it and its resources back.
The keys are revoked rather than deleted, and that is the design: the row stays, carrying a revoked_at, so the audit trail of what that key did survives the teardown. Finding the key still listed after a remove is not an incomplete teardown — check revoked_at rather than checking for absence. A revoked key authenticates nothing.
foir remove <key>Where <key> is the config key (the key field from your foir.config.ts).
Confirmation Prompt
By default, foir remove asks for confirmation before deleting:
? Remove config "My App" (my-app)? This deletes its models, operations, hooks and
schedules and revokes the API keys it created. Any production is served stay there,
records included, until a release carries the deletion. (y/N)Skipping Confirmation
Use the --force flag to skip the confirmation prompt (useful in CI/CD):
foir remove my-app --forceConfig Lifecycle
A typical config lifecycle follows this pattern:
1. Create
Write your foir.config.ts and push it for the first time:
foir pushAll declared resources are created on the platform.
2. Update
Modify your config (add fields, change operations, add hooks) and push again:
foir pushThe platform updates existing resources to match. New resources are created.
3. Iterate
Continue modifying and pushing as your project evolves. Each push is an incremental update.
4. Remove
When you no longer need the config and its resources:
foir remove my-appAll provisioned resources are deleted.
CI/CD Integration
Use foir push in your deployment pipeline to keep platform resources in sync with your codebase:
# .github/workflows/deploy.yml
name: Deploy Config
on:
push:
branches: [main]
paths: ['foir.config.ts']
jobs:
push-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g @foir/cli
- name: Push config
env:
FOIR_API_KEY: ${{ secrets.FOIR_API_KEY }}
run: foir pushAuthentication
Both foir push and foir remove require authentication. Use either:
- Interactive login: Run
foir loginandfoir select-projectfirst - API key: Set the
FOIR_API_KEYenvironment variable
See Using Foir CLI for full authentication details.
Next Steps
- Config System Overview — What you can define in a config
- Configuration Reference — Full config API reference
- Using Foir CLI — CLI installation, authentication, and commands