Skip to main content

Export automatically on every publish

Repositories, registries and buckets that hold your exported specs fall behind the moment a new version is published. Auto-export keeps them current: subscribe an export preset to a project, and every publish of that project runs the preset's export on the new version and delivers it through the preset's delivery profiles.

Delivery is guarded. Before anything leaves Apiome, the export's loss is measured. When it is too high, the export is halted: nothing is delivered, and the person who published and the person who set up the auto-export are notified. Someone can then release it, or fix the source and publish again.

How much loss halts delivery​

Each export's loss is one of three levels, the same ones its fidelity report uses:

LossWhen
CriticalA severe or near-empty conversion, a types-only result, or any construct lost at critical severity.
WarnAny other loss — a lossy target.
InfoNothing lost.

A subscription halts delivery at critical loss (the default) or at any loss (warn). With a multi-target preset, the worst target decides. To deliver whatever the loss, pre-approve it with Deliver even past it; every run records that it was pre-approved.

Before you start​

  • An export preset, with delivery profiles if the export should be delivered. A preset without any still exports on publish, but has nothing to deliver.
  • The projects:edit and versions:publish permissions to subscribe, switch a subscription on or pre-approve loss — every publish then delivers outside Apiome. Switching one off or removing it needs projects:edit; releasing a halted export needs versions:publish.

Set it up in Export studio​

  1. Open Export studio and select the Presets tab.
  2. On the preset, click Auto-export.
  3. Choose the Project, and under Halt delivery at choose Critical loss or Any loss. Optionally tick Deliver even past it.
  4. Click Run on every publish.
The Auto-export panel for nightly-sync: Orders API halts at critical loss, with one halted run (avro, a severe conversion at 12% preserved) and its Release button, one delivered run, and the form to add another projectThe Auto-export panel for nightly-sync: Orders API halts at critical loss, with one halted run (avro, a severe conversion at 12% preserved) and its Release button, one delivered run, and the form to add another project
Route/ade/dashboard/export/studio?tab=presets

You can also subscribe from an export itself: on Review, tick Auto-export on publish to run the preset you just saved or applied (see Run it on every publish from Review).

The same panel is on each version of the project: View spec on a version shows an Auto-export on publish card next to Recent exports, listing the presets every publish of the project runs (see The version's Export panel).

The panel lists each project the preset runs for, with its recent runs: Delivered, Exported (no delivery profile), Halted with the reason, Delivery failed or Failed. Turn off pauses a subscription, and Remove stops it; past runs keep their record.

When an export is halted​

A halted export is not delivered. The publisher and the person who set up the auto-export get a notification that names the preset, the version and the reason, and links to the Presets tab.

  • Release on the halted run delivers it anyway, through every one of the preset's delivery profiles, as you. It works while the export's download is still kept (24 hours by default).
  • Or fix the source and publish a new version; that publish runs the preset again.

An export that fails outright (the source can't be loaded, the preset's options no longer validate, or the server restarted mid-export) is Failed, and the same people are notified.

Use it from the CLI​

# Run nightly-sync on every publish of orders, halting at any loss
apiome export auto add orders --preset nightly-sync --halt-at warn

# What each publish did, and release a halted export
apiome export auto runs --project orders
apiome export auto release <run id>

apiome export auto also has list, update (--halt-at, --approve-loss/--no-approve-loss, --on/--off) and remove. Every option is in the CLI reference.

Use it from the API​

curl -X POST "$APIOME/v1/export/acme/auto-exports" \
-H "Authorization: Bearer $APIOME_API_KEY" -H "Content-Type: application/json" \
-d '{"projectId": "<project id>", "preset": "nightly-sync", "haltAt": "critical"}'
RouteWhat it does
POST /v1/export/{tenant}/auto-exportsRun a preset on every publish of a project.
GET /v1/export/{tenant}/auto-exportsList subscriptions (?projectId=, ?preset=).
PATCH / DELETE /v1/export/{tenant}/auto-exports/{id}Change haltAt, approveLoss or active, or remove one.
GET /v1/export/{tenant}/auto-export-runsWhat each publish did: status, loss and reasons, deliveries.
POST /v1/export/{tenant}/auto-export-runs/{id}/releaseDeliver a halted export anyway.

A publish never fails because of an auto-export: the exports are queued after the publish answers and run in the background. Every subscription change, halt, delivery and release is recorded in the audit log as export.auto_export.*. Every field is in the auto-export reference.