Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions mpg/api/index.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: "Managed Postgres API"
layout: docs
nav: mpg
toc: false
---

The Managed Postgres API is part of the [Fly Machines API](/docs/machines/api/), Fly.io's REST API for provisioning and managing resources. Use it to create and manage Managed Postgres clusters, databases, users, backups, and app attachments programmatically, without going through flyctl or the dashboard.

If you're not already familiar with the Machines API, start with [Working with the Machines API](/docs/machines/api/working-with-machines-api/) to get authenticated and set up.

## Endpoints

Cluster management:

- `GET /v1/postgres` - List Managed Postgres clusters for an organization. Requires an `org_slug` query parameter.
- `POST /v1/postgres` - Create a Managed Postgres cluster.
- `GET /v1/postgres/{postgres_cluster_id}` - Get details of a specific cluster.
- `DELETE /v1/postgres/{postgres_cluster_id}` - Delete a cluster.

Attachments:

- `POST /v1/postgres/{postgres_cluster_id}/attachments` - Attach a cluster to a Fly App.
- `DELETE /v1/postgres/{postgres_cluster_id}/attachments/{app_name}` - Detach a cluster from a Fly App.

Backups:

- `GET /v1/postgres/{postgres_cluster_id}/backups` - List backups for a cluster.
- `POST /v1/postgres/{postgres_cluster_id}/backups` - Create a backup.

Databases:

- `GET /v1/postgres/{postgres_cluster_id}/databases` - List databases within a cluster.
- `POST /v1/postgres/{postgres_cluster_id}/databases` - Create a database.
- `DELETE /v1/postgres/{postgres_cluster_id}/databases/{database_name}` - Delete a database.

Extensions:

- `GET /v1/postgres/{postgres_cluster_id}/databases/{database_name}/extensions` - List extensions available within a database.
- `POST /v1/postgres/{postgres_cluster_id}/databases/{database_name}/extensions` - Enable an extension.
- `DELETE /v1/postgres/{postgres_cluster_id}/databases/{database_name}/extensions/{extension_name}` - Disable an extension.

Fork and restore:

- `POST /v1/postgres/{postgres_cluster_id}/fork` - Fork a ready cluster into a new cluster.
- `POST /v1/postgres/{postgres_cluster_id}/restore` - Restore a backup, or a point-in-time, into a new cluster.

Users:

- `GET /v1/postgres/{postgres_cluster_id}/users` - List Postgres users within a cluster.
- `POST /v1/postgres/{postgres_cluster_id}/users` - Create a Postgres user.
- `PATCH /v1/postgres/{postgres_cluster_id}/users/{username}` - Update a user's role.
- `DELETE /v1/postgres/{postgres_cluster_id}/users/{username}` - Delete a user.
- `GET /v1/postgres/{postgres_cluster_id}/users/{username}/credentials` - Get connection credentials for a user.
- `POST /v1/postgres/{postgres_cluster_id}/users/{username}/rotate_password` - Rotate a user's password.

## OpenAPI spec

See the full [OpenAPI 3.0 specification](https://docs.machines.dev/+external) for request and response schemas.
1 change: 1 addition & 0 deletions mpg/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ You'll be able to access:

- A highly-available Postgres cluster within your Fly.io organization's [private network](/docs/networking/private-networking/)
- Multiple databases and schemas on that cluster
- Programmatic access via the [Managed Postgres API](/docs/mpg/api/), part of the Fly Machines API
- Fly.io Support Portal to log tickets and get help
- Any trusted extensions included in the [default Postgres 16 distribution](https://www.postgresql.org/docs/16/contrib.html)
- The third party `pgvector` extension for vector similarity search
Expand Down
3 changes: 2 additions & 1 deletion partials/_mpg_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
links: [
{ text: "Monitoring and Metrics", path: "/docs/mpg/metrics/" },
{ text: "Import data from another postgres cluster", path: "/docs/mpg/import/" },
{ text: "Supported Postgres Extensions", path: "/docs/mpg/extensions/" }
{ text: "Supported Postgres Extensions", path: "/docs/mpg/extensions/" },
{ text: "Managed Postgres API", path: "/docs/mpg/api/" }
]
}
]
Expand Down
Loading