# Add a volume

Source: https://openpanel.sh/docs/api/services/add-a-volume

Persistent storage at a path in the container. Its data lives on the server the service is placed on at its next deploy; a service with a volume runs as one instance.

`POST https://openpanel.sh/api/v1/services/{serviceId}/volumes`

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `serviceId` | path | yes | The service's id. |
| `Idempotency-Key` | header | no | Any unique string up to 255 characters. Sending the same request again with it returns the first answer instead of creating twice. |

## Request body

JSON, `VolumeCreate`.

## Responses

| Status | Meaning | Body |
|---|---|---|
| 201 | Add a volume | `application/json`, `Volume` |
| 401 | No valid credential was sent. | `application/problem+json`, `Problem` |
| 403 | The credential may not do this. | `application/problem+json`, `Problem` |
| 404 | Not found, or not visible to this credential. | `application/problem+json`, `Problem` |
| 409 | It clashes with something that exists, such as a name in use. | `application/problem+json`, `Problem` |
| 422 | The input was refused; detail says why. | `application/problem+json`, `Problem` |
| 429 | Too many requests; wait for Retry-After seconds. | `application/problem+json`, `Problem` |

## Schemas

### Problem

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "description": "A link to the error's explanation in the docs."
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable code: not_found, forbidden, invalid, conflict, rate_limited, not_implemented, …"
    },
    "detail": {
      "type": "string",
      "description": "What went wrong, in a sentence written for a person."
    }
  },
  "required": [
    "type",
    "title",
    "status",
    "code",
    "detail"
  ]
}
```

### Volume

```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "mountPath": {
      "type": "string"
    },
    "sizeGb": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ]
    },
    "serverId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "description": "The server its data lives on, set at the first deploy."
    }
  },
  "required": [
    "id",
    "mountPath",
    "sizeGb",
    "serverId"
  ]
}
```

### VolumeCreate

```json
{
  "type": "object",
  "properties": {
    "mountPath": {
      "type": "string",
      "maxLength": 255,
      "description": "An absolute path in the container, such as /data."
    },
    "sizeGb": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "mountPath"
  ],
  "additionalProperties": false
}
```