﻿---
title: Write Scout API tests
description: Scout API tests validate HTTP endpoints with realistic scoped credentials. Prepare with higher-privilege helpers (apiServices, kbnClient, esArchiver,...
url: https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/write-api-tests
products:
  - Kibana
---

# Write Scout API tests
Scout API tests validate HTTP endpoints with realistic scoped credentials.
<important>
  [Set up your plugin or package](https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/setup-plugin) first.
</important>


## Recommended structure

1. **Prepare** with higher-privilege helpers (`apiServices`, `kbnClient`, `esArchiver`, …)
2. **Authenticate** with `requestAuth` (or `samlAuth` for `internal/*`)
3. **Call the endpoint under test** with `apiClient` + the scoped headers
4. **Assert** status + response body, and verify side effects when needed

See [best practices for API tests](/elastic/docs-builder/docs/2763/extend/kibana/scout/best-practices#api-tests).
Example test ([Console](https://github.com/elastic/kibana/blob/main/src/platform/plugins/shared/console/test/scout/api/tests/spec_definitions.spec.ts)).

## Save the test file

API tests live under `<plugin-root>/test/scout/api/tests` and must end with `.spec.ts`.

## Next steps

- [API authentication](https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/api-auth)
- [Best practices](https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/best-practices)
- [Fixtures](https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/fixtures)
- [Run tests](https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/run-tests) and [Debugging](https://www.elastic.co/elastic/docs-builder/docs/2763/extend/kibana/scout/debugging)
- [Parallelism notes](/elastic/docs-builder/docs/2763/extend/kibana/scout/parallelism#api-tests-and-parallelism)