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

# Create a database

> Creates a database record in the control plane and triggers creation in the
target region. Database names must be less than 64 characters, and unique
within a workspace. Names may contain letters (lower or uppercase), numbers,
and underscores, and must begin with a letter or underscore.




## OpenAPI

````yaml https://global.thenile.dev/openapi.yaml post /workspaces/{workspaceSlug}/databases
openapi: 3.0.1
info:
  title: Nile ReST API
  description: Making SaaS chill.
  contact:
    email: support@thenile.dev
  version: 0.1.0-1133318
servers:
  - url: https://global.thenile.dev
security: []
paths:
  /workspaces/{workspaceSlug}/databases:
    post:
      tags:
        - databases
      summary: Create a database
      description: >
        Creates a database record in the control plane and triggers creation in
        the

        target region. Database names must be less than 64 characters, and
        unique

        within a workspace. Names may contain letters (lower or uppercase),
        numbers,

        and underscores, and must begin with a letter or underscore.
      operationId: createDatabase
      parameters:
        - name: workspaceSlug
          in: path
          required: true
          schema:
            type: string
      requestBody:
        description: The name and region for the new database
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatabaseRequest'
        required: true
      responses:
        '201':
          description: Database created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetDatabaseResponse'
        '400':
          description: An invalid database name or region was provided.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '401':
          description: Unauthorized. Credentials were missing or expired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '403':
          description: >-
            Forbidden. The credentials provided do not grant access to the
            requested resource(s).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '404':
          description: >-
            The workspace does not exist or is not authorized for the
            authenticated user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '409':
          description: A database with the provided name already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
      security:
        - jwtBearerAuth: []
components:
  schemas:
    CreateDatabaseRequest:
      required:
        - databaseName
        - region
      type: object
      properties:
        databaseName:
          type: string
          description: >
            The name of the database to be created. Database names must be less
            than 64

            characters, and unique within a workspace. Names may contain letters
            (lower

            or uppercase), numbers, and underscores, and must begin with a
            letter or

            underscore.
          example: my_spectacular_db
        region:
          type: string
          description: >
            The region where the database will be hosted. Nile currently
            supports the

            following values:

            - `AWS_US_WEST_2` - AWS in US West (Oregon)

            - `AWS_EU_CENTRAL_1` - AWS in Europe (Frankfurt)
          example: AWS_US_WEST_2
          enum:
            - AWS_US_WEST_2
            - AWS_EU_CENTRAL_1
        sharded:
          type: boolean
          description: >
            Whether to create a sharded database or just regular Postgres.

            Sharded databases are a good fit for scalable multi-tenant
            applications and vector use,

            while regular Postgres is suitable for most applications.
          example: true
          enum:
            - true
            - false
      description: Parameters for creating a new database, including the name and region.
    GetDatabaseResponse:
      required:
        - apiHost
        - expandable
        - id
        - name
        - region
        - status
        - workspace
      type: object
      properties:
        id:
          type: string
        name:
          minLength: 1
          type: string
        workspace:
          $ref: '#/components/schemas/Workspace'
        status:
          type: string
          enum:
            - PENDING
            - REQUESTED
            - BUILT
            - READY
        region:
          type: string
          enum:
            - AWS_US_WEST_2
            - AWS_EU_CENTRAL_1
            - AZURE_EASTUS
        expandable:
          type: boolean
        created:
          type: string
          format: date-time
        deleted:
          type: string
          format: date-time
        apiHost:
          type: string
          format: uri
        dbHost:
          type: string
          format: uri
        sharded:
          type: boolean
    APIError:
      required:
        - errorCode
        - message
        - statusCode
      type: object
      properties:
        errorCode:
          type: string
          enum:
            - internal_error
            - bad_request
            - unsupported_operation
            - forbidden_operation
            - entity_not_found
            - duplicate_entity
            - invalid_credentials
            - unknown_oidc_provider
            - unknown_oidc_party
            - provider_already_exists
            - provider_config_error
            - provider_mismatch
            - provider_update_error
            - provider_disabled
            - session_state_missing
            - session_state_mismatch
            - oidc_code_missing
            - tenant_not_found
            - constraint_violation
            - sql_exception
            - db_creation_failure
            - db_status_failure
            - db_initialization_failure
            - db_deletion_failure
            - db_config_missing
            - unauthorized_workspace_access
            - email_send_failure
            - jdbc_exception
            - oidc_exception
            - region_mismatch
            - credential_creation_failure
            - credential_propagation_failure
            - unauthorized_client
            - unsupported_response_type
            - invalid_request
            - server_error
            - access_denied
            - feature_ineligible
            - customer_lookup_failure
            - threshold_exceeded
            - create_rejected
        message:
          minLength: 1
          type: string
        statusCode:
          type: integer
          format: int32
    Workspace:
      required:
        - name
        - slug
      type: object
      properties:
        id:
          type: string
        name:
          minLength: 1
          type: string
        slug:
          minLength: 1
          type: string
        stripe_customer_id:
          type: string
        created:
          type: string
          format: date-time
  securitySchemes:
    jwtBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````