> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.kuudo.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.kuudo.com/_mcp/server.

# Attach server storage

POST https://app.kuudo.com/api/servers/{id}/storage
Content-Type: application/json

Storage must be active and in the same environment. Duplicate attachment conflicts. S3 Files remains subject to availability/prerequisites.

Requires every scope: `servers:write`, `storage:write`.

Reference: https://docs.kuudo.com/api-reference/servers/attach-server-storage

## Authentication

- `Authorization` header (bearer token, required) — JWT returned by POST /api/auth/token-exchange. Amazon, authorization invitations, and developer credentials require API-key-derived tokens.

## Request

### Path parameters

- `id` (integer, required) — Storage/server/environment resource ID as applicable.

### Body (application/json)

This endpoint expects an object.

- `storageResourceId` (integer, required)
- `mountPath` (string, optional, default: /data)

## Response

### 201

Success

- `attachment` (StorageAttachment, required) — Storage attachment; list responses may include additional resource details.

## Errors

### 400 Bad Request Error

Invalid request or unsupported resource state.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 401 Unauthorized Error

Missing or invalid credentials, or inactive machine principal.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 403 Forbidden Error

Insufficient scope, authorization policy, or entitlement.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 404 Not Found Error

Resource not found or not visible to this principal.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 409 Conflict Error

Conflicting state, duplicate resource, or idempotency conflict.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 422 Unprocessable Entity Error

Provider or organization availability/prerequisite failed.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 500 Internal Server Error

Internal error.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 503 Service Unavailable Error

Dependency unavailable or application maintenance.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

## Types

### StorageAttachment

Storage attachment; list responses may include additional resource details.

- `id` (integer, optional)
- `serverId` (integer, optional)
- `storageResourceId` (integer, optional)
- `mountPath` (string, optional)
- `resource` (StorageResource, optional) — Storage resource. Managed status can also be supplied beside the resource. Mode in persisted resource data can differ from the request label.

### ErrorError

- string
- ErrorError1

### StorageResource

Storage resource. Managed status can also be supplied beside the resource. Mode in persisted resource data can differ from the request label.

- `id` (integer, required)
- `environmentId` (integer, required)
- `name` (string, required)
- `bucketName` (string, required)
- `storageProvider` (enum, required)
  - Allowed values: `r2`, `s3-object`, `s3-files`, `gcs`
- `organizationId` (string, optional)
- `mode` (string, optional)
- `status` (string, optional)
- `endpointUrl` (string, optional, nullable)
- `providerMetadata` (map from string to any, optional)
- `createdAt` (datetime, optional, nullable)

### ErrorError1

- `code` (string, required)
- `message` (string, required)

## Examples

**Request**

```json
{
  "storageResourceId": 1
}
```

**Response**

```json
{
  "attachment": {
    "id": 1,
    "serverId": 1,
    "storageResourceId": 1,
    "mountPath": "string",
    "resource": {
      "id": 1,
      "environmentId": 1,
      "name": "string",
      "bucketName": "string",
      "storageProvider": "r2",
      "organizationId": "string",
      "mode": "string",
      "status": "string",
      "endpointUrl": "string",
      "providerMetadata": {},
      "createdAt": "2024-01-15T09:30:00Z"
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.kuudo.com/api/servers/1/storage"

payload = { "storageResourceId": 1 }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.kuudo.com/api/servers/1/storage';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"storageResourceId":1}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.kuudo.com/api/servers/1/storage"

	payload := strings.NewReader("{\n  \"storageResourceId\": 1\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.kuudo.com/api/servers/1/storage")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"storageResourceId\": 1\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.kuudo.com/api/servers/1/storage")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"storageResourceId\": 1\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.kuudo.com/api/servers/1/storage', [
  'body' => '{
  "storageResourceId": 1
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.kuudo.com/api/servers/1/storage");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"storageResourceId\": 1\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["storageResourceId": 1] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.kuudo.com/api/servers/1/storage")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```