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

# Refresh Materialized View

> This refreshes a materialized view

<Info>
  Minimum required API key scope: `Read`
</Info>

This endpoint refreshes a materialized view, triggering a new execution to update its data.

<Note>
  * By default, the refresh runs on the `medium` engine. To boost performance, pass in a JSON body with `{{"performance": "large"}}`. Credits are consumed based on actual compute resources used for the refresh operation.
  * If you prefer `medium` performance, you can omit the `performance` parameter.
  * You must own the materialized view to refresh it.
</Note>

## Path Parameters

<ParamField path="name" type="string" required>
  The name of the materialized view to refresh
</ParamField>

## Request Body

<ParamField body="performance" type="string">
  Performance level of the refresh. Available options: `medium`, `large`. Defaults to `medium`.

  * `medium`: Extended timeout, 1x compute, priority queue. Best for most queries.
  * `large`: Extended timeout, 2x compute, priority queue. For complex queries.
</ParamField>

## Response

<ResponseField name="execution_id" type="string">
  Unique identifier for the execution triggered to refresh the materialized view

  Example: `01HZ065JVE23C23FM2HKWQP2RT`
</ResponseField>

<ResponseField name="sql_id" type="string">
  Unique identifier for the materialized view

  Example: `dune.dune.result_erc_20_token_summary`
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.dune.com/api/v1/materialized-views/my_matview/refresh" \
    -H "X-Dune-Api-Key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "performance": "medium"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.dune.com/api/v1/materialized-views/my_matview/refresh"
  headers = {
      "X-Dune-Api-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  data = {
      "performance": "medium"
  }

  response = requests.post(url, headers=headers, json=data)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.dune.com/api/v1/materialized-views/my_matview/refresh',
    {
      method: 'POST',
      headers: {
        'X-Dune-Api-Key': 'YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        performance: 'medium'
      })
    }
  );

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "execution_id": "01HZ065JVE23C23FM2HKWQP2RT",
    "sql_id": "dune.dune.result_erc_20_token_summary"
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "Bad Request"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": "Invalid API Key"
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "error": "Object not found"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": "Internal error"
  }
  ```
</ResponseExample>

## Notes

* Refreshing a materialized view triggers a query execution to update the view with the latest data
* Use the returned `execution_id` to check the status of the refresh operation
* Credits are consumed based on actual compute resources used, the performance tier selected, and the amount of data written (e.g., table creation and data insertion)


## OpenAPI

````yaml POST /v1/materialized-views/{name}/refresh
openapi: 3.0.1
info:
  contact: {}
  description: Dune API
  title: DuneAPI
  version: '1.0'
servers:
  - url: https://api.dune.com/api
security: []
paths:
  /v1/materialized-views/{name}/refresh:
    post:
      summary: This refreshes a materialized view
      description: This refreshes a materialized view
      parameters:
        - description: Matview Name
          in: path
          name: name
          required: true
          schema:
            type: string
        - description: API Key for the service
          in: header
          name: X-Dune-Api-Key
          required: true
          schema:
            type: string
        - description: API Key, alternative to using the HTTP header X-Dune-Api-Key
          in: query
          name: api_key
          schema:
            type: string
      requestBody:
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/matviews.MatviewsRefreshRequest'
        description: MatviewsRefreshRequest
        x-originalParamName: body
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/matviews.MatviewsRefreshResponse'
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.Error400'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.Error401'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.Error404'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.Error500'
          description: Internal Server Error
components:
  schemas:
    matviews.MatviewsRefreshRequest:
      properties:
        performance:
          description: >-
            Performance tier for the refresh execution. Accepts `small`,
            `medium`, `large`.

            Omit to use the default tier for the source query's engine.
          type: string
      type: object
    matviews.MatviewsRefreshResponse:
      properties:
        execution_id:
          description: >-
            Unique identifier for the execution triggered to refresh the
            materialized view
          example: 01HZ065JVE23C23FM2HKWQP2RT
          type: string
        sql_id:
          description: Unique identifier for the materialized view
          example: dune.dune.result_erc_20_token_summary
          type: string
      type: object
    models.Error400:
      properties:
        error:
          example: Bad Request
          type: string
      type: object
    models.Error401:
      properties:
        error:
          example: Invalid API Key
          type: string
      type: object
    models.Error404:
      properties:
        error:
          example: Object not found
          type: string
      type: object
    models.Error500:
      properties:
        error:
          example: Internal error
          type: string
      type: object

````