Sharing Queries
Sharing turns a saved query into something other people — or other systems — can use without logging into Kvery. Every query has a hash from its creation: a stable identifier that its share link and its API endpoint use.
Enabling sharing
Click the query's Share button in the query list and tick Enable sharing? in the Query sharing window. The query becomes reachable in two complementary ways:
- As a link — open the query's results in the browser via its share URL.
- As a REST API — call the query programmatically at its hash endpoint. See Public Query API.
Both use the same hash, so enabling sharing unlocks both at once. The window shows
the links in its Normal, API (JSON) and Mobile blocks, each with a
Copy to clipboard! button; the Mobile block also has a QR code that opens
the query in the Kvery mobile app. The share link can also be
shown in a frame (<iframe>) on a page of another site. See
Share URLs and embedding for the address formats.
The owner and the editors of the query's group can change its sharing settings, and so can a Manager of that group; a Manager restricted by member tags can do it only for the queries those tags allow. See Members and permissions.
Protecting a shared query
A shared query can be locked down so it is not open to the world. Password protection and Link expiration date appear in the window while Enable sharing? is ticked.
- Password protection — enter a password and click Set password protection to require it for the shared query; empty the field and click the button again to remove it. Useful for links you send to people outside your group. Visitors of a protected link see an Access required page: they enter the password and click Send, and a wrong password shows "Invalid password!". Everyone who can change the sharing settings sees the current password in the window. A query that another shared query opens (a link field or the add button) asks for its own password too, and an import that runs such a query is refused until its password has been entered. Wrong passwords are counted per client address (an IPv6 address counts by its /64 network) and per link: after 20 wrong passwords, every attempt from that address for that link is refused ("Rate limit exceeded. Try again later."), even with the right password, until 5 minutes have passed since the last wrong attempt. An entered password is kept in the browser's session, or in the Kvery mobile app for the device; after you change the password, everyone has to enter the new one.
- Link expiration date — pick a date and time and click Set expiration date; the share stops working automatically at that moment. Without a date the share lasts indefinitely. Ideal for temporary access. Once the date has passed, the link answers like an unknown address: the shared page is empty (HTTP 404), and the API answers HTTP 404 with "Query not found!", also to callers with Basic Auth.
- Custom URL — set your own value instead of the generated hash with Set
custom URL, giving you a cleaner, more memorable URL. It must be at least 3
characters long. Its
path may contain letters, digits,
-,_,/,.,=and$variables(for examplereports/sales-2024,users/$idorv1.2/items/id=$id); a.matches only itself. The path may be followed by?and the URL parameters of the calls, made of letters, digits,-,_,.,=,&,,,%,[,]and$variables(for examplereports/sales?region=$region&year=2024). Only the path identifies the query: callers send the parameters in the query string of their request (…/reports/sales?region=north&year=2024), and they arrive as form variables. Any other value is refused with "The URL must be at least 3 characters long and may contain only letters, digits, "-", "", "/", ".", "=" and $variables, optionally followed by "?" and URL parameters (letters, digits, "-", "", ".", "=", "&", ",", "%", "[", "]" and $variables)!". A custom URL whose path was stored with any other character opens only at exactly that path: one with a method other than All or with$variablesdoes not open, so set such a URL again with the allowed characters. A custom URL must be unique: a URL that another query already answers is refused ("The given URL already exists!"). An empty value is refused too ("URL cannot be empty!"), so a custom URL can be replaced with another one, but not removed. A custom URL always starts with the hash of the query's own group, whichever group you have open. That group hash does not limit a call to the group's queries: when several queries match a call, the one that matches it exactly wins, then a query of the group whose hash the call starts with, then the one whose path has more/-separated parts.
Combine these with the group's IP whitelist, which applies to the shared link, shared dashboards and the API, and with rate limits, which cap how often the API (JSON) endpoint may be called; the shared link page is not rate limited.
Drafts of a shared query
While a query is shared, saving it in the editor keeps the changes to its SQL and
form as a draft: the share link and the API keep running the
published version until you click Publish Draft. An editor of the query who is
signed in can open the draft by adding ?draft to the link. The query's other
settings take effect on the link as soon as you save them.
Form variables in shared queries
If the query has form variables, shared viewers get the same form. When called as an API, those variables are passed as request parameters — see Public Query API.
Turning sharing off
Untick Enable sharing? at any time to revoke the public link and the anonymous API access immediately. The share link then answers with an empty page (HTTP 404). The API endpoint only answers calls authenticated with the Basic Auth credentials of a Kvery user who can access the query (see Public Query API). Turning sharing back on restores the same link with its password, expiry date and custom URL (a link whose expiry date has passed stays closed until you change the date); to give out a different link, set another Custom URL.
Security checklist
- Use a password for anything sensitive.
- Set an expiry for temporary shares.
- Add a group IP whitelist for API endpoints that should only be called from your servers.
- Set a rate limit to cap the calls of the API endpoint.