- EmDash
- Reference
- API routes
sources
Stage pasted text, read a sample of your data, and create, fetch and delete the URL sources that imports and schedules read.
Every route here is a POST to /_emdash/api/plugins/fluximporter/<route> with a JSON body, and needs an Administrator. See Before you call the API for authentication, the response envelope and the errors any route can return. Files are uploaded with the upload route.
| Route | What it does | MCP tool |
|---|---|---|
sources/paste |
Stages pasted text like an upload | none |
sources/sample |
Reads the first records of an upload | none |
sources/create |
Saves a source | none |
sources/update |
Renames a source or changes its URL, credential or config | none |
sources/delete |
Deletes a source | none |
sources/get |
Reads a source | none |
sources/list |
Lists sources | none |
sources/fetch |
Fetches a source now | none |
sources/overview |
Lists sources without URLs or credentials | fluximporter__list_sources |
sources/kinds |
Lists the kinds of source installed packages add | none |
A source’s id is 1 to 64 characters from A-Z, a-z, 0-9, _ and -. For how URL sources and credentials work, see URL sources and credentials.
sources/paste
Section titled “sources/paste”POST /_emdash/api/plugins/fluximporter/sources/paste
Stages text as if it were an uploaded file, and answers with its upload ID. The template’s source block decides how it’s parsed, as for a file. The whole body can be at most 1 MiB, so the text must fit in it once JSON-escaped.
| Field | Type | Required | Notes |
|---|---|---|---|
format |
string | yes | csv, json, jsonl or xml. xlsx is refused: a workbook can only be uploaded. |
text |
string | yes | The data, at most 1 MiB of UTF-8. |
Response: { uploadId, bytes, sha256 }, as the upload route answers.
Errors: INVALID_FORMAT (400) for xlsx; EMPTY_BODY (400) for empty or blank text; INVALID_PLUGIN_REQUEST (413) for a body over 1 MiB, which text over 1 MiB always is.
curl -X POST "https://example.com/_emdash/api/plugins/fluximporter/sources/paste" \ -H "Authorization: Bearer $EMDASH_TOKEN" \ -H "Content-Type: application/json" \ -d '{"format":"csv","text":"sku,Name,Price\r\nSKU-1,Desk lamp,24.50\r\n"}'sources/sample
Section titled “sources/sample”POST /_emdash/api/plugins/fluximporter/sources/sample
Reads the first records of an upload, as the wizard’s Source step shows them, so you can see the columns or paths to map.
| Field | Type | Required | Notes |
|---|---|---|---|
uploadId |
string | yes | From the upload route, sources/paste or sources/fetch. |
n |
integer | no | 1 to 20 records. Default 5. |
source |
object | no | The template’s source block: format (default csv), and records, sheet, headerRow and filter where the format takes them. See Template format. |
Response: for CSV, { headers, rows }, the header names and the rows as lists of strings. For JSON, JSON Lines, XML and XLSX, { records, paths }, the parsed records and the paths found in them. XLSX paths are the header names.
{ "success": true, "data": { "headers": ["sku", "Name", "Price"], "rows": [["SKU-1", "Desk lamp", "24.50"], ["SKU-2", "Shelf", "89.00"]] }}Errors: UPLOAD_NOT_FOUND (404); INVALID_SOURCE (400) when the source block is invalid or the data can’t be read, with the reader’s code in details.code for text formats; TOO_LARGE (413) for an XLSX file over its limit.
URL sources
Section titled “URL sources”A URL source is an http or https address, at most 2,048 characters, without a user name or password. Private and loopback addresses are refused, unless allowPrivateNetwork is on in development. A feed that needs a key uses a credential.
A source row has id, name, url, createdAt and updatedAt, and, once set, credential (its name), lastFetch (at, status, etag, lastModified, sha256, bytes, uploadId, and records once an import has read it), lastError (at, code, message) and lastImport (the content and template of the last real import from it).
From version 0.9.0, an HTTP_ERROR in lastError also has the status the server answered, and remote (code, message) when the server named its own error in a JSON body, as Flux Relay does. See The server’s own error.
sources/create
Section titled “sources/create”POST /_emdash/api/plugins/fluximporter/sources/create
| Field | Type | Required | Notes |
|---|---|---|---|
name |
string | yes | 1 to 100 characters, unique among sources. |
url |
string | yes | 1 to 2,048 characters. |
credential |
string | no | The name of a stored header credential. |
For another kind of source, send kind and config instead of url and credential.
Response: the new source row. It isn’t fetched yet.
Errors: URL_BLOCKED (400) for an address that isn’t allowed; CONFLICT (409) when the name is taken; NOT_FOUND (404) when the credential doesn’t exist; VALIDATION_ERROR (400) when the credential is a secret, when url is missing (“A URL source needs a url”) or when a URL source is sent a config (“A URL source takes no config”).
curl -X POST "https://example.com/_emdash/api/plugins/fluximporter/sources/create" \ -H "Authorization: Bearer $EMDASH_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"Supplier feed","url":"https://feeds.example.net/products.json","credential":"supplier-key"}'sources/update
Section titled “sources/update”POST /_emdash/api/plugins/fluximporter/sources/update
Changes a source. Changing its URL or credential clears lastFetch, lastError and lastImport, so the next fetch is a full one and its content counts as new.
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | yes | The source’s ID. |
name |
string | no | 1 to 100 characters, unique. |
url |
string | no | 1 to 2,048 characters. |
credential |
string or null |
no | A header credential’s name; null removes it. |
config |
object | no | From version 0.9.0, for another kind of source only: its whole new config. |
A URL source refuses config, and another kind refuses url and credential, with VALIDATION_ERROR (400). Changing a config clears the fetch history, as changing a URL does.
Response: the source row. When a schedule reads the source and was set up with another URL or credential, the row also has warnings, one string per schedule: that schedule pauses at its next run until it’s enabled again.
Errors: NOT_FOUND (404) for the source or the credential; URL_BLOCKED (400); CONFLICT (409) when the name is taken or the source kept changing.
sources/delete
Section titled “sources/delete”POST /_emdash/api/plugins/fluximporter/sources/delete
Deletes a source and its latest fetched copy, unless a job still reads that copy.
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | yes | The source’s ID. |
Response: { "deleted": true }.
Errors: NOT_FOUND (404); SOURCE_IN_USE (409) when a schedule reads it, with the schedules’ IDs in details.scheduleIds.
sources/get
Section titled “sources/get”POST /_emdash/api/plugins/fluximporter/sources/get
Takes { "id": "…" } and answers with the source row. Errors: NOT_FOUND (404).
sources/list
Section titled “sources/list”POST /_emdash/api/plugins/fluximporter/sources/list
Lists source rows, newest first, 50 a page. Takes an optional cursor (1 to 1,024 characters) and answers with { items, hasMore, cursor? }.
sources/fetch
Section titled “sources/fetch”POST /_emdash/api/plugins/fluximporter/sources/fetch
Fetches a source now and stages the result, as Fetch now does on the Sources tab. By default it sends the last fetch’s ETag and Last-Modified, so an unchanged feed costs no download. A fetch may take up to 15 seconds for the headers and 2 minutes in all, and is limited to maxSourceBytes (50 MiB by default).
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | yes | The source’s ID. |
force |
boolean | no | true fetches in full, without the cached validators. Default false. |
Response: { changed, uploadId, bytes, sha256 }. changed is false when the feed is the same as the last fetch; uploadId then names the copy already stored. A failed fetch is saved as the source’s lastError.
{ "success": true, "data": { "changed": true, "uploadId": "01JDQ9C6A1B2D3E4F5G6H7J8KM9c3e5a7b1d2f4a6c8e0b2d4f6a8c0e2b", "bytes": 52311, "sha256": "a1c3e5f7b9d1f3a5c7e9b1d3f5a7c9e1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3" }}| Code | Status | Meaning |
|---|---|---|
NOT_FOUND |
404 | No source has this ID. |
CREDENTIAL_MISSING |
409 | The source’s credential no longer exists. |
CREDENTIALS_UNAVAILABLE |
500 | Stored credentials can’t be read, usually because EMDASH_ENCRYPTION_KEY isn’t set. |
URL_BLOCKED |
400 | The address, or one it redirects to, isn’t allowed. |
FETCH_FAILED |
502 | The address couldn’t be reached, or it timed out. |
HTTP_ERROR |
502 | The server answered with an error status. |
TOO_MANY_REDIRECTS |
502 | More than 5 redirects. |
LENGTH_REQUIRED |
502 | On Workers, the response has no usable Content-Length and is larger than the 32 MiB Workers can buffer. |
TOO_LARGE |
413 | The feed is over the size limit. |
CONFLICT |
409 | The source was changed or deleted during the fetch. |
sources/overview
Section titled “sources/overview”POST /_emdash/api/plugins/fluximporter/sources/overview · strict · MCP tool fluximporter__list_sources
Lists sources as an agent may see them, newest first, 50 a page: no URL, path or credential. The body can be at most 16 KiB.
| Field | Type | Required | Notes |
|---|---|---|---|
cursor |
string | no | From the previous page. |
Response: { items, hasMore, cursor? }. Each item has id, name, host, credential (true when one is set), createdAt and updatedAt, and, once set, lastFetch (at, status, bytes) and lastError (at, code). From version 0.9.0, a source of another kind also has its kind, with an empty host, and never its config.
Other kinds of source
Section titled “Other kinds of source”From version 0.9.0, a package that wraps the importer, such as Flux Importer Pro, can add kinds of source besides URLs: FTP, SFTP or SQL Server, for example. Such a source’s row has kind and config instead of url and credential. The package checks the config. A password or key is never in it: config.credentials maps each secret the source needs to the name of a stored secret credential.
Fetching, sampling, importing and scheduling work the same for every kind. A source whose package is no longer installed fails with PROVIDER_MISSING (409).
sources/kinds
Section titled “sources/kinds”POST /_emdash/api/plugins/fluximporter/sources/kinds
Takes {} and answers { kinds }, sorted by kind: each installed kind’s kind, label and form (the settings the admin asks for, or null when the kind has no form). The built-in URL kind isn’t listed. On a site without such a package, kinds is empty.