Skip to content

Mint a new Prometheus scrape token

POST
/api/integrations/prometheus-tokens

Generates a new bearer scrape token for the Prometheus exposition endpoint. The cleartext token value is returned EXACTLY ONCE in the response token field — it is never recoverable. Database stores only the SHA-256 hex of the token.

Token format: dpiprom_<base64url-32-bytes>. The dpiprom_ prefix is intended for leak detection (GitHub secret scanning, grep audits).

Admin role required (D-24). Only admins mint scrape tokens; the tokens themselves confer viewer-tier read access to the Prometheus endpoint and nothing else.

Audit event scrape_token_created is emitted on success.

Parameters for minting a new Prometheus scrape token.

object
name
required

Operator-facing label for the token (e.g. “Production Prometheus”).

string
>= 1 characters <= 200 characters
expires_at

Optional expiry. Omit the field (or send an empty zero-time) for no expiry. When set, the token is rejected after this instant (PrometheusScrapeAuth checks expires_at on every scrape).

string format: date-time

Token created. The cleartext token value is returned ONCE.

Newly minted Prometheus scrape token. The token field carries the cleartext value and is returned exactly once. Store it now — the database keeps only the SHA-256 hash.

object
id
required

Token row id.

integer format: int64
name
required

Operator-facing label.

string
token
required

Cleartext token value. Returned ONCE here, never again. Format dpiprom_<base64url-32-bytes>. Use as the bearer in the Authorization header against /api/metrics/prometheus.

string
created_at
required

Token creation timestamp.

string format: date-time
expires_at

Optional expiry. Field is omitted when the token has no expiry.

string format: date-time

The request body or parameters failed validation.

Standardised error envelope per RFC 7807. Many existing endpoints still return an older shape (e.g. {"error": "..."}). This schema documents the target shape; legacy endpoints will be migrated in Phase 70. Per D-21 the spec describes current behaviour without enforcing the migration here.

object
type

A URI reference that identifies the problem type.

string format: uri-reference
default: about:blank
title

A short human-readable summary of the problem.

string
status

The HTTP status code generated by the origin server.

integer format: int32
>= 100 <= 599
detail

A human-readable explanation specific to this occurrence.

string
instance

A URI reference that identifies the specific occurrence.

string format: uri-reference
error

Legacy error message field. Will be removed once handlers are migrated.

string
details

Legacy per-field error details. Will be removed once handlers are migrated.

object
key
additional properties
string
requestId

The request id middleware-assigned identifier for tracing.

string

Authentication is required or the supplied token is invalid.

Standardised error envelope per RFC 7807. Many existing endpoints still return an older shape (e.g. {"error": "..."}). This schema documents the target shape; legacy endpoints will be migrated in Phase 70. Per D-21 the spec describes current behaviour without enforcing the migration here.

object
type

A URI reference that identifies the problem type.

string format: uri-reference
default: about:blank
title

A short human-readable summary of the problem.

string
status

The HTTP status code generated by the origin server.

integer format: int32
>= 100 <= 599
detail

A human-readable explanation specific to this occurrence.

string
instance

A URI reference that identifies the specific occurrence.

string format: uri-reference
error

Legacy error message field. Will be removed once handlers are migrated.

string
details

Legacy per-field error details. Will be removed once handlers are migrated.

object
key
additional properties
string
requestId

The request id middleware-assigned identifier for tracing.

string

Forbidden — admin role required.

Standardised error envelope per RFC 7807. Many existing endpoints still return an older shape (e.g. {"error": "..."}). This schema documents the target shape; legacy endpoints will be migrated in Phase 70. Per D-21 the spec describes current behaviour without enforcing the migration here.

object
type

A URI reference that identifies the problem type.

string format: uri-reference
default: about:blank
title

A short human-readable summary of the problem.

string
status

The HTTP status code generated by the origin server.

integer format: int32
>= 100 <= 599
detail

A human-readable explanation specific to this occurrence.

string
instance

A URI reference that identifies the specific occurrence.

string format: uri-reference
error

Legacy error message field. Will be removed once handlers are migrated.

string
details

Legacy per-field error details. Will be removed once handlers are migrated.

object
key
additional properties
string
requestId

The request id middleware-assigned identifier for tracing.

string

Internal server error

Standardised error envelope per RFC 7807. Many existing endpoints still return an older shape (e.g. {"error": "..."}). This schema documents the target shape; legacy endpoints will be migrated in Phase 70. Per D-21 the spec describes current behaviour without enforcing the migration here.

object
type

A URI reference that identifies the problem type.

string format: uri-reference
default: about:blank
title

A short human-readable summary of the problem.

string
status

The HTTP status code generated by the origin server.

integer format: int32
>= 100 <= 599
detail

A human-readable explanation specific to this occurrence.

string
instance

A URI reference that identifies the specific occurrence.

string format: uri-reference
error

Legacy error message field. Will be removed once handlers are migrated.

string
details

Legacy per-field error details. Will be removed once handlers are migrated.

object
key
additional properties
string
requestId

The request id middleware-assigned identifier for tracing.

string