# Services API reference

> Public URLs for what you run on Legion, on a port of a rental or autoscaled on rented GPUs: create, change, pause and delete them, manage their keys, and read their replicas, usage and activity.

Source: https://legion.ambient.xyz/docs/api/services

- [List the organization's services](https://legion.ambient.xyz/docs/api/services/list-services): `GET /v1/services`. The organization's services, newest first: every exposed port, model rental and autoscaled model (decision 32).
- [Create a service](https://legion.ambient.xyz/docs/api/services/create-service): `POST /v1/services`. Creates a service (decision 32): a Service URL https://<name>-<suffix>.ambi.run, an access policy and a target.
- [The defaults of a new service](https://legion.ambient.xyz/docs/api/services/get-service-defaults): `GET /v1/services/defaults`. The single source of service defaults and limits (decision 12): scaling, key expiry, timeouts and, for a catalog entry (catalog_id), its target…
- [Estimate what a service would cost](https://legion.ambient.xyz/docs/api/services/estimate-service): `POST /v1/services/estimate`. What a service with this hardware and scaling would cost per hour at current prices, from the cheapest host that fits now: idle, at minimum and at…
- [Get a service](https://legion.ambient.xyz/docs/api/services/get-service): `GET /v1/services/{service_id}`. One service with its status, replica counts, cold-start time and this month's spend, plus (on this read only) its keys (keys), live and warm replicas…
- [Change a service's model, hardware, scaling or budget, or switch autoscaling on or off](https://legion.ambient.xyz/docs/api/services/update-service): `PATCH /v1/services/{service_id}`. Merge patch (decision 34).
- [Delete a service](https://legion.ambient.xyz/docs/api/services/delete-service): `DELETE /v1/services/{service_id}`. Deletes the service and revokes its keys at once.
- [Pause a service](https://legion.ambient.xyz/docs/api/services/pause-service): `POST /v1/services/{service_id}/pause`. No replicas and no GPU cost; the URL and keys stay and callers get 503 service_paused until resumed.
- [Resume a paused service](https://legion.ambient.xyz/docs/api/services/resume-service): `POST /v1/services/{service_id}/resume`. Back to active: the autoscaler returns to min_replicas, warm replicas first.
- [List a service's keys](https://legion.ambient.xyz/docs/api/services/list-service-keys): `GET /v1/services/{service_id}/keys`. The service's keys, newest first, revoked ones included: name, display prefix, expiry, last use and status.
- [Create a service key](https://legion.ambient.xyz/docs/api/services/create-service-key): `POST /v1/services/{service_id}/keys`. A new lek_ key for this service only, its secret shown once (Cache-Control: no-store); Legion keeps only its SHA-256.
- [Revoke a service key](https://legion.ambient.xyz/docs/api/services/revoke-service-key): `DELETE /v1/services/{service_id}/keys/{key_id}`. Revokes the key now; callers using it get 401 within seconds (at most 30).
- [Rotate a service key](https://legion.ambient.xyz/docs/api/services/rotate-service-key): `POST /v1/services/{service_id}/keys/{key_id}/rotate`. Creates a new key and makes the old one expire after overlap_hours (default 24, 0 to 168), so callers can switch without downtime.
- [List a service's replicas](https://legion.ambient.xyz/docs/api/services/list-service-replicas): `GET /v1/services/{service_id}/replicas`. The service's live and warm replicas, newest first; include_retired=true adds those retired in the last 7 days with the reason.
- [A service's metrics and cost](https://legion.ambient.xyz/docs/api/services/get-service-usage): `GET /v1/services/{service_id}/usage`. Request metrics over window (1h in minute points, the default; 24h in 5-minute points; 7d hourly): requests, status classes, rejections, time to first…
- [A service's inference metrics](https://legion.ambient.xyz/docs/api/services/get-service-metrics): `GET /v1/services/{service_id}/metrics`. Serving metrics of a service, or of one of its replicas with replica, over window: a time series (points) and a summary of the whole window.
- [A service's activity](https://legion.ambient.xyz/docs/api/services/list-service-events): `GET /v1/services/{service_id}/events`. Scaling, key, budget and settings history, newest first, kept 30 days.
- [Read a service's logs, every replica](https://legion.ambient.xyz/docs/api/services/get-service-logs): `GET /v1/services/{service_id}/logs`. .
