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

# Create

> Create a PostgreSQL Connection.

<Note>
  Check out the configuration docs for [PostgreSQL
  Connections](/integrations/app-connections/postgres) to learn how to obtain the
  required credentials.
</Note>


## OpenAPI

````yaml POST /api/v1/app-connections/postgres
openapi: 3.0.3
info:
  title: Infisical API
  description: List of all available APIs that can be consumed
  version: 0.0.1
servers:
  - url: https://us.infisical.com
    description: Production server (US)
  - url: https://eu.infisical.com
    description: Production server (EU)
  - url: http://localhost:8080
    description: Local server
security: []
paths:
  /api/v1/app-connections/postgres:
    post:
      tags:
        - App Connections
      description: Create a PostgreSQL Connection.
      operationId: createPostgresAppConnection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - anyOf:
                    - type: object
                      properties:
                        method:
                          type: string
                          enum:
                            - username-and-password
                          description: The method used to authenticate with PostgreSQL.
                        credentials:
                          type: object
                          properties:
                            host:
                              type: string
                              minLength: 1
                              description: The hostname of the database server.
                            port:
                              type: number
                              description: The port number of the database.
                            database:
                              type: string
                              minLength: 1
                              description: The name of the database to connect to.
                            username:
                              type: string
                              minLength: 1
                              description: The username to connect to the database with.
                            password:
                              type: string
                              minLength: 1
                              description: The password to connect to the database with.
                            sslEnabled:
                              type: boolean
                              description: >-
                                Whether or not to use SSL when connecting to the
                                database.
                            sslRejectUnauthorized:
                              type: boolean
                              description: >-
                                Whether or not to reject unauthorized SSL
                                certificates.
                            sslCertificate:
                              type: string
                              description: The SSL certificate to use for connection.
                          required:
                            - host
                            - port
                            - database
                            - username
                            - password
                            - sslEnabled
                            - sslRejectUnauthorized
                          additionalProperties: false
                          description: The credentials used to connect with PostgreSQL.
                      required:
                        - method
                        - credentials
                      additionalProperties: false
                - type: object
                  properties:
                    name:
                      type: string
                      minLength: 1
                      maxLength: 64
                      description: >-
                        The name of the PostgreSQL Connection to create. Must be
                        slug-friendly.
                    description:
                      type: string
                      maxLength: 256
                      nullable: true
                      description: An optional description for the PostgreSQL Connection.
                    projectId:
                      type: string
                      description: >-
                        The ID of the project to create the PostgreSQL
                        Connection in.
                    isPlatformManagedCredentials:
                      type: boolean
                      default: false
                      description: >-
                        Whether or not the PostgreSQL Connection credentials
                        should be managed by Infisical. Once enabled this cannot
                        be reversed.
                    gatewayId:
                      type: string
                      format: uuid
                      nullable: true
                      description: The Gateway ID to use for this connection.
                    gatewayPoolId:
                      type: string
                      format: uuid
                      nullable: true
                      description: The Gateway Pool ID to use for this connection.
                    isAutoRotationEnabled:
                      type: boolean
                      enum:
                        - false
                      description: Not supported for PostgreSQL Connections.
                    rotation:
                      anyOf:
                        - not: {}
                        - enum:
                            - 'null'
                          nullable: true
                      description: Not supported for PostgreSQL Connections.
                  required:
                    - name
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  appConnection:
                    anyOf:
                      - type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                          name:
                            type: string
                          description:
                            type: string
                            nullable: true
                          version:
                            type: number
                            default: 1
                          orgId:
                            type: string
                            format: uuid
                          createdAt:
                            type: string
                            format: date-time
                          updatedAt:
                            type: string
                            format: date-time
                          isPlatformManagedCredentials:
                            type: boolean
                            default: false
                            nullable: true
                          gatewayId:
                            type: string
                            format: uuid
                            nullable: true
                          projectId:
                            type: string
                            nullable: true
                          isAutoRotationEnabled:
                            type: boolean
                            default: false
                          gatewayPoolId:
                            type: string
                            format: uuid
                            nullable: true
                          rotation:
                            type: object
                            properties:
                              lastRotationMessage:
                                type: string
                                nullable: true
                                description: The message from the last rotation attempt.
                              rotationInterval:
                                type: number
                                description: >-
                                  The interval in days between credential
                                  rotations.
                              nextRotationAt:
                                type: string
                                format: date-time
                                nullable: true
                                description: The next scheduled rotation time.
                              rotationStatus:
                                type: string
                                enum:
                                  - success
                                  - failed
                                description: The status of the last rotation attempt.
                              rotateAtUtc:
                                type: object
                                properties:
                                  hours:
                                    type: number
                                    description: The hour (0-23) at which to rotate.
                                  minutes:
                                    type: number
                                    description: The minute (0-59) at which to rotate.
                                required:
                                  - hours
                                  - minutes
                                additionalProperties: false
                                description: >-
                                  The UTC time of day at which rotation should
                                  occur.
                            required:
                              - rotationInterval
                              - rotationStatus
                              - rotateAtUtc
                            additionalProperties: false
                            description: >-
                              The credential rotation configuration, if
                              configured.
                          credentialsHash:
                            type: string
                          project:
                            type: object
                            properties:
                              name:
                                type: string
                              id:
                                type: string
                              type:
                                type: string
                              slug:
                                type: string
                            required:
                              - name
                              - id
                              - type
                              - slug
                            additionalProperties: false
                            nullable: true
                          app:
                            type: string
                            enum:
                              - postgres
                          method:
                            type: string
                            enum:
                              - username-and-password
                          credentials:
                            type: object
                            properties:
                              host:
                                type: string
                                minLength: 1
                                description: The hostname of the database server.
                              database:
                                type: string
                                minLength: 1
                                description: The name of the database to connect to.
                              port:
                                type: number
                                description: The port number of the database.
                              username:
                                type: string
                                minLength: 1
                                description: The username to connect to the database with.
                              sslEnabled:
                                type: boolean
                                description: >-
                                  Whether or not to use SSL when connecting to
                                  the database.
                              sslRejectUnauthorized:
                                type: boolean
                                description: >-
                                  Whether or not to reject unauthorized SSL
                                  certificates.
                              sslCertificate:
                                type: string
                                description: The SSL certificate to use for connection.
                            required:
                              - host
                              - database
                              - port
                              - username
                              - sslEnabled
                              - sslRejectUnauthorized
                            additionalProperties: false
                        required:
                          - id
                          - name
                          - orgId
                          - createdAt
                          - updatedAt
                          - app
                          - method
                          - credentials
                        additionalProperties: false
                        title: PostgreSQL (Username and Password)
                required:
                  - appConnection
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 400
                  message:
                    type: string
                  error:
                    type: string
                  details: {}
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '401':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 401
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '403':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 403
                  message:
                    type: string
                  details: {}
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 404
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false
        '422':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 422
                  message: {}
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - error
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  reqId:
                    type: string
                  statusCode:
                    type: number
                    enum:
                      - 500
                  message:
                    type: string
                  error:
                    type: string
                required:
                  - reqId
                  - statusCode
                  - message
                  - error
                additionalProperties: false

````