Update a view
Changes a view, draft or published; send only the fields to change. A published view stays published, so your changes reach your customers straight away. The scope can't be changed, and the period is set with Set a view's period.
Queries: send queries to replace the whole list, or queryUpserts (add a query, or replace the one with the
same id) and queryRemovals (IDs to remove; each must exist), not both. Removals apply first. The result must
still have 1 to 20 queries, and every query is compiled again.
Render bundle: send renderBundle to replace it, or bundleEdits to change it in place, not both. Edits apply in
order; each replaces the first occurrence of oldText (every occurrence with replaceAll) and fails with 400 if
oldText isn't in the bundle. The result must still listen for the spondo:data message and be at most 2 MB.
description and filters can be cleared with null. Answers 400 VALIDATION_ERROR when anything is invalid
(nothing is changed then) and 404 when no view has that ID.
Path Parameters
- Type: stringdisplay
Id requiredThe view's ID (
view_…).
Body·
The fields to change. Send queries or queryUpserts/queryRemovals, and renderBundle or bundleEdits, not both.
- Type:bundle
Edits Properties: 3Find-and-replace edits to the current render bundle, applied in order.
- Type: booleancaps
Enabled - Type: string | nulldescription
A new description, or
nullto clear it. - Type: …5filtersProperties: 2
The new filters, replacing all of them, or
nullto remove them. - Type: booleanhierarchy
Enabled - Type: stringnamemin length:1
- Type: 1…20queriesProperties: 2
The new list of queries, replacing all of them.
- Type: array of stringquery
Removals IDs of queries to remove. Each must exist.
- Type:query
Upserts Properties: 2Queries to add, or to replace the query with the same
id. - Type: stringrender
Bundle min length:1max length:2000000A new render bundle, replacing the old one. It must listen for the
spondo:datamessage.
Responses
- application/json
- application/json
- application/json
curl https://billing.getspondo.com/api/v1/experimental/views/view_3Rk8Tq1Zp6Wn0Ys4 \
--request PATCH \
--header "Authorization: Bearer $SPONDO_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"name": "Documents and contracts",
"queryUpserts": [
{
"id": "by_signal",
"sql": "SELECT signal_name, count(*) AS signals FROM fact_signal WHERE effective_timestamp >= {period_start:DateTime64} AND effective_timestamp < {period_end:DateTime64} GROUP BY signal_name ORDER BY signals DESC"
}
],
"queryRemovals": ["total"],
"bundleEdits": [{ "oldText": "draw(e.data)", "newText": "drawAll(e.data)" }]
}'
{
"hierarchyEnabled": true,
"capsEnabled": false,
"displayId": "view_3Rk8Tq1Zp6Wn0Ys4",
"name": "Documents and contracts",
"status": "PUBLISHED",
"previewUrl": "https://billing.getspondo.com/api/views/5c1e9a7b3d2f4e60_view_3Rk8Tq1Zp6Wn0Ys4/preview",
"scope": "customer"
}