---
title: "Create a server"
method: POST
path: "/projects/{project_id}/servers"
tags: ["Servers"]
---

# Create a server

`POST /projects/{project_id}/servers`

## Request

- Base URL: `https://sg.deployhq.com`
- URL: `https://sg.deployhq.com/projects/{project_id}/servers`
- Auth: HTTP basic

Creates a new server in the project. The protocol_type determines which additional connection parameters are required: SSH needs hostname and username, FTP needs hostname, username, and password, S3 needs bucket_name, access_key_id, and secret_access_key. For managed_vps, pass region, size, and os_image at the top level. For static_hosting, pass hosted_website_attributes at the top level. For custom_action, pass commands and a Docker image inside server: either docker_image, or docker_image_source curated with curated_template_id.

## Path parameters

- `project_id` string, required

## Request body

- ServerRegionSizeObject2
  - `server` object, required
    - `name` string
    - `protocol_type` string
    - `server_path` string
    - `email_notify_on` string
    - `root_path` string
    - `auto_deploy` boolean
    - `notification_email` string
    - `branch` string
    - `environment` string
    - `server_group_identifier` string
    - `agent_id` string
    - `enabled` boolean
    - `global_key_pair_id` string
    - `atomic` boolean
    - `atomic_strategy` string
    - `atomic_retention` integer
    - `docker_image` string
    - `docker_image_source` string
    - `curated_template_id` string
    - `commands` string
    - `halt_on_error` boolean
  - `region` string
  - `size` string
  - `os_image` string
  - `key_pair_identifier` string
  - `hosted_website_attributes` object
    - `subdomain` string
    - `spa_mode` boolean
    - `subdirectory` string

## Response `200`

Success

- Server
  - `id` integer
  - `identifier` string
  - `name` string
  - `protocol_type` string
  - `server_path` string
  - `last_revision` string, nullable
  - `preferred_branch` string
  - `branch` string
  - `notify_email` string
  - `server_group_identifier` string, nullable
  - `auto_deploy` boolean
  - `environment` string
  - `enabled` boolean
  - `agent` string, nullable
  - `atomic` boolean
  - `atomic_strategy` string
  - `atomic_retention` integer
  - `use_compression` boolean
  - `use_accelerated_transfer` boolean
  - `use_parallel_upload` boolean
  - `root_path` string
  - `position` integer
  - `created_at` string
  - `updated_at` string
  - `connection_checked_at` string, nullable
  - `connection_error_message` string, nullable
  - `hostname` string
  - `username` string
  - `port` integer
  - `use_ssh_keys` boolean
  - `host_key` string
  - `unlink_before_upload` boolean

## Other responses

- `401`: You are not authorized to access this resource. You need to authenticate yourself first.
- `403`: You are not allowed to access this resource. You do not have the necessary permissions.
- `422`: Unprocessable Entity
- `500`: An unexpected error occurred on the server. The server was unable to process the request.

---

[API](https://skmtc.dev/deployhq/apis/deployhq-api-interactive-documentation.md) · [All operations](https://skmtc.dev/deployhq/apis/deployhq-api-interactive-documentation/llms.txt) · [OpenAPI document](https://skmtc.dev/deployhq/apis/deployhq-api-interactive-documentation/revisions/830264ae58be?raw)
