# Create Signed URL

`POST /storage/buckets/{bucketName}/objects/sign` · Core · Storage & Schema

Mints a pre-authenticated GET URL for one object in the bucket.

`expiresIn` is required (no default, R-15) and is accepted from 1 to 604800 seconds (7 days); a value outside that range is `400 K9O_INVALID_FIELD_VALUE`. The URL itself is valid for at most 900 seconds: a longer request is clamped to 900, not refused. The response's `expiresIn` is the effective lifetime, so read it from the response rather than assuming the requested value. A URL minted with an extension token never outlives that token.

A read role on the bucket suffices.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `bucketName` | path | yes | The bucket's name. It is unique within the project. Example: `"product-images"`. |
| `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 |
|---|---|---|---|
| `path` | string | yes | The object's path in the bucket, 1 to 1024 characters. It may contain slashes. |
| `expiresIn` | integer | yes | Requested lifetime in seconds (required, no default). Accepted 1..604800; the URL is clamped to 900 s, and the response's expiresIn is the effective value. |
| `download` | boolean | no | True to have the URL serve the object as an attachment (`Content-Disposition: attachment`). Default false. |

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | The signed URL and how long it lasts. |
| `data.signedUrl` | string | yes | A URL that reads the object without other credentials until it expires. Scoped to this one object. |
| `data.expiresIn` | integer | yes | Seconds the URL is valid for: the requested `expiresIn`, capped at 900, and for an extension token also at the token's remaining life. |
| `meta` | object | yes | Request metadata: cost, timing and correlation ids. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 401 | `K9O_UNAUTHENTICATED` | Authentication is required. |
| 403 | `K9O_RBAC_DENY` | The caller's project role does not permit this object operation. |
| 404 | `K9O_BUCKET_NOT_FOUND` | No bucket with this name exists in the project. |
| 400 | `K9O_INVALID_FIELD_VALUE` | expiresIn is required and must be an integer in 1..604800 seconds (R-15: no default expiry). |
| 403 | `K9O_ACCESS_DENIED` | The bucket's storage policy does not allow read (signed URL) for this caller (context.reason storage_policy_denied). Checked after the role and IAM checks; a bucket with no policy is unaffected. |
| 404 | `K9O_NOT_FOUND` | The object is past the bucket's deleteAfterDays age (counted from its last upload), so it reads as not found. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/storage/buckets/product-images/objects/sign' \
  -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/buckets/product-images/objects/sign', {
  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.from('<collection>').createSignedUrl()
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.from_("<collection>").create_signed_url()
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.From("<collection>").CreateSignedUrl()
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.from("<collection>").create_signed_url().await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.from("<collection>").createSignedUrl()
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.From("<collection>").CreateSignedUrlAsync()
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.from("<collection>").create_signed_url()
```

### k9o/sdk

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

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.from("<collection>").createSignedUrl()
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.from("<collection>").createSignedUrl()
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.from('<collection>').createSignedUrl()
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.from('<collection>').createSignedUrl()
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/create-signed-url
