---
title: "Create a new query patterns report"
method: POST
path: "/organizations/{organization}/databases/{database}/branches/{branch}/query-patterns"
tags: ["Query Insights reports"]
---

# Create a new query patterns report

`POST /organizations/{organization}/databases/{database}/branches/{branch}/query-patterns`

### Authorization
A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:

**Service Token Accesses**
 `read_branch`

**OAuth Scopes**

 | Resource | Scopes |
| :------- | :---------- |
| Organization | `read_branches` |
| Database | `read_branches` |
| Branch | `read_branch` |

## Path parameters

- `organization` string, required
- `database` string, required
- `branch` string, required

## Response `201`

The created query patterns download

- object
  - `id` string, required — The ID of the query patterns download
  - `state` 'pending' | 'completed' | 'failed', required — The state of the download
  - `created_at` string, required — When the download was created
  - `finished_at` string, nullable, required — When the download was finished
  - `url` string, required — The URL to access the query patterns download
  - `download_url` string, required — The URL to download the query patterns file
  - `actor` object, required
    - `id` string, required — The ID of the actor
    - `display_name` string, required — The name of the actor
    - `avatar_url` string, required — The URL of the actor's avatar

## Other responses

- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `500` — Internal Server Error

## Changes

- **2026-06-01** `72506953f367` — 1 breaking
  - the response property `finished_at` became nullable for the status `201`

[Change history](https://skmtc.dev/planetscale/apis/planetscale-api/changes/organizations/:organization/databases/:database/branches/:branch/query-patterns/post.md)

---

[API](https://skmtc.dev/planetscale/apis/planetscale-api.md) · [All operations](https://skmtc.dev/planetscale/apis/planetscale-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/planetscale/planetscale-api/revisions/6d28c038c4fd/schema)
