PermuteDocs
Go to Permute

Dashboards · dashboardsSourceUpdate

Update dashboard source

Validates and replaces the complete dashboard TSX source when its dashboard draft revision and data run are unchanged.

PUT/v1/dashboards/{dashboardId}/source
betaapiKeyworkspace

When to use

Replace a dashboard frontend after reading and editing its complete TSX source.

For agents

Requires dashboard write access. The server validates the source and derives its data contract from expectedDataRunId.

Example

typescript
import { PermuteClient } from '@permute/sdk';

const orgClient = new PermuteClient({
  apiKey: process.env.PERMUTE_API_KEY!,
});

const client = orgClient.withWorkspace(process.env.PERMUTE_WORKSPACE_ID!);

const result = await client.dashboards.updateSource('oper_revenue123', {
  "source": "export default function Dashboard({ data }) { return <div>{data.revenue}</div>; }",
  "expectedRevision": {
    "revisionId": "rvsn_dashboard1",
    "sequence": 1
  },
  "expectedDataRunId": "oprn_revenue123"
});

Request body

json
{
  "source": "export default function Dashboard({ data }) { return <div>{data.revenue}</div>; }",
  "expectedRevision": {
    "revisionId": "rvsn_dashboard1",
    "sequence": 1
  },
  "expectedDataRunId": "oprn_revenue123"
}

Response

json
{
  "data": {
    "dashboardId": "oper_revenue123",
    "source": "export default function Dashboard({ data }) { return <div>{data.revenue}</div>; }",
    "revision": {
      "revisionId": "rvsn_dashboard2",
      "sequence": 2
    },
    "dataRunId": "oprn_revenue123"
  }
}