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

# Create a managed database



## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples post /managed_databases
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Baselines (Preview)
    description: >-
      Preview. Available to teams with the `baselines_api` feature flag. The
      shape of these endpoints may change before general availability.
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: IP Addresses
  - name: Managed Databases
    description: Managed database instances (PostgreSQL, ClickHouse)
  - name: Kubernetes Clusters
  - name: LKS
  - name: Marketplace apps
  - name: Operating Systems
  - name: Plans
  - name: Public Networks
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Block Storage
  - name: Filesystem Storage
  - name: Object Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
  - name: Virtual machine backups
  - name: Virtual machine restores
paths:
  /managed_databases:
    post:
      tags:
        - Managed Databases
      summary: Create a managed database
      operationId: create-managed-database
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/managed_database_payload'
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/managed_database_payload'
      responses:
        '201':
          description: Created
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/managed_database'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.managed_databases.create_managed_database(data={
                    "type": latitudesh_python_sdk.ManagedDatabasePayloadType.MANAGED_DATABASES,
                    "attributes": {
                        "name": "my-postgres-db",
                        "project_id": "proj_ABC123",
                        "region": "ASH",
                        "plan": "db.psql.small",
                        "engine": "postgres",
                    },
                })

                # Handle response
                print(res)
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tlatitudeshgosdk \"github.com/latitudesh/latitudesh-go-sdk\"\n\t\"github.com/latitudesh/latitudesh-go-sdk/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := latitudeshgosdk.New(\n        latitudeshgosdk.WithSecurity(os.Getenv(\"LATITUDESH_BEARER\")),\n    )\n\n    res, err := s.ManagedDatabases.CreateManagedDatabase(ctx, components.ManagedDatabasePayload{\n        Data: &components.ManagedDatabasePayloadData{\n            Type: components.ManagedDatabasePayloadTypeManagedDatabases.ToPointer(),\n            Attributes: &components.ManagedDatabasePayloadAttributes{\n                Name: \"my-postgres-db\",\n                ProjectID: \"proj_ABC123\",\n                Region: \"ASH\",\n                Plan: \"db.psql.small\",\n                Engine: \"postgres\",\n            },\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.ManagedDatabase != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Latitudesh } from "latitudesh-typescript-sdk";

            const latitudesh = new Latitudesh({
              bearer: process.env["LATITUDESH_BEARER"] ?? "",
            });

            async function run() {
              const result = await latitudesh.managedDatabases.createManagedDatabase({
                data: {
                  type: "managed_databases",
                  attributes: {
                    name: "my-postgres-db",
                    projectId: "proj_ABC123",
                    region: "ASH",
                    plan: "db.psql.small",
                    engine: "postgres",
                  },
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    managed_database_payload:
      type: object
      example:
        data:
          type: managed_databases
          attributes:
            project_id: proj_ABC123
            region: ASH
            plan: db.psql.small
            engine: postgres
            name: my-postgres-db
      properties:
        data:
          type: object
          properties:
            type:
              type: string
              enum:
                - managed_databases
            attributes:
              type: object
              required:
                - name
                - project_id
                - region
                - plan
                - engine
              properties:
                name:
                  type: string
                  description: Display name; used to derive the helm release name
                project_id:
                  type: string
                  description: Project slug
                region:
                  type: string
                  example: ASH
                  description: Target region
                plan:
                  type: string
                  example: db.psql.small
                  description: Plan slug (e.g. db.psql.small)
                engine:
                  type: string
                  example: postgres
                  description: Database engine
                billing:
                  type: string
                  enum:
                    - monthly
                    - yearly
                  description: >-
                    Billing cycle (postgres/clickhouse). Defaults to monthly
                    when omitted.
                parameters:
                  type: object
                  additionalProperties: true
                  description: Custom PostgreSQL parameters at create (postgres only)
                pooler:
                  type: object
                  additionalProperties: true
                  description: PgBouncer pooler configuration at create (postgres only)
                backup:
                  type: object
                  additionalProperties: true
                  description: Scheduled backup configuration at create (postgres only)
                recovery:
                  type: object
                  description: >-
                    Restore from a source database backup at create (postgres
                    only)
                  properties:
                    sourceDatabaseName:
                      type: string
                    backupId:
                      type: string
                replica_regions:
                  type: array
                  items:
                    type: string
                  example:
                    - MIA
                    - DAL
                  description: >-
                    Optional. Reserved for cross-region read replicas (postgres
                    only): accepted and validated, but replica provisioning is
                    not yet active.
    managed_database:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/managed_database_attributes'
    managed_database_attributes:
      type: object
      properties:
        id:
          type: string
          example: db_a1b2c3d4
        type:
          type: string
          enum:
            - managed_databases
        attributes:
          type: object
          properties:
            name:
              type: string
            engine:
              type: string
            status:
              type: string
            namespace:
              type: string
              nullable: true
            created_at:
              type: string
              nullable: true
            specs:
              type: object
              nullable: true
              properties:
                cpu:
                  type: integer
                  nullable: true
                memory:
                  type: integer
                  nullable: true
                storage:
                  type: integer
                  nullable: true
                shards:
                  type: integer
                  nullable: true
                replicas:
                  type: integer
                  nullable: true
                iops:
                  type: string
                  nullable: true
            region:
              type: object
              properties:
                city:
                  type: string
                  nullable: true
                country:
                  type: string
                  nullable: true
                site:
                  type: object
                  nullable: true
                  properties:
                    id:
                      type: string
                    name:
                      type: string
                    slug:
                      type: string
                    facility:
                      type: string
            plan:
              type: object
              properties:
                id:
                  type: string
                name:
                  type: string
                  nullable: true
                slug:
                  type: string
                  nullable: true
                billing:
                  type: string
            team:
              $ref: '#/components/schemas/team_include'
              nullable: true
            project:
              $ref: '#/components/schemas/project_include'
              nullable: true
            trusted_sources:
              type: array
              items:
                type: string
              description: Array of CIDR addresses allowed to connect
            play_url:
              type: string
              nullable: true
            credentials:
              type: object
              nullable: true
              properties:
                host:
                  type: string
                http_port:
                  type: integer
                  nullable: true
                tcp_port:
                  type: integer
                  nullable: true
                port:
                  type: integer
                  nullable: true
                  description: Postgres NodePort
                database:
                  type: string
                  nullable: true
                url:
                  type: string
                  nullable: true
                  description: Postgres connection string
                username:
                  type: string
                password:
                  type: string
                  nullable: true
            parameters:
              type: object
              additionalProperties:
                type: string
              description: Custom PostgreSQL parameters
            pooler:
              type: object
              additionalProperties: true
              description: PgBouncer pooler configuration
            backup:
              type: object
              additionalProperties: true
              description: Scheduled backup configuration
            recovery:
              type: object
              properties:
                enabled:
                  type: boolean
                  nullable: true
            supabase:
              type: object
              properties:
                enabled:
                  type: boolean
    team_include:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        description:
          type: string
          nullable: true
        address:
          type: string
          nullable: true
        currency:
          type: object
          properties:
            id:
              type: string
            code:
              type: string
            name:
              type: string
            currency_id:
              type: integer
              nullable: true
        status:
          type: string
          nullable: true
        feature_flags:
          type: array
          items:
            type: string
        limits:
          type: object
          properties:
            bare_metal:
              type: integer
              nullable: true
            bare_metal_gpu:
              type: integer
              nullable: true
            virtual_machine:
              type: integer
              nullable: true
            virtual_machine_gpu:
              type: integer
              nullable: true
            elastic_ip:
              type: integer
              nullable: true
            bgp_session_per_ip:
              type: integer
              nullable: true
            public_network:
              type: integer
              nullable: true
            virtual_network:
              type: integer
              nullable: true
            database:
              type: integer
              nullable: true
            filesystem:
              type: integer
              nullable: true
            block_storage:
              type: integer
              nullable: true
    project_include:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        description:
          type: string
          nullable: true
        billing_type:
          type: string
          nullable: true
        provisioning_type:
          type: string
          nullable: true
        billing_method:
          type: string
          nullable: true
        bandwidth_alert:
          type: boolean
        environment:
          type: string
          nullable: true
        billing:
          type: object
          properties:
            subscription_id:
              type: string
              nullable: true
            type:
              type: string
            method:
              type: string
        stats:
          type: object
          properties:
            databases:
              type: integer
            ip_addresses:
              type: integer
            prefixes:
              type: integer
            servers:
              type: integer
            storages:
              type: integer
            virtual_machines:
              type: integer
            vlans:
              type: integer
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````

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