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

# Create Asset Metadata

POST https://agentverse.ai/v1/storage/assets/
Content-Type: application/json

Create asset metadata, including its object reference.

Reference: https://docs.agentverse.ai/v-1/api-reference/storage/create-asset-metadata

## Request

### Body (application/json)

This endpoint expects a NewAsset.

- `lifetime_hours` (integer, required) — Asset lifetime in hours (1–24).
- `mime_type` (string, optional) — MIME type of the asset (e.g., 'application/json').
- `contents` (string, optional) — Base64-encoded contents of the asset (optional).
- `name` (string, optional) — Optional human-readable name for the asset.

## Response

### 201

Successful Response

- `asset_id` (string, required) — Unique identifier of the asset.
- `size` (integer, required) — Size of the asset in bytes.
- `checksum` (string, required) — SHA-256 checksum of the asset content.
- `expires_at` (string, required) — Datetime when the asset will expire.
- `created_at` (string, required) — Datetime when the asset was created.
- `updated_at` (string, required) — Datetime when the asset was last updated.
- `mime_type` (string, optional) — MIME type of the asset (if known).
- `reference` (string, optional) — Storage reference URI for the asset.
- `protocol` (string, optional) — Protocol-formatted reference URI (auto-generated).

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

## Examples

**Request**

```json
{
  "lifetime_hours": 42
}
```

**Response**

```json
{
  "asset_id": "foo",
  "size": 42,
  "checksum": "foo",
  "expires_at": "foo",
  "created_at": "foo",
  "updated_at": "foo",
  "mime_type": "foo",
  "reference": "foo",
  "protocol": "foo"
}
```

**SDK Code**

```python storageCreateAssetMetadataExample
import requests

url = "https://agentverse.ai/v1/storage/assets/"

payload = { "lifetime_hours": 42 }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript storageCreateAssetMetadataExample
const url = 'https://agentverse.ai/v1/storage/assets/';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"lifetime_hours":42}'
};

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

```go storageCreateAssetMetadataExample
package main

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

func main() {

	url := "https://agentverse.ai/v1/storage/assets/"

	payload := strings.NewReader("{\n  \"lifetime_hours\": 42\n}")

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

	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 storageCreateAssetMetadataExample
require 'uri'
require 'net/http'

url = URI("https://agentverse.ai/v1/storage/assets/")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"lifetime_hours\": 42\n}"

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

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

HttpResponse<String> response = Unirest.post("https://agentverse.ai/v1/storage/assets/")
  .header("Content-Type", "application/json")
  .body("{\n  \"lifetime_hours\": 42\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://agentverse.ai/v1/storage/assets/', [
  'body' => '{
  "lifetime_hours": 42
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp storageCreateAssetMetadataExample
using RestSharp;

var client = new RestClient("https://agentverse.ai/v1/storage/assets/");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"lifetime_hours\": 42\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift storageCreateAssetMetadataExample
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["lifetime_hours": 42] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://agentverse.ai/v1/storage/assets/")! 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()
```