> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Update saved query

> Replaces one saved APL query.

`axiom.updateSavedQuery` replaces one saved APL query. Include the complete query, metadata, owner, name, and `kind: "apl"`.

```ts automations/axiom-update-saved-query.automation.ts theme={null}
import { automation, onHttpRequest } from "automate.ax"
import { axiom } from "automate.ax/axiom"

export default automation("Update saved query", () => {
  onHttpRequest({ scope: "automation" })
  axiom.updateSavedQuery({
    savedQueryId: "saved-query-id",
    kind: "apl",
    name: "Recent critical errors",
    metadata: {},
    who: "user-id",
    query: {
      apl: "['production'] | where severity == 'critical'",
      startTime: "now-30m",
      endTime: "now",
    },
  })
})
```

## Inputs

`savedQueryId`, `kind: "apl"`, `name`, `who`, `metadata`, and the complete `query` are required. Within `query`, `apl` is required, while `startTime` defaults to `"now-30m"` and `endTime` defaults to `"now"`. Optional cursor, ordering, library, variable, display, and execution settings replace their stored values; `dataset` is optional.

## Output

Returns the complete updated saved query with its Axiom ID.

## Permission and failures

The API token needs the dataset-level `starredQueries|update` capability for the relevant dataset. Axiom rejects missing saved queries, invalid APL or time expressions, and inaccessible dataset references. This replacement mutation is not retried automatically after an ambiguous provider response.
