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

# validateMetricsResponse

> Checks a metrics response against the metrics the manifest declares and returns what is wrong with it.

```ts theme={null}
function validateMetricsResponse(response, metrics): string[];
```

Checks a metrics response against the metrics the manifest declares and returns
what is wrong with it.

## Parameters

### response

`unknown`

### metrics

`MetricDeclaration`\[]

## Returns

`string`\[]

## Remarks

Returns an empty array when the response is sound, so a test asserts on an empty
list. It reports a body that is not `{ series: [...] }`, an entry with no
`metric` key, a metric the declarations do not name, a unit that disagrees with
the declared one, a missing `points` array, and any point that is not a
`[string, number]` pair. It does not check that every declared metric is
answered, so assert on the length yourself when that matters. The strings are the
ones `tappify extension doctor` reports.

## Example

```ts theme={null}
import { validateMetricsResponse } from '@tappify/extension-sdk/testing';
import { expect, it } from 'vitest';

const metrics = [
  { key: 'orders', label: 'Orders', unit: 'count' as const, kind: 'counter' as const },
];

it('answers orders as a counted series', () => {
  const response = { series: [{ metric: 'orders', unit: 'count', points: [['2026-09-01', 12]] }] };
  expect(validateMetricsResponse(response, metrics)).toEqual([]);
});
```
