Skip to content
v2.7

Import and export API

The /_owbase/data/* routes to upload files, analyze, import, export, download and undo, with scopes, credentials, curl examples and errors.

The /_owbase/data/* routes do through the API the same thing as the console wizard: upload the file, analyze, import, export, download and undo. Tasks run in the background; you create the task and poll its progress.

All of them live at https://cloud.owbase.dev/_owbase/data and take JSON (except for uploading the file parts). Integrations written for the earlier Portuguese routes (/_owbase/dados/*) keep working unchanged. The examples use:

Terminal window
export OWBASE_API=https://cloud.owbase.dev
export PROJECT=<PROJECT_ID>
export OWBASE_API_KEY=<API_KEY>

Each request carries the project in the X-Owbase-Project header and a credential:

  • the project’s API key in the X-Owbase-Key header (integrations and server); or
  • the console session (what the console uses).

Before passing the request on, Owbase checks, with its own credential, that it has the route’s scope (table below). Every route also requires tables.read — the scope that only whoever administers the project and API keys have. Without the scope, the response is the usual 401 general_unauthorized_scope.

The console session is valid only for members of the project’s organization. Requests with no credential (only the project ID) and from your app’s users (app session or JWT) are refused with 401 general_unauthorized_scope: the history, the uploaded files and the exports are never within reach of the client app.

Route Scope
GET /limits tables.read
POST /files, PUT /files/<id>, GET /files/<id>/sample, DELETE /files/<id> rows.write
GET /mappings tables.read
PUT /mappings, DELETE /mappings/<id> rows.write
POST /analyses tables.read, rows.read + keys.write
POST /imports tables.read, rows.read, rows.write + keys.write
POST /exports tables.read, rows.read + keys.write
GET /tasks, GET /tasks/<id> rows.read
POST /tasks/<id>/cancel rows.write
POST /tasks/<id>/resume rows.write + the task’s scopes + keys.write
POST /tasks/<id>/undo tables.read, rows.read, rows.write + keys.write
POST /tasks/<id>/links rows.read
GET /download/<token> none (the signed token is the credential)

The task never runs with a platform credential: it runs with a temporary key of your project, created from the credential of whoever made the request, with only the scopes it needs — analysis and export: tables.read and rows.read; import and undo: also rows.write. The temporary key never has more than yours.

With an API key, it needs keys.write in addition to the task’s scopes. Without it, creating the task responds 403 owbase_data_key_scope. One key for everything: tables.read, rows.read, rows.write and keys.write.

How it works with an API key:

  • The task runs with an ephemeral key of up to 1 hour, generated from your key with the task’s scopes. While the task is alive, Owbase generates another one before the previous one expires and swaps it into the running task.
  • For that, your key is kept, encrypted, while the task exists. It never appears in logs or responses, and it’s deleted when the task ends (renewal stops at that moment).
  • Accepted limit: the last ephemeral key stays valid for up to 1 hour after the task ends. An ephemeral key can’t be revoked; it only expires. It’s valid only for this project and only with the task’s scopes.
  • Ephemeral keys don’t appear in API keys.
  • If you delete your key or remove keys.write from it in the middle of the task, renewal fails. When the ephemeral key in use expires, the task stops with the failed state and error.type equal to key. POST /tasks/<id>/resume with another valid key continues from where it stopped.

With the console session, the task uses two ordinary temporary API keys (the task’s and the removal one), which appear in API keys with the Temporary (import/export) badge and an ID like dados-…, and are deleted at the end (details in Temporary keys). The account must be able to create API keys in the project; otherwise, 403 owbase_data_key_scope.

  1. POST /files opens the upload; PUT /files/<id> sends each 5 MiB part. The last part returns what was detected (encoding, separator, header, columns and sample).
  2. POST /analyses with the configuration creates the analysis task. Poll GET /tasks/<id> until it finishes and read the result in analysis.
  3. POST /imports with the analysisId and the relationship decisions creates the import. Poll GET /tasks/<id> until the end.
  4. POST /tasks/<id>/links generates the link for the rejected rows file; GET /download/<token> downloads it.

GET /limits returns the project’s limits and the upload part size:

Terminal window
curl -s "$OWBASE_API/_owbase/data/limits" \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY"
{ "fileBytes": 52428800, "rows": 500000, "concurrent": 1, "retentionDays": 30, "partBytes": 5242880 }
Field What
fileBytes Maximum file size (50 MB; 200 MB on the Scale plan).
rows Rows per import and per export.
concurrent Tasks at the same time in the project (import, export and undo; analysis doesn’t count).
retentionDays Days that files, reports and tasks are kept.
partBytes Size of each upload part (5 MiB).

POST /files with {name, size} (size in bytes). The name’s extension decides the format: .csv, .txt, .tsv or .xlsx. A file over the limit is refused here, before the first byte. Response 201:

{ "$id": "<FILE_ID>", "projectId": "<PROJECT_ID>", "name": "orders.csv", "size": 12582912, "received": 0, "complete": false, "format": "csv", "createdAt": "2026-10-29T13:00:00.000Z" }

PUT /files/<id> with the raw body (content-type: application/octet-stream) and the Content-Range: bytes start-end/total header:

  • end is inclusive and total is the announced size;
  • each part starts at a multiple of 5,242,880 and is exactly 5,242,880 bytes, except the last (whatever is left);
  • parts go in order; a part out of order or with the wrong size → 416 owbase_data_upload_range;
  • resending a part that already arrived whole is accepted (the body is discarded): repeat the one that failed without worry.

Response: 200 {"received": <bytes>} on the middle parts; 201 on the last, with the file and the detection:

{
"file": { "$id": "<FILE_ID>", "name": "orders.csv", "size": 12582912, "received": 12582912, "complete": true, "format": "csv" },
"detection": { "format": "csv", "encoding": "windows-1252", "delimiter": ";", "header": true, "columns": ["code", "amount", "date", "customer"], "sample": [["A1", "1.234,56", "31/12/2025", "[email protected]"]] }
}

For xlsx, detection carries sheets ([{name, hidden}]) and sheet (the chosen one) in place of encoding and delimiter. The sample has the first 20 rows as they were read.

Full upload in bash:

Terminal window
FILE_NAME=orders.csv
SIZE=$(wc -c < "$FILE_NAME" | tr -d ' ')
PART=5242880
FILE_ID=$(curl -s -X POST "$OWBASE_API/_owbase/data/files" \
-H 'content-type: application/json' \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
-d "{\"name\": \"$FILE_NAME\", \"size\": $SIZE}" | jq -r '."$id"')
for ((START = 0; START < SIZE; START += PART)); do
END=$(( START + PART - 1 < SIZE - 1 ? START + PART - 1 : SIZE - 1 ))
tail -c +$((START + 1)) "$FILE_NAME" | head -c $((END - START + 1)) | \
curl -s -X PUT "$OWBASE_API/_owbase/data/files/$FILE_ID" \
-H 'content-type: application/octet-stream' \
-H "content-range: bytes $START-$END/$SIZE" \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
--data-binary @-
echo
done

GET /files/<id>/sample re-reads the start of the file with the query’s options and returns a new detection. Options: format (csv or xlsx), encoding (utf-8, windows-1252, utf-16le, utf-16be), delimiter (,, ;, tab or |, URL-encoded), header (true or false), skipRows (0 to 1,000) and sheet (name).

Terminal window
curl -s -G "$OWBASE_API/_owbase/data/files/$FILE_ID/sample" \
--data-urlencode 'encoding=utf-8' --data-urlencode 'delimiter=;' --data-urlencode 'header=true' \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY"

DELETE /files/<id> → 204. A file that was uploaded and not used in an analysis disappears on its own after 24 hours; the project can have up to 5 of them at the same time.

The analysis receives the configuration (config) and the import uses the same one. In the analysis, only fileId is required: anything missing is filled in with the console’s defaults (reading detected from the file, columns suggested by name, create mode, America/Sao_Paulo time zone, etc.), and the complete configuration comes back in the task (config).

Field Values
fileId The $id of the uploaded file.
readOptions {format, encoding, delimiter, header, skipRows, sheet}: use what came in detection (skipRows is required; 0 if not skipping).
columns List of {target, source, rule, relation}, one per table column that receives a value. target: the column’s key, or $id, $createdAt, $updatedAt. source: {"type": "column", "index": 0} (position of the column in the file, starting at 0) or {"type": "fixed", "value": "text"}. rule (optional): the rule for this column only. relation (relationship column): {"field": "email", "case": "insensitive"}, the field of the related table where the value is looked up ($id by default) and whether the match is case-sensitive: insensitive (default; applies to text fields, $id is always exact) or sensitive.
mode create, update or upsert.
keys Key columns to find the row (outside create), for example ["code"] or ["$id"].
keysCase Optional: sensitive (default) or insensitive case when finding the row by key.
fastUpdate Optional, false by default. true (only outside create and on a table without relationships) writes updates as a batch upsert: rows.*.upsert events instead of update, another person’s edit during the import may be undone and a row deleted during the import may come back.
emptyValues keep (an empty cell doesn’t change the row when updating) or clear.
errors skip (the row goes to the rejected rows) or stop (at the first error).
timeZone IANA time zone for dates with no time zone, such as America/Sao_Paulo.
rule The general conversion rule (table below).
trim true trims the spaces at the ends of each cell.
permissions Optional, only on a table with row security: permissions of the created rows, such as ["read(\"any\")"].

Conversion rule (the general rule or a column’s; the column’s applies on top of the general one, field by field):

Field Values
decimal auto, , or .
dateFormat auto, iso, dd/mm/yyyy, mm/dd/yyyy, yyyy-mm-dd, serial (Excel serial), unix_s or unix_ms. ISO 8601 is accepted in any of them.
trueValues, falseValues Lists of texts that count as yes and no (replace the defaults). "" in falseValues makes an empty cell count as “no”.
enumMap File value → column option, such as {"Paid": "paid", "Open": "open"}.
listSeparator Separator for the items of list columns and of relationships with several rows (up to 5 characters; default ;).
geo Coordinates: json, wkt, lat,lng or lng,lat.
stripApostrophe true removes the leading ' when it comes before =, +, -, @, tab or CR (what the export adds so it doesn’t become a formula); any other leading ', as in '90s, stays.

A configuration with a problem is refused when creating the analysis with 422 owbase_data_mapping_invalid and the problems list ([{field, message}], with field as the path in the configuration, such as columns[3].source or keys[0]).

  • GET /mappings?databaseId=<database>&tableId=<table> → {"mappings": [...]}, each with $id, name, databaseId, tableId, config (without fileId), createdAt, updatedAt and author.
  • PUT /mappings with {databaseId, tableId, name, config} → 200 with the mapping. The same name on the same table replaces the previous one.
  • DELETE /mappings/<id> → 204.

POST /analyses with {databaseId, tableId, config} creates the analysis task and responds 202 with the task (type: "analysis"). The analysis reads the whole file and writes nothing.

analysis.json
{
"databaseId": "store",
"tableId": "orders",
"config": {
"fileId": "<FILE_ID>",
"readOptions": { "format": "csv", "encoding": "windows-1252", "delimiter": ";", "header": true, "skipRows": 0 },
"columns": [
{ "target": "code", "source": { "type": "column", "index": 0 } },
{ "target": "amount", "source": { "type": "column", "index": 1 } },
{ "target": "date", "source": { "type": "column", "index": 2 }, "rule": { "dateFormat": "dd/mm/yyyy" } },
{ "target": "customer", "source": { "type": "column", "index": 3 }, "relation": { "field": "email" } },
{ "target": "channel", "source": { "type": "fixed", "value": "store" } }
],
"mode": "upsert",
"keys": ["code"],
"emptyValues": "keep",
"errors": "skip",
"timeZone": "America/Sao_Paulo",
"rule": { "decimal": "auto", "dateFormat": "auto", "listSeparator": "|", "stripApostrophe": true },
"trim": true
}
}
Terminal window
ANALYSIS_ID=$(curl -s -X POST "$OWBASE_API/_owbase/data/analyses" \
-H 'content-type: application/json' \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
-d @analysis.json | jq -r '."$id"')

When the task finishes (status: "completed"), the result is in analysis:

Field What
rows, valid, withErrors, malformed File counts.
mode {create, update, skipped}: what the import would do.
errors [{type, column, count, examples}], with up to 20 examples ({row, value, message}) per type and column.
relations Per relationship column: column, table, field, distinct, missing, missingExamples (up to 1,000), ambiguous, ambiguousExamples (up to 20, {value, matches}), case (how it matched: insensitive or sensitive), affectedRows, required, many and canCreate ({ok, reason, fixedColumns}: whether the missing ones can be created and which columns of the related table need a fixed value).
rowsWithMissing [{columns, rows}]: rows that would be written but have a missing value, per set of relationships (how many rows the skip decision removes).
keysCase Outside create: how the keys matched (insensitive or sensitive).
preview The first 20 converted rows: {row, values, errors, relations}.
warnings [{type, detail}]: key_without_index, ignored_columns, ambiguous_decimal, ambiguous_date, case_unavailable (matched exactly: the table is too large to match case-insensitively).
estimatedRequests Requests the import is expected to make.
method batch (table without relationships) or transaction (with a relationship).
formats Decimal separator and date format decided per column (the import uses the same ones).

The full list of a relationship’s missing values is a CSV of the analysis task: generate the link with {"file": "missing:<column>"} (Download).

GET /tasks/<id> returns the task. Poll every few seconds while the state isn’t final (the console polls every 1.5 s):

Terminal window
curl -s "$OWBASE_API/_owbase/data/tasks/$ANALYSIS_ID" \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
| jq '{status, progress, error, analysis: (.analysis | {rows, valid, withErrors, mode, relations: [.relations[]? | {column, missing, canCreate}]})}'

Main fields:

{
"$id": "<TASK_ID>",
"type": "import",
"status": "running",
"databaseId": "store",
"tableId": "orders",
"tableName": "Orders",
"author": { "type": "key", "id": "api", "name": "API key" },
"createdAt": "2026-10-29T13:05:00.000Z",
"startedAt": "2026-10-29T13:05:02.000Z",
"progress": { "phase": "writing", "rows": 42000, "totalRows": 120000, "bytes": 4194304, "perSecond": 850, "remainingSeconds": 92 },
"counters": { "created": 30100, "updated": 11500, "skipped": 0, "withErrors": 400, "relatedCreated": { "customers": 3 } },
"requests": 1260,
"files": {}
}
Field What
type analysis, import, export or undo.
status queued, running, canceling, and the final ones completed, completed_with_errors, failed and canceled.
queuePosition While queued: the position among the project’s waiting tasks.
progress phase (reading, related, writing, exporting, restoring, deleting), rows, totalRows, bytes, perSecond, remainingSeconds.
counters Import: created, updated, skipped, withErrors, relatedCreated. Export: exported, truncatedCells. Undo: removed, restored, changedAfter, alreadyDeleted, relatedRemoved, relatedKept.
requests Requests made so far.
error In failed: {type, message} (table below).
files What can be downloaded: rejected, missing, export ({name, size}), undoSkipped.
undoable Import only: {ok: true, created, updated, related, until} (until = deadline to undo) or {ok: false, type, reason}.
undoneBy, undoTaskId, undo.source Link the import to its undo and vice versa.

error.type of a task that failed:

error.type When
key The temporary key was deleted or expired (or your key lost keys.write). Resumable.
stopped_at_error errors: "stop" and a row had an error.
too_many_rows The file went over the project’s row limit.
export_too_large The export went over the row limit (or the xlsx’s 1,048,575 rows); the file has the first ones.
analysis_stale The table’s columns changed since the analysis: run the analysis again.
too_many_values Too many distinct values in a relationship column.
server The database refused or failed (the message says what).
undo_expired, undo_unavailable Undo: the import’s record is gone (7-day deadline) or the import no longer exists.
internal Unexpected failure in the service.

GET /tasks lists the project’s history, newest first: {"tasks": [...], "cursor": "<id>"}. Query filters: type, databaseId, tableId, limit (1 to 100, default 25) and cursor (the one from the previous page, for the next).

POST /imports with {databaseId, tableId, analysisId, decisions} → 202 with the task. The analysis must be completed and for the same table.

decisions has one entry per relationship column with missing values (by the column’s key):

action What it does
create Creates the missing ones in the related table. fixedValues carries a value for each column in canCreate.fixedColumns. Only when canCreate.ok.
skip The rows go to the rejected rows.
empty The row goes in without the relationship (doesn’t apply to a required single-row column).
Terminal window
curl -s -X POST "$OWBASE_API/_owbase/data/imports" \
-H 'content-type: application/json' \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
-d "{\"databaseId\": \"store\", \"tableId\": \"orders\", \"analysisId\": \"$ANALYSIS_ID\",
\"decisions\": {\"customer\": {\"action\": \"create\", \"fixedValues\": {\"name\": \"No name\"}}}}"

A missing or impossible decision → 422 owbase_data_mapping_invalid with problems. Table columns changed since the analysis → 409 owbase_data_analysis_stale.

POST /exports with {databaseId, tableId, export} → 202 with the task.

export field Values
columns Required: column keys in the file’s order; $id, $createdAt and $updatedAt are valid.
queries Filters and order, in the format of queries (the text that Query.equal(...) returns). limit, offset, cursor and select are ignored.
relations Relationship column → exported field of the related table, such as {"customer": "email"} (default $id).
format csv (default) or xlsx.
delimiter CSV: ; (default), , or tab.
decimal CSV: , (default) or ..
listSeparator List items and relationships with several rows (default | with separator ;, otherwise ;).
timeZone Time zone of the dates (default America/Sao_Paulo).
dateFormat iso (default) or dd/mm/yyyy hh:mm:ss.
protectFormulas CSV: ' before text that starts with =, +, -, @ (default true).
permissions true includes each row’s permissions.
Terminal window
curl -s -X POST "$OWBASE_API/_owbase/data/exports" \
-H 'content-type: application/json' \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
-d '{"databaseId": "store", "tableId": "orders", "export": {
"columns": ["$id", "code", "amount", "date", "customer"],
"queries": ["{\"method\":\"equal\",\"attribute\":\"status\",\"values\":[\"paid\"]}", "{\"method\":\"orderDesc\",\"attribute\":\"date\"}"],
"relations": {"customer": "email"},
"format": "xlsx"}}'

The CSV comes out in UTF-8 with BOM and CRLF, ready for Excel. If it goes over the row limit: the task ends failed with error.type export_too_large, and the file, with the first rows, stays available.

POST /tasks/<id>/links with {"file": ...} generates a download link valid for 24 hours:

file Task What
export export The exported file.
rejected import The rows that didn’t get in, with error_line and error_reason (erro_linha and erro_motivo if the task was requested in Portuguese).
missing:<column> analysis All the missing values of the relationship.
undoSkipped undo The rows the undo skipped (rowId, table, reason; tabela and motivo if the task was requested in Portuguese).
Terminal window
curl -s -X POST "$OWBASE_API/_owbase/data/tasks/$EXPORT_ID/links" \
-H 'content-type: application/json' \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY" \
-d '{"file": "export"}'
{ "url": "/_owbase/data/download/<TOKEN>", "token": "<TOKEN>", "expiresAt": "2026-10-30T13:10:00.000Z" }

The url is relative: put the API address in front of it.

Terminal window
curl -s -OJ "$OWBASE_API/_owbase/data/download/<TOKEN>"

GET /download/<token> asks for no credential: whoever has the link downloads until it expires (you can use it in the browser or pass it to another system). After that, 410 owbase_data_link_expired; generate another while the file still exists (per the project’s retention).

  • POST /tasks/<id>/cancel → 200 with the task. If queued, it cancels right away; if running, it becomes canceling and stops after the current chunk. A task that already ended → 409 owbase_data_task_state.
  • POST /tasks/<id>/resume (no body) → 200 with the task back in the queue. Only for a failed task with error.type key; it creates a new temporary key with this request’s credential and continues from where it stopped. Any other situation → 409 owbase_data_task_state.
  • POST /tasks/<id>/undo (no body; <id> is the import) → 202 with the new task type: "undo". Valid for up to 7 days after the import ends, once. The undo joins the same queue as the project’s imports and exports. Before requesting, undoable on the import says whether it’s possible and until when.
Terminal window
curl -s -X POST "$OWBASE_API/_owbase/data/tasks/$IMPORT_ID/undo" \
-H "x-owbase-project: $PROJECT" -H "x-owbase-key: $OWBASE_API_KEY"

In the SDK format ({message, code, type}), with the message in the request’s language (English by default):

type Status When
owbase_data_project_missing 400 The X-Owbase-Project header is missing.
owbase_data_invalid 400 Body or parameter in the wrong format (the message says which).
owbase_data_key_scope 403 With an API key: keys.write is missing. With a session: the account can’t create API keys in the project.
owbase_data_file_not_found 404 The file doesn’t exist in this project, hasn’t finished arriving, or the task has no such file to download.
owbase_data_mapping_not_found 404 The mapping doesn’t exist in this project.
owbase_data_task_not_found 404 The task (or analysis) doesn’t exist in this project or belongs to another table.
owbase_data_task_state 409 The task isn’t in a state that allows the action (analysis not finished, cancelling one that already ended, resuming one that didn’t stop because of the key).
owbase_data_analysis_stale 409 The table’s columns changed since the analysis.
owbase_data_undo_unavailable 409 It can’t be undone: it isn’t an import, still running, already undone, wrote nothing or an undo is already queued.
owbase_data_link_expired 410 The download link expired.
owbase_data_undo_expired 410 The 7 days to undo the import have passed.
owbase_data_file_too_large 413 The file is over the project’s limit.
owbase_data_format_unsupported 415 Format not accepted (.xls, .ods, .xlsm, or the content isn’t of the extension’s format).
owbase_data_upload_range 416 Content-Range missing or wrong, part out of order or with a size different from the announced one.
owbase_data_file_unreadable 422 The file couldn’t be read (corrupted xlsx, reading options that don’t fit).
owbase_data_mapping_invalid 422 Configuration or decisions with a problem; the list comes in problems.
owbase_data_uploads_pending 429 The project already has 5 uploaded and unused files: use or delete one.
owbase_data_queue_full 429 The project already has 20 tasks waiting in the queue.
owbase_data_unavailable 503 The import and export service is down right now. Try again in a moment.
owbase_data_disabled 503 Task creation is paused at the moment; running ones finish.
owbase_data_storage_full 507 No space for new files right now. Try again later.

A missing scope on your credential gives the usual 401 general_unauthorized_scope (errors).

Was this page helpful?