# Create Storage Location

`POST /storage/locations` · Core · Storage & Schema

Registers one of the customer's own object stores as a storage location for the project. Both `region` (the platform region, checked against the project's data residency) and `providerRegion` (the bucket's own region at its provider) are required, and neither is derived from the other. A region outside the project's residency set is refused. The credential is referenced, never sent in the request. The change is audited as `data.write.org.settings_updated`.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `provider` | enum ("s3", "s3_compatible", "gcs", "azure_blob", "minio", "r2", "b2") | yes | The storage provider. `s3_compatible` is any S3 API at `endpointOverride`. |
| `bucketName` | string | yes | The bucket or container name at the provider. |
| `region` | string | yes | The platform region the data belongs to. It must be in the project's residency set, or the request is refused. |
| `providerRegion` | string | yes | The bucket's region at its provider, used for signing and the endpoint host: `auto` for R2, the location for GCS or Azure. |
| `endpointOverride` | string | no | A custom endpoint URL, for S3-compatible providers and MinIO. |
| `credentialRef` | string | yes | A reference to a credential you created beforehand, `kibo://byos-creds/sec_...`. Any other string is refused. |
| `custodyMode` | enum ("PLATFORM_MANAGED", "BYOK", "HYOK") | no | Who holds the encryption keys for data written to the location. Default `PLATFORM_MANAGED`. |
| `providerParams` | object | no | Non-secret settings the provider's credential exchange needs, as string keys with string values (each value at most 512 characters, at most 16 keys). The keys read per provider: - `r2` needs `accountId` and `parentAccessKeyId`. - `b2` needs `bucketId`. - `gcs` needs `serviceAccountEmail`. - `azure_blob` needs `azureTenantId`. - `s3`, `s3_compatible` and `minio` read none. Never put a secret here: the secret lives in the credential that `credentialRef` names, and these values are returned as stored on every read. |

## Responses

- **201**: Created

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | A storage location: a bucket at an outside provider that the project's storage writes to. |
| `data.id` | string | yes | The location id (`byos_...`). |
| `data.projectId` | string | yes | The project the location belongs to (`proj_...`). |
| `data.provider` | enum ("s3", "s3_compatible", "gcs", "azure_blob", "minio", "r2", "b2") | yes | The storage provider. `s3_compatible` is any S3 API at `endpointOverride`. |
| `data.bucketName` | string | yes | The bucket or container name at the provider. |
| `data.region` | string | yes | The platform region the data belongs to. |
| `data.providerRegion` | string | yes | The bucket's region at its provider. |
| `data.endpointOverride` | object | yes | The custom endpoint URL, or null when none is set. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.credentialRef` | string | yes | The credential reference (`kibo://byos-creds/sec_...`). The secret itself is never returned. |
| `data.custodyMode` | enum ("PLATFORM_MANAGED", "BYOK", "HYOK") | yes | Who holds the encryption keys for data written to the location. |
| `data.providerParams` | object | yes | The non-secret provider settings as stored, string keys with string values; an empty object when none were given. |
| `data.createdAt` | string (date-time) | yes | When the location was created. |
| `data.retiredAt` | object | yes | When the location was retired, or null while it is active. List results are always active; a read by id also returns a retired location. |
| _one of_ | | |  |
| _or_ | | |  |
| `meta` | object | yes |  |


## Errors

| HTTP | Code | When |
|---|---|---|
| 400 | `K9O_INVALID_REQUEST_SHAPE` | The request body failed schema validation, for example a provider value outside the supported vendor list; context.detail lists the failing fields. |
| 400 | `K9O_INVALID_FIELD_VALUE` | The credentialRef is not a valid kibo://byos-creds/<secId> reference; pre-create the credential secret and bind its reference. |
| 403 | `K9O_ACCESS_DENIED` | Your role does not permit provisioning storage locations for this project. |
| 403 | `K9O_CREDENTIAL_CUSTODY_MISMATCH` | The requested credential access mode does not match the custody mode configured for this project. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/storage/locations' \
  -H 'Authorization: Bearer $K9O_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/storage/locations', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({}),
});
const { data, meta } = await res.json();
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.storage.locations.create({})
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.storage.locations.create({})
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Storage.Locations.Create(ctx, map[string]any{})
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.storage.locations.create(json!({})).await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.storage().locations().create(Map.of())
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Storage.Locations.CreateAsync(new Dictionary<string, object> {  })
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.storage.locations.create({  })
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->storage->locations->create([])
```

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.storage.locations.create({})
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.storage.locations.create({})
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.storage.locations.create({})
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.storage.locations.create({})
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/create-storage-location
