---
title: "Add a persistent volume: its files survive restarts, redeploys and rollbacks. A running app is restarted (no rebuild) to mount it unless restart is false"
method: POST
path: "/projects/{projectId}/volumes"
tags: ["Volumes"]
---

# Add a persistent volume: its files survive restarts, redeploys and rollbacks. A running app is restarted (no rebuild) to mount it unless restart is false

`POST /projects/{projectId}/volumes`

## Request

- Base URL: `https://hostingsurge.com/api/v1`
- URL: `https://hostingsurge.com/api/v1/projects/{projectId}/volumes`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `__Host-hs_session`

## Path parameters

- `projectId` string, uuid, required

## Request body

- object
  - `name` string, required: Label, unique within the project: lower-case letters, digits and hyphens (e.g. data, uploads)
  - `mountPath` string, required: Absolute directory inside the app's container, e.g. /app/data. Not a system directory and not the app's code directory itself.
  - `sizeGb` integer, required: Size in GB; the sum over the organization counts against the plan's storage
  - `restart` boolean

## Response `201`

Created

- object
  - `volume` object, required
    - `id` string, uuid, required
    - `projectId` string, uuid, required
    - `name` string, required
    - `mountPath` string, required
    - `sizeGb` integer, required
    - `status` 'pending' | 'active' | 'error', required
    - `statusDetail` string, nullable, required
    - `usedBytes` integer, nullable, required
    - `usageMeasuredAt` string, nullable, required: ISO-8601 timestamp
    - `overQuota` boolean, required
    - `createdAt` string, required: ISO-8601 timestamp
    - `updatedAt` string, required: ISO-8601 timestamp
  - `applies` 'restarting' | 'next_restart' | 'next_start' | 'next_deploy' | 'restart_failed', required

## Other responses

- `400`: Invalid request: a bad name, mount path or size, a project type without volumes, or a delete without the exact name (code invalid_request)
- `401`: Missing or invalid session/token (code unauthorized)
- `402`: Plan limit reached: details.reason volume_storage (the team's volume storage) or volumes_per_project (code limit_reached)
- `403`: Authenticated but not permitted (code forbidden)
- `404`: Not found or not visible to the caller (code not_found)
- `409`: The name is taken or the mount path overlaps another volume (code conflict)
- `501`: Volumes are not available on this server yet (code not_configured)
- `503`: The hosting engine did not complete the change; nothing was changed (code provider_unavailable)

---

[API](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api.md) · [All operations](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hostingsurge/apis/hostingsurge-platform-api/revisions/4d08337cdff1?raw)
