# Create

Launch stage: GA

`POST /api/2.0/postgres/{parent=projects/*/branches/*}/endpoints`

Creates a new compute endpoint in the branch.

API scopes: postgres

## Path parameters

- `parent` (string, optional)
  The Branch where this Endpoint will be created.
   Format: projects/{project_id}/branches/{branch_id}

## Query parameters

- `endpoint_id` (string, optional)
  The ID to use for the Endpoint. This becomes the final component of the endpoint's resource name.
   The ID is required and must be 1-63 characters long, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens.
   For example, `primary` becomes `projects/my-app/branches/development/endpoints/primary`.
- `replace_existing` (boolean, optional)
  If true, update the endpoint if it already exists instead of returning an error.

## Request body

- `endpoint` (object, optional)
  The Endpoint to create.
  - `name` (string, optional)
    Output only. The full resource path of the endpoint.
     Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}
  - `uid` (string, optional)
    System-generated unique ID for the endpoint.
  - `parent` (string, optional)
    The branch containing this endpoint (API resource hierarchy).
     Format: projects/{project_id}/branches/{branch_id}
  - `create_time` (string, optional)
    A timestamp indicating when the compute endpoint was created.
  - `update_time` (string, optional)
    A timestamp indicating when the compute endpoint was last updated.
  - `spec` (object, optional)
    The spec contains the compute endpoint configuration, including autoscaling limits, suspend timeout, and disabled state.
    - `endpoint_type` (string, optional)
      The endpoint type. A branch can only have one READ_WRITE endpoint.
      Possible values: `ENDPOINT_TYPE_UNSPECIFIED`, `ENDPOINT_TYPE_READ_WRITE`, `ENDPOINT_TYPE_READ_ONLY`
    - `autoscaling_limit_min_cu` (double, optional)
      The minimum number of Compute Units. Minimum value is 0.5.
    - `autoscaling_limit_max_cu` (double, optional)
      The maximum number of Compute Units. The maximum value is 64.
       The difference between the minimum and maximum Compute Units (max - min) must not exceed 16.
    - `disabled` (boolean, optional)
      Whether to restrict connections to the compute endpoint.
       Enabling this option schedules a suspend compute operation.
       A disabled compute endpoint cannot be enabled by a connection or
       console action.
    - `suspend_timeout_duration` (string, required)
      Duration of inactivity after which the compute endpoint is automatically suspended.
       If specified should be between 60s and 604800s (1 minute to 1 week).
       Mutually exclusive with `no_suspension`. When updating, use `spec.suspension` in the update_mask.
    - `no_suspension` (boolean, required)
      When set to true, explicitly disables automatic suspension (never suspend).
       Should be set to true when provided.
       Mutually exclusive with `suspend_timeout_duration`. When updating, use `spec.suspension` in the update_mask.
    - `settings` (object, optional)
      - `pg_settings` (object, optional)
        A raw representation of Postgres settings.
    - `group` (object, optional)
      Settings for optional HA configuration of the endpoint. If unspecified, the endpoint defaults
       to non HA settings, with a single compute backing the endpoint (and no readable secondaries
       for Read/Write endpoints).
      - `min` (int32, optional)
        The minimum number of computes in the endpoint group. Currently, this must be equal to max. This must be greater
         than or equal to 1.
      - `max` (int32, optional)
        The maximum number of computes in the endpoint group. Currently, this must be equal to min. Set to 1 for single
         compute endpoints, to disable HA. To manually suspend all computes in an endpoint group, set disabled to
         true on the EndpointSpec.
      - `enable_readable_secondaries` (boolean, optional)
        Whether to allow read-only connections to read-write endpoints. Only relevant for read-write endpoints where
         size.max > 1.
  - `status` (object, optional)
    Current operational status of the compute endpoint.
    - `endpoint_type` (string, optional)
      The endpoint type. A branch can only have one READ_WRITE endpoint.
      Possible values: `ENDPOINT_TYPE_UNSPECIFIED`, `ENDPOINT_TYPE_READ_WRITE`, `ENDPOINT_TYPE_READ_ONLY`
    - `hosts` (object, optional)
      Contains host information for connecting to the endpoint.
      - `host` (string, optional)
        The hostname to connect to this endpoint. For read-write endpoints, this is a read-write hostname which connects
         to the primary compute. For read-only endpoints, this is a read-only hostname which allows read-only operations.
      - `read_only_host` (string, optional)
        An optionally defined read-only host for the endpoint, without pooling. For read-only endpoints,
         this attribute is always defined and is equivalent to host. For read-write endpoints, this attribute is defined
         if the enclosing endpoint is a group with greater than 1 computes configured, and has readable secondaries enabled.
      - `read_write_pooled_host` (string, optional)
        The read-write hostname of the compute endpoint, with pooling. This attribute is only defined for read-write endpoints.
      - `read_only_pooled_host` (string, optional)
        The read-only hostname of the compute endpoint, with pooling. This attribute is always defined for read-only endpoints,
         and may be defined for read-write endpoints if configured with read replicas and allow read-only connections.
    - `last_active_time` (string, optional)
      A timestamp indicating when the compute endpoint was last active.
    - `autoscaling_limit_min_cu` (double, optional)
      The minimum number of Compute Units.
    - `autoscaling_limit_max_cu` (double, optional)
      The maximum number of Compute Units. The maximum value is 64.
       The difference between the minimum and maximum Compute Units (max - min) must not exceed 16.
    - `current_state` (string, optional)
      Possible values: `STATE_UNSPECIFIED`, `INIT`, `ACTIVE`, `IDLE`, `DEGRADED`
    - `pending_state` (string, optional)
      Possible values: `STATE_UNSPECIFIED`, `INIT`, `ACTIVE`, `IDLE`, `DEGRADED`
    - `disabled` (boolean, optional)
      Whether to restrict connections to the compute endpoint.
       Enabling this option schedules a suspend compute operation.
       A disabled compute endpoint cannot be enabled by a connection or
       console action.
    - `suspend_timeout_duration` (string, optional)
      Duration of inactivity after which the compute endpoint is automatically suspended.
    - `settings` (object, optional)
      - `pg_settings` (object, optional)
        A raw representation of Postgres settings.
    - `group` (object, optional)
      Details on the HA configuration of the endpoint.
      - `min` (int32, optional)
        The minimum number of computes in the endpoint group. Currently, this must be equal to max. This must be greater
         than or equal to 1.
      - `max` (int32, optional)
        The maximum number of computes in the endpoint group. Currently, this must be equal to min. Set to 1 for single
         compute endpoints, to disable HA. To manually suspend all computes in an endpoint group, set disabled to
         true on the EndpointSpec.
      - `enable_readable_secondaries` (boolean, optional)
        Whether read-only connections to read-write endpoints are allowed. Only relevant if read replicas are configured
         by specifying size.max > 1.
    - `endpoint_id` (string, optional)
      Part of the resource name.
  - `endpoint_id` (string, optional)
    The part of the name, chosen by the user when the resource was created.

## Returns

- `name` (string, optional)
  The server-assigned name, which is only unique within the same service that
   originally returns it. If you use the default HTTP mapping, the
   `name` should be a resource name ending with `operations/{unique_id}`.
- `metadata` (object, optional)
  Service-specific metadata associated with the operation.  It typically
   contains progress information and common metadata such as create time.
   Some services might not provide such metadata.
- `done` (boolean, optional)
  If the value is `false`, it means the operation is still in progress.
   If `true`, the operation is completed, and either `error` or `response` is
   available.
- `error` (object, required)
  The error result of the operation in case of failure or cancellation.
  - `error_code` (string, optional)
    Possible values: `UNKNOWN`, `INTERNAL_ERROR`, `TEMPORARILY_UNAVAILABLE`, `IO_ERROR`, `BAD_REQUEST`, `SERVICE_UNDER_MAINTENANCE`, `WORKSPACE_TEMPORARILY_UNAVAILABLE`, `DEADLINE_EXCEEDED`, `CANCELLED`, `RESOURCE_EXHAUSTED`, `ABORTED`, `NOT_FOUND`, `ALREADY_EXISTS`, `UNAUTHENTICATED`, `UNAVAILABLE`, `INVALID_PARAMETER_VALUE`, `ENDPOINT_NOT_FOUND`, `MALFORMED_REQUEST`, `INVALID_STATE`, `PERMISSION_DENIED`, `FEATURE_DISABLED`, `CUSTOMER_UNAUTHORIZED`, `REQUEST_LIMIT_EXCEEDED`, `RESOURCE_CONFLICT`, `UNPARSEABLE_HTTP_ERROR`, `NOT_IMPLEMENTED`, `DATA_LOSS`, `INVALID_STATE_TRANSITION`, `COULD_NOT_ACQUIRE_LOCK`, `RESOURCE_ALREADY_EXISTS`, `RESOURCE_DOES_NOT_EXIST`, `QUOTA_EXCEEDED`, `MAX_BLOCK_SIZE_EXCEEDED`, `MAX_READ_SIZE_EXCEEDED`, `PARTIAL_DELETE`, `MAX_LIST_SIZE_EXCEEDED`, `DRY_RUN_FAILED`, `RESOURCE_LIMIT_EXCEEDED`, `DIRECTORY_NOT_EMPTY`, `DIRECTORY_PROTECTED`, `MAX_NOTEBOOK_SIZE_EXCEEDED`, `MAX_CHILD_NODE_SIZE_EXCEEDED`, `SEARCH_QUERY_TOO_LONG`, `SEARCH_QUERY_TOO_SHORT`, `MANAGED_RESOURCE_GROUP_DOES_NOT_EXIST`, `PERMISSION_NOT_PROPAGATED`, `DEPLOYMENT_TIMEOUT`, `GIT_CONFLICT`, `GIT_UNKNOWN_REF`, `GIT_SENSITIVE_TOKEN_DETECTED`, `GIT_URL_NOT_ON_ALLOW_LIST`, `GIT_REMOTE_ERROR`, `PROJECTS_OPERATION_TIMEOUT`, `IPYNB_FILE_IN_REPO`, `INSECURE_PARTNER_RESPONSE`, `MALFORMED_PARTNER_RESPONSE`, `METASTORE_DOES_NOT_EXIST`, `DAC_DOES_NOT_EXIST`, `CATALOG_DOES_NOT_EXIST`, `SCHEMA_DOES_NOT_EXIST`, `TABLE_DOES_NOT_EXIST`, `SHARE_DOES_NOT_EXIST`, `RECIPIENT_DOES_NOT_EXIST`, `STORAGE_CREDENTIAL_DOES_NOT_EXIST`, `EXTERNAL_LOCATION_DOES_NOT_EXIST`, `PRINCIPAL_DOES_NOT_EXIST`, `PROVIDER_DOES_NOT_EXIST`, `METASTORE_ALREADY_EXISTS`, `DAC_ALREADY_EXISTS`, `CATALOG_ALREADY_EXISTS`, `SCHEMA_ALREADY_EXISTS`, `TABLE_ALREADY_EXISTS`, `SHARE_ALREADY_EXISTS`, `RECIPIENT_ALREADY_EXISTS`, `STORAGE_CREDENTIAL_ALREADY_EXISTS`, `EXTERNAL_LOCATION_ALREADY_EXISTS`, `PROVIDER_ALREADY_EXISTS`, `CATALOG_NOT_EMPTY`, `SCHEMA_NOT_EMPTY`, `METASTORE_NOT_EMPTY`, `PROVIDER_SHARE_NOT_ACCESSIBLE`
  - `message` (string, optional)
  - `stack_trace` (string, optional)
  - `details` (array of object, optional)
- `response` (object, required)
  The normal, successful response of the operation.

## Response

```json
{
  "name": "string",
  "metadata": {},
  "done": true,
  "error": {
    "error_code": "string",
    "message": "string",
    "stack_trace": "string",
    "details": [
      {}
    ]
  },
  "response": {}
}
```

