---
title: "POST /api/testing/api-keys/seed-usage"
method: POST
path: "/api/testing/api-keys/seed-usage"
tags: ["/api/testing"]
---

# POST /api/testing/api-keys/seed-usage

`POST /api/testing/api-keys/seed-usage`

## Request

- Base URL: `` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/testing/api-keys/seed-usage`
- Auth: API key in header `X-API-Key`

Record one completed API-key-authenticated request so the API-key usage E2E page has a visible
  row, then force an immediate flush of the usage-log and last_used_at batches (both normally
  flushed on a scheduled interval) so the row is queryable without waiting. Routes through the
  production `metabase.api-keys.usage/record-api-key-usage!` path (rather than a hand-rolled insert)
  so the seeded row can't drift from real writes. Intended only for E2E tests.

## Request body

- object
  - `api_key_id` integer, required: value must be an integer greater than zero.
  - `created_by_id` integer, required: value must be an integer greater than zero.
  - `duration_ms` integer, nullable: value must be an integer greater or equal to than zero.
  - `route_template` string, nullable: value must be a non-blank string.
  - `status` integer, nullable
  - `user_id` integer, required: value must be an integer greater than zero.

## Response `2XX`

Successful response

- object
  - `inserted` integer, required

## Other responses

- `4XX`: Client error response
- `5XX`: Server error response

## Changes

- **2026-11-04** `2e178f5a7934`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/metabase/apis/metabase-api/changes/api/testing/api-keys/seed-usage/post.md)

---

[API](https://skmtc.dev/metabase/apis/metabase-api.md) - [All operations](https://skmtc.dev/metabase/apis/metabase-api/llms.txt) - [OpenAPI document](https://skmtc.dev/metabase/apis/metabase-api/revisions/2e178f5a7934?raw)
