An export rule sends the files in one or more folders to another app, such as a Google Drive folder or your Xero organization. You create and change rules through the API, run them on the files you choose, and read each file’s outcome. Rules made through the API are the same rules the fileAI app shows under its export settings, so you can manage them in either place.

When to use it

  • You process files through the API and want the results to land in your accounting or storage app without anyone opening fileAI.
  • You set up many folders the same way and want to script their export settings instead of clicking through the app.
  • You need to know, per file, whether an export reached the other app and why it didn’t.

How it works

1

Connect the app in fileAI

The account for each app (your Xero organization, your Google account) is connected once per organization in the fileAI app. The API can’t connect an account, because the app’s own sign-in page has to be shown to a person. GET /v1/export-connections shows which accounts are connected.
2

Create a rule

A rule names the integration, the folders whose files it exports, and the integration’s options: where files go and how they’re written. It can also be limited to one contact or one file type. Each integration publishes the options it takes as a JSON Schema in GET /v1/export-integrations.
3

Export files

With autoExport on, a file in the rule’s folders is exported as soon as it is processed. To export files now, run the rule on them. A run is an async job with an exjob_ id that you poll.
4

Check the outcome

The job lists each file as EXPORTED, FAILED or SKIPPED, with a reason when it isn’t EXPORTED. GET /v1/files/{fileId}/exports shows a file’s latest export, whichever rule or person started it.

Which rule applies to a file

A file is covered by a rule when it is in one of the rule’s folders and matches the rule’s contact and file type. A rule with no contact or no file type matches any. If several rules for the same integration cover a file, the most specific one wins: contact and file type, then contact only, then file type only, then neither. Rules for different integrations all apply, so an invoice can go to Xero through an invoice rule and to Google Drive through a rule for any file type. A folder can’t hold two rules with the same contact and file type, even for different integrations: the second returns 409 CONFLICT. A Wafeq bank statement rule needs a folder of its own.

Endpoints

NetSuite exports are set up through the fileAI connector app, not these endpoints.

Example

Export a processed invoice as JSON into a Google Drive folder. The cURL commands assume FILEAI_BASE_URL="https://api.orion.file.ai/prod/v1", or your regional host.
1

Check the integration and its connection

Find GoogleDrive in the first list and read its optionsSchema: a format of excel or json, and a destination.folderId. The second list must show { "integration": "GoogleDrive", "status": "connected" }. If it doesn’t, connect Google Drive in the fileAI app first.
2

Create the rule

The Drive folder id is the last part of the folder’s link: https://drive.google.com/drive/folders/1AbCdEfGhIjKlMnOpQrStUvWxYz.
The response is the saved rule, with its id. Keep autoExport off while you test; turn it on later with PATCH.
3

Run the rule on a file

4

Poll the job until it settles

COMPLETED means every file has an outcome, not that every file was exported: check each file’s status. external_url links to the exported record when the integration reports one, as Xero does for a bill. Google Drive doesn’t report one.
A file’s latest export stays readable after the job, from any rule or from the app:

Options for each integration

options must match the integration’s optionsSchema: required fields present, values from the allowed lists, and no unknown field names. Each problem comes back as its own item in a 422 response, with a pointer such as #/options/destination/folderId. For Xero and QuickBooks, values such as an account code or tax rate are also checked against the data fileAI has synced from your account, when it has some. The examples below are a starting point for each integration. Values in capitals are placeholders for ids from your own account. optionsSchema lists every field and the allowed values.
Writes each file as Excel (excel) or JSON (json) into a Drive folder. The folder id is the last part of the folder’s link.
A Google Drive or OneDrive folder id is not checked when the rule is saved. A wrong id is only found when a file is exported, and the export fails. Copy the id from the folder’s link.

Change, pause or delete a rule

  • Change. PATCH changes only the fields you send. options, when sent, replaces the saved options as a whole, so send the full set, not just the field you’re changing. The integration can’t change; create a new rule instead.
  • Pause. PATCH with only { "autoExport": false } stops automatic exports. It works even when the integration has been disconnected. Turning it back on runs the same checks as creating a rule.
  • Delete. DELETE stops the rule. As in the app, the rule goes back to being a suggestion the app may offer again. Files already exported are not touched.

Reference

Rule fields

Run statuses

A run’s job (kind: "export") has one of these statuses: Each entry in files has one of these statuses:

Reasons

Errors

See Errors for the response format.

Limits

  • Up to 100 folders per rule and 100 files per run. Repeated ids count once.
  • A run exports a file again even if it was exported before.
  • GET /v1/export-rules returns 50 rules per page by default; a limit above 100 returns 100. See Pagination.
  • A file keeps only its latest export. There is no export history yet.
  • Suggested rules the app hasn’t confirmed are not listed.

Next steps

Async jobs

How export jobs are polled alongside other jobs.

Idempotent requests

Retry a create or run safely with the same key.

MCP tools

Set up and run exports from an AI assistant.

API reference

Every export endpoint, field and response.