Sending data in with a source

Take rows or documents from another system: a source gives it an address to post JSON, NDJSON or CSV to, and keeps only the fields you choose.

A source sends rows into one of your models, or a plain table, from outside Oalo: your shop's order webhook, a nightly export from another system, a spreadsheet you update. You choose which fields Oalo keeps; anything else the sender sends is dropped before it's stored. Once rows are in, they're like any others: your apps see them at once, bots can search them, and workflows can start on them.

Making one

From a sample of what the sender will send, which proposes the fields and their types and makes the model:

oalo sources create shop_orders --from orders.csv --id-field "Order ID"

or into a model you already have, keeping all its fields or some:

oalo sources create shop_sales --table sales --fields status,total --id-field order_no

or into a plain table: one your app made with its own SQL, or a database import kept as it is. The id field must be one of its unique columns (its primary key, say):

oalo sources create stock --table inventory --id-field sku --fields price,stock

In the dashboard, Data > Sources does the same: make one (from a pasted sample, a table you have, or a bot), see its address, what arrived and its documents, set a fetch, make a new secret, delete it.

The reply shows the source's address and its secret, once. Give both to the sender. oalo sources rotate makes a new secret and stops the old one at once.

  • --id-field: the field that identifies a record. Sending a record again updates its row.
  • --mode snapshot: each upload is the whole set, and rows it leaves out are deleted (an empty upload is refused). Only for a model the source made.
  • --env dev: rows go to your staging copy instead of live (see Dev and prod).
  • --keep-from-ai cost,supplier: these fields are stored and synced, but a bot never hands them to its AI model (see below).
  • --retention 90: rows the source hasn't sent in 90 days are dropped each night (04:30 UTC). Only for a model the source made; rows someone added by hand in Data stay. Change it later with oalo sources retention <name> <days|off>.

Documents into a bot's knowledge

A source can feed a bot's knowledge instead of a table: your help center, policies, a folder of PDFs that changes.

oalo bots                                   # the bots, by public id
oalo sources create handbook --bot bot_ABC

Each upload is one document, by name:

curl -X POST "https://<workspace>.oalo.ai/api/sources/v1/src_...?name=returns.pdf" \
  -H "Authorization: Bearer $SECRET" -H "Content-Type: application/pdf" \
  --data-binary @returns.pdf
  • PDF, Word (.docx), Markdown, HTML and plain text, by the Content-Type or the name's extension. A form upload (curl -F file=@returns.pdf) is named by its file. A tool that sends text can post JSON {"name": "returns", "text": "..."}.
  • The same name again replaces it. DELETE to the address with ?name=returns.pdf removes it, and GET to the address lists the documents, so a script syncing a folder can remove what it no longer has.
  • The same text again changes nothing. A document sent unchanged isn't indexed again, so a sync can send every file every time.
  • Markdown front matter (a --- block at the top, as docs sites use) is read, not indexed as text. title, url and summary open the document, so the bot can name the page and link to it. related lists other documents of the source by name or slug (related: [shipping, returns]): once the bot has a knowledge graph (the bot's Graph tab, Build graph), a question answered from one page also brings in the pages it names.
  • The text is read when it arrives, so a file with no text (a scanned PDF is only images) is refused at once with the reason. Oalo keeps the text as one of the bot's knowledge documents, not the file itself.
  • The bot answers from it once it's indexed, usually within a minute. It's live at once: bots have no draft knowledge.
  • From your machine: oalo sources push handbook docs/*.pdf, and oalo sources remove handbook returns.pdf. oalo sources show handbook lists the documents and their indexing status.
  • To keep the bot in step with a folder, add --prune: oalo sources push handbook docs/*.md --prune also removes each document the folder no longer has. If any file fails, nothing is removed.
  • Each document counts as one row toward the daily cap, and fires source.handbook.received with its name.

Keeping fields from AI

Some fields should reach your apps and workflows but never a model provider: a cost price, a supplier, an internal note. Name them, at creation or later:

oalo data keep-from-ai shop_orders cost,supplier       # add
oalo data keep-from-ai shop_orders                      # the list
oalo data keep-from-ai shop_orders supplier --off       # take one off (--off alone clears)

A field kept from AI:

  • is still stored, synced to your apps, and read by workflow steps;
  • is left out of what a bot's data tools (data_search, data_related, table_search, search) hand its AI model in a chat;
  • can't be embedded. If it's embedded now, vectorize the table again without it first.

Fields you don't want stored at all are simpler: leave them out of the source's fields, and they're dropped on arrival.

How a sender proves it's allowed

--authThe sender sendsFor
bearer (default)Authorization: Bearer <secret>your own code
hmaca header with an HMAC-SHA256 of the raw body, keyed with the secret: --hmac-header (default x-signature), --hmac-format sha256=hex (default), hex or base64tools that sign their webhooks (Shopify, GitHub and the like)
urlnothing: the secret is the address's last parttools that can only send to an address. The weakest: anyone who sees the address can send

The secret only writes. Nobody can read anything back with it.

Sending

POST the source's address with JSON (one object, or an array of them), NDJSON (Content-Type: application/x-ndjson) or CSV with a header row (text/csv):

curl -X POST "https://<workspace>.oalo.ai/api/sources/v1/src_..." \
  -H "Authorization: Bearer $SECRET" -H "Content-Type: application/json" \
  -d '[{"order_no": "1042", "status": "paid", "total": 89.5}]'
  • Field names are snake-cased the way the CSV import does it, so Order ID, order id and order_id are one field.
  • CSV cells take the field's type (numbers, true and false, JSON); JSON values are stored as sent. Into a plain table, Postgres casts each value to its column's type, writes only the columns the record has (the others keep their values), and a value that doesn't fit rejects that record with Postgres's reason.
  • The answer counts what happened: upserted, rejected (with each one's position and why, such as a missing id), deleted (a snapshot), and dropped_fields, the fields you didn't choose.

From your own machine, oalo sources push shop_orders export.csv sends a file over your CLI login instead of the secret, in batches of 1,000.

A webhook that wraps its record

Only top-level fields are fields. Many webhooks send the record inside a wrapper, such as {"event": "delivery.updated", "delivery": {...}}. Read that way, delivery is one field holding the whole object, everything inside it included (a card number, a phone), and --fields can't pick inside it. Name where the record sits instead:

oalo sources create deliveries --from sample.json --records-at delivery --id-field "Delivery ID" --env dev

Each post is then read from delivery (an object there is one record, a list is several), the sample too, so --id-field and --fields name fields inside it and anything else inside is dropped. A post without delivery is refused and says so. Paths go deeper with dots (data.order). When a sample has a field that holds an object, create warns about it.

When the sender can't post: Oalo fetches

For a system that can't call a webhook (an API you read, a published sheet, an export at a fixed address), Oalo fetches it on a schedule:

oalo sources fetch shop_orders https://api.example.com/orders --every 60 \
  --header "Authorization: Bearer $SHOP_KEY" --records-at data.items
oalo sources fetch shop_orders --now        # once, now
oalo sources fetch shop_orders --off        # stop
  • The answer is stored as a post with the same body would be: JSON, NDJSON or CSV by its Content-Type. --records-at data.items takes the records from inside a JSON answer. For a --bot source, the answer is one document (named by --document, else the address's last part).
  • --every is 5 to 10,080 minutes (a week); 60 by default.
  • Headers are sealed on the server; show prints only their names. Repeat --header for more than one (up to 10). Give values through an environment variable so they stay out of your shell history. Left out on a later fetch, the ones set before stay; --header "" clears them.
  • An answer that hasn't changed is skipped, so an hourly fetch of a daily export rewrites nothing.
  • Public https addresses only, up to 3 redirects on the same rule, and 10 MB. Your Base's own addresses, its network and private addresses are refused.
  • show has the last run and its error, if any; the next run tries again. A snapshot source fits a fetch well: each answer is the whole set.

Seeing what arrived

oalo sources show shop_orders lists the last arrivals: when, how the sender proved itself, what was stored, rejected and dropped.

Every arrival fires source.<name>.received, so a workflow can start on it ("when the nightly orders arrive, recompute segments"). Each row also fires the model's own row events when they're on.

From your own database

fetch also takes a postgres:// address: Oalo reads a view (or table) in your database on the same schedule. Write a view of just the columns you share, and give Oalo a user that can only read it:

CREATE VIEW public.orders_for_oalo AS SELECT ref, status, total, updated_at FROM orders;
CREATE ROLE oalo_reader LOGIN PASSWORD '...';
GRANT SELECT ON public.orders_for_oalo TO oalo_reader;
oalo sources fetch db_orders "$ORDERS_DB_URL" --relation public.orders_for_oalo \
  --key ref --cursor updated_at --every 15

In one step, with no sample file: --from-postgres makes the source and its table from the view's own columns, then sets the fetch:

oalo sources create db_orders --from-postgres "$ORDERS_DB_URL" --relation public.orders_for_oalo \
  --key ref --cursor updated_at --every 15 --now

The table gets one field per column (whole numbers, decimals, true/false, JSON and lists keep their type; dates and times become date fields, so a dashboard can count rows by them). The key column becomes each row's id. Without --cursor it's a snapshot: each run reads the whole view and deletes rows it no longer has. Columns named like Oalo's own fields (seqnum, deleted_at, owner_id, availability, product_id, locale) are left out, so rename them in the view (tg_seq, not seqnum). --now reads once right away.

  • It's checked when you set it: Oalo connects and reads the view's columns, and saves nothing until that works.
  • --cursor updated_at: each run reads only rows past the last one it saw, up to 50,000, and the next run carries on. Without a cursor, each run reads the whole view (up to 200,000 rows), so a snapshot source deletes the rows the view no longer has.
  • Safe by default: public addresses only (never your Base's own network), TLS required, a read-only session with a 30-second limit per query, opened for the run and closed after. The address, password included, is sealed; show prints it without the password. Oalo never runs your SQL, only reads the view.
  • Allow Oalo's address through your firewall: every Base connects out from 3.151.137.186. Allow that address on your database's port; the database still needs its own user and password (the address is shared by all Oalo Bases, so it's a second lock, not the only one).

Large files

Over 10 MB, the sender asks for an upload address, puts the file there itself, and says it's done:

POST <address>/uploads          {"name": "stock.csv", "content_type": "text/csv", "size": 48211337}
  -> {"upload_id": "upl_...", "upload_url": "...", "headers": {...}, "complete_url": "...", "status_url": "..."}
PUT  <upload_url>               the file, with the headers given
POST <complete_url>             -> 202
GET  <status_url>               -> {"status": "done", "result": {"records": ..., "upserted": ...}}
  • Each call proves the sender like a send does (a signature covers each call's body; the status call signs an empty one). For a source with its secret in the address, the calls go under that address.
  • Up to 500 MB of CSV or NDJSON (read a line at a time) or a 50 MB JSON array; a document up to 50 MB. The upload address works for an hour.
  • Records go in batches of 10,000 as one upload: a snapshot deletes what the whole file left out, after its last batch. The daily cap applies; a file past it stops there and says how far it got.
  • The file is deleted once it's read.
  • oalo sources push uses this by itself for a document over 10 MB.

Limits

  • Up to 10,000 records and 10 MB a request (larger through an upload, above), 120 requests a minute per source.
  • 200,000 rows a day per workspace (UTC); past it, uploads are refused until midnight. Oalo support can raise it.

Common mistakes

  • A wrapped webhook made without --records-at. The wrapper becomes one field and everything inside it is stored. See "A webhook that wraps its record".
  • Losing the secret. It's shown once; rotate to get a new one.
  • A snapshot from a partial export. Rows missing from it are deleted. Use upsert unless every upload is the whole set.
  • A plain table without a unique id column. A record can't be matched to its row, so creating the source is refused. Add a primary key or a unique index on the column first.
  • Expecting a new field to appear. Fields outside the source's list are dropped, by design. Add the field to the model in Data, then oalo sources fields <name> a,b,new_field; the address and secret stay.
Related
Try it on your own Base

Sign up, install the CLI, and deploy your repo in a few minutes.

bring your repo