---
title: "Enable `pg_stat_statements` on a standalone Postgres service."
method: POST
path: "/external-services/{service_id}/pg-stat-statements/enable"
tags: ["External Services"]
---

# Enable \`pg_stat_statements\` on a standalone Postgres service.

`POST /external-services/{service_id}/pg-stat-statements/enable`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/external-services/{service_id}/pg-stat-statements/enable`
- Auth: HTTP bearer

Stops the container and restarts it so that the
`shared_preload_libraries=pg_stat_statements` CMD flag (baked into every
new standalone Postgres container) takes effect. The named data volume is
reused unchanged — no data is lost.

**Clustered (HA) services are rejected** with 422 — a blind single-container
restart bypasses controlled failover. For clustered services the response
body describes the manual rolling-restart steps.

Confirmation is the caller's responsibility (UI dialog / CLI `--yes` flag)
before invoking this endpoint.

## Path parameters

- `service_id` integer, required

## Response `200`

Container restarted; pg_stat_statements now active

- EnablePgStatStatementsResponse: Response for the enable pg_stat_statements endpoint.
  - `message` string, required: Human-readable message confirming the action.

## Other responses

- `401`: Unauthorized
- `403`: Insufficient permissions (requires external_services:write)
- `404`: Service not found
- `422`: Service is not standalone Postgres (cluster or wrong type)
- `500`: Restart failed

## Changes

- **2026-07-31** `00b2fffe41df`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/external-services/:service_id/pg-stat-statements/enable/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
