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

# Secure deployment

> How to run Parmana so that API endpoints are protected: HTTPS, keys, network placement, downstream systems, approvals and what is still your responsibility.

The API checks each action against your rules and signs the record. It can only protect what passes through it. This page
lists what to set and what to put around it, so that the API is the only way to change the systems it protects.

> [!WARNING]
>
> The local setup in `docker-compose.yml` is for one machine, published on
> `127.0.0.1` only. Do not use it as a production template without the steps
> below.

## Checklist before go-live

| Item | Required setting or action |
| - | - |
| HTTPS only | `PARMANA_REQUIRE_HTTPS=true` (the server default). TLS terminated at one reverse proxy in front of the API. |
| Keys | One API key per calling system, stored in a secrets manager. Only hashes on the server. |
| Network | Only the reverse proxy can reach the API. The database is not reachable from outside the private network. |
| Downstream systems | Each system accepts changes only from Parmana's own credentials and network path. |
| Approvers | Named people, separate from anyone who requests actions, with a written revocation procedure. |
| Multiple API instances | Shared Postgres rate-limit store, so limits apply across all instances. |
| Verification | Records checked regularly with the offline verifier. |

## 1. Serve HTTPS only

Set `PARMANA_REQUIRE_HTTPS=true`, or leave it unset. The API then returns `403` for any request that did not arrive over HTTPS,
except `GET /health` and `GET /ready`, which stay open for internal monitoring.

* Terminate TLS at one reverse proxy. The API trusts exactly one proxy hop.
* The proxy must **overwrite** `X-Forwarded-For` and `X-Forwarded-Proto` on every request, so that a client cannot send its own values.
* Use a current TLS configuration and redirect plain HTTP to HTTPS at the proxy.

Local development runs over `http://127.0.0.1`. Set `PARMANA_REQUIRE_HTTPS=false` there, and only there.

### Response headers

Every response carries these headers:

| Header | Value | Why |
| - | - | - |
| `X-Content-Type-Options` | `nosniff` | Stops browsers guessing a response's type. |
| `X-Frame-Options` | `DENY` | Stops the API being shown inside another site. |
| `Referrer-Policy` | `no-referrer` | Stops URLs leaking to other sites. |
| `Strict-Transport-Security` | `max-age=31536000; includeSubDomains` | Tells browsers to use HTTPS only. |
| `Content-Security-Policy` | `default-src 'none'; frame-ancestors 'none'` | Set on JSON responses. The HTML reference pages at `/documentation` and `/reference` are exempt, because they load their own scripts and styles. |

The server does not send the `X-Powered-By` header.

## 2. Manage API keys

* Each calling system gets its own key, with only the capabilities it needs. See [Manage API keys](https://docs.parmanasystems.com/self-hosted/api-keys.md).
* The server stores only the SHA-256 hash of each key. Keep the raw keys in a secrets manager, never in source control or in an image.
* Rotate keys on a schedule and when someone leaves. To rotate, add the new key, move the caller over, then remove the old one with `--keep-newest`.
* Use separate keys for production and test. A test key must not be able to reach production systems.

## 3. Control the network

* Put the API and the database on a private network. The only public entry point is the reverse proxy.
* Restrict the database to the API's address. Do not publish its port.
* Restrict access to the host itself: named administrators only, with logging, and patched regularly.
* Software running on the same host can read the server's environment and keys. Treat the host as part of the trust boundary.

## 4. Close the direct-call gap

Parmana only checks actions sent to it. An agent or application that holds its own credentials for a system can still change that
system directly, with no check and no record. You close this in your infrastructure, not in Parmana:

* **Hold the credentials in one place.** Give downstream systems credentials that only the Parmana gateway holds. Remove standing access for AI tools and applications.
* **Restrict paths at the network.** Allow the downstream system to accept writes only from Parmana's network address.
* **Reconcile regularly.** Compare the changes made in each downstream system with the Parmana records. Any change without a matching record is a bypass to investigate.

## 5. Run approvals as a process

Parmana checks that a trusted approver key signed an approval. It cannot check that the person read the request. Until your approver
rules are built into the product, write them down and enforce them:

* Name the people who may approve, and keep approver keys separate from anyone who requests actions.
* Approvers review the full request in your own system before signing, not just the summary.
* Keep a written procedure to revoke an approver key the day someone leaves or changes role.
* Review the list of approvers and approvals regularly.

## 6. Run more than one instance

When more than one API instance runs, set up the Postgres rate-limit store. Without it, each instance counts separately, so the real
limit is the configured limit multiplied by the number of instances.

## 7. Check the records

* Export audit events and signed records to storage you control.
* Verify a sample of records regularly with the [offline verifier](https://docs.parmanasystems.com/self-hosted/offline-verification.md). A verifier needs only the public keys you trust.
* Keep the public key set and its history, so that old records can still be checked after a key rotation.

## 8. Check your setup

Replace `api.example.com` with your domain and the key with a real key for that system.

```bash theme={null}
# Plain HTTP must be refused (expect 403 with "https required")
curl -s -o /dev/null -w '%{http_code}\n' http://api.example.com/callers/me

# HTTPS with a key must work
curl -s https://api.example.com/callers/me -H "Authorization: Bearer $PARMANA_API_KEY"

# Without a key must be refused (expect 401)
curl -s -o /dev/null -w '%{http_code}\n' https://api.example.com/callers/me

# Security headers are present
curl -sI https://api.example.com/health | grep -iE 'strict-transport|x-content-type|x-frame|referrer-policy'
```

## What remains your responsibility

* Operating the proxy, certificates, network rules and host security.
* Who holds approver and API keys, and how they are issued and revoked.
* Downstream systems that accept changes only from Parmana.
* Your own legal and regulatory obligations. Parmana does not provide compliance certification.

See [Limitations](https://docs.parmanasystems.com/security/limitations.md) for what Parmana does not claim.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.