updateView

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

  • The view's ID (view_…).

Body·

required
application/json

The fields to change. Send queries or queryUpserts/queryRemovals, and renderBundle or bundleEdits, not both.

  • Find-and-replace edits to the current render bundle, applied in order.

    Properties: 3
  • A new description, or null to clear it.

  • The new filters, replacing all of them, or null to remove them.

    Properties: 2
  • The new list of queries, replacing all of them.

    Properties: 2
  • IDs of queries to remove. Each must exist.

  • Queries to add, or to replace the query with the same id.

    Properties: 2
  • A new render bundle, replacing the old one. It must listen for the spondo:data message.

Responses

  • application/json
  • application/json
  • application/json
Request Example for patch/experimental/views/{displayId}
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"
}