# Health (https://dev.cosmospay.lat/docs/api/health/)

> Liveness and readiness probes.

Base URL: `https://api.cosmospay.lat/cosmos-api`

## Liveness probe

`GET /v1/health/liveness`

Answers `{ "status": "ok" }` while the process is up, without checking any dependency, the database included. Public: no API key, for the orchestrator to probe directly.

No authentication.

**Responses**

- `200` (`object`): The process is up. It says nothing about the database.
  - `status` (string, optional)
- `500`: InternalError (see Shared responses)

## Readiness probe (checks the database)

`GET /v1/health/readiness`

Pings Postgres: 200 with the indicator report when it answers, `503 provider_unavailable` when it does not, with a body that names no host or cause (those are only logged). Public: no API key, for the orchestrator to probe directly.

No authentication.

**Responses**

- `200` (`object`): Every indicator is up; the service can take traffic.
  - `status` (string, optional)
  - `info` (object, optional)
  - `error` (object, optional)
  - `details` (object, optional)
- `500`: InternalError (see Shared responses)
- `503` (`ApiErrorBodyEntity`): An indicator is down: today that means Postgres did not answer the ping. Which one, and why, is logged; the body says only that the service is not ready, because this route is served without credentials and the indicator report names internal hosts.
  - `statusCode` (number, required): Always the HTTP status of the response itself.
  - `code` (string, required): Stable machine-readable code. Branch on this, never on the message: messages are human-facing and may be reworded; codes are never renamed once published. Each response documents the subset it can return. One of: `insufficient_scope`, `no_authenticated_consumer`, `gateway_required`, `admin_console_only`, `not_found`, `validation_failed`, `payload_too_large`, `idempotency_conflict`, `operation_in_flight`, `invalid_state_transition`, `slippage_exceeded`, `insufficient_balance`, `no_path_found`, `trustline_missing`, `invalid_amount`, `invalid_memo`, `transaction_rejected`, `transaction_already_settled`, `recipient_not_registered`, `payment_transfer_mismatch`, `fee_transfer_mismatch`, `merchant_fee_transfer_mismatch`, `payer_mismatch`, `transaction_not_found`, `expired`, `network_unsupported`, `asset_unsupported`, `merchant_fee_unsupported`, `provider_error`, `provider_unavailable`, `quote_not_found`, `quote_expired`, `kyc_state_invalid`, `kyc_review_required`, `account_disabled`, `payload_expired`, `rate_limited`, `customer_wallet_taken`, `alias_taken`, `alias_name_invalid`, `alias_challenge_invalid`, `alias_signature_invalid`, `alias_recovery_invalid`, `alias_address_conflict`, `wallet_handshake_invalid`, `wallet_verifier_invalid`, `wallet_login_code_invalid`, `wallet_login_code_cooldown`, `wallet_session_invalid`, `wallet_signature_invalid`, `wallet_backup_invalid`, `wallet_backup_limit`, `wallet_account_mismatch`, `wallet_provider_unavailable`, `wallet_return_url_not_allowed`, `wallet_recovery_setup_refused`, `easy_recovery_not_found`, `easy_recovery_already_offered`, `easy_recovery_not_offered`, `easy_recovery_code_invalid`, `easy_recovery_burned`, `plugin_not_installed`, `plugin_consent_mismatch`, `plugin_rejected`, `plugin_quota_exceeded`, `plugin_failed`, `protected_payment_buyer_mismatch`, `protected_payment_signature_invalid`, `misconfigured`, `internal_error`.
  - `error` (string, required): The HTTP reason phrase for `statusCode`.
  - `message` (string | string[], required): Human-readable detail. An array when class-validator rejected the body.
  - `details` (object, optional): Machine-readable facts about this failure, present only on the codes whose example shows it: `easy_recovery_code_invalid` carries `{ "attemptsLeft": 4 }`. Absent everywhere else.
  - `path` (string, required): The path of the request that failed.
  - `timestamp` (string, required): When the envelope was produced, ISO 8601.

## Shared responses

- **InternalError** (`ApiErrorBodyEntity`): Unexpected server error. The detail is logged server-side and never returned: there is nothing in the body to branch on beyond the code.
