> This page is for version v1.
> For other versions, use one of these documentation indexes:
> - v2 (default): https://docs.agentverse.ai/v-2/llms.txt
> - v1: https://docs.agentverse.ai/v-1/llms.txt

> 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.

# Duplicate Hosted Agent

POST https://agentverse.ai/v2/hosting/{address}/duplicate
Content-Type: application/json

Duplicate a hosted agent's code and optionally secrets and storage.

The source agent is read from its actual owner. The duplicate is created under
the personal account or the team from the ``X-Team`` request header.
Profile data must be registered separately via the hub API.

Reference: https://docs.agentverse.ai/v-1/api-reference/hosting-v-2/duplicate-hosted-agent-v-2

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `address` (string, required)

### Query parameters

- `no_cache` (boolean, optional, default: false)

### Body (application/json)

This endpoint expects a DuplicateHostedAgentOptions.

- `include_secrets` (boolean, optional, default: false) — Whether to copy secrets from the source agent to the duplicate.
- `include_storage` (boolean, optional, default: false) — Whether to copy storage from the source agent to the duplicate.

## Response

### 200

Successful Response

- `address` (string, required) — Bech32 address of the agent.
- `running` (boolean, required) — Whether the agent is currently running.
- `compiled` (boolean, optional, nullable) — Whether the agent code has been compiled.
- `code_digest` (string, optional, nullable) — Digest of the agent's code.
- `wallet_address` (string, optional, nullable) — Wallet address of the agent.
- `code_update_timestamp` (datetime, optional, nullable) — Last time the code was updated.
- `creation_timestamp` (datetime, optional, nullable) — Time when the agent was created.
- `revision` (integer, optional, default: 0) — Revision number of the agent.
- `metadata` (AgentMetadata, optional, nullable) — Metadata associated with the agent.

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### AgentMetadata

Model used to validate metadata for an agent. Framework specific fields will be added here to ensure valid serialization. Additional fields will simply be passed through.

- `geolocation` (AgentMetadataGeolocation, optional, nullable)

### ValidationError

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

### AgentMetadataGeolocation

- AgentGeoLocation: AgentGeoLocation
- AgentGeoLocationDetails: AgentGeoLocationDetails

### ValidationErrorLocItems

- string
- integer

### AgentGeoLocation

- `latitude` (double, required)
- `longitude` (double, required)
- `radius` (double, optional, nullable)

### AgentGeoLocationDetails

- `name` (string, optional, nullable) — the full agent location
- `description` (string, optional, nullable) — the description of the agent location
- `latitude` (double, optional, nullable) — the latitude of the agent location
- `longitude` (double, optional, nullable) — the longitude of the agent location
- `street` (string, optional, nullable) — the street where the agent is located
- `city` (string, optional, nullable) — the city where the agent is located
- `state` (string, optional, nullable) — the state where the agent is located
- `postal_code` (string, optional, nullable) — the postal code where the agent is located
- `country` (string, optional, nullable) — the country where the agent is located
- `url` (string, optional, nullable) — the url belonging to the agent location
- `image_url` (string, optional, nullable) — the image url belonging to the agent location

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "address": "string",
  "running": true,
  "compiled": true,
  "code_digest": "string",
  "wallet_address": "string",
  "code_update_timestamp": "2024-01-15T09:30:00Z",
  "creation_timestamp": "2024-01-15T09:30:00Z",
  "revision": 0,
  "metadata": {
    "geolocation": {
      "latitude": 1.1,
      "longitude": 1.1,
      "radius": 1.1
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://agentverse.ai/v2/hosting/address/duplicate"

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

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

print(response.json())
```

```javascript
const url = 'https://agentverse.ai/v2/hosting/address/duplicate';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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://agentverse.ai/v2/hosting/address/duplicate"

	payload := strings.NewReader("{}")

	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://agentverse.ai/v2/hosting/address/duplicate")

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 = "{}"

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://agentverse.ai/v2/hosting/address/duplicate")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://agentverse.ai/v2/hosting/address/duplicate', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://agentverse.ai/v2/hosting/address/duplicate");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://agentverse.ai/v2/hosting/address/duplicate")! 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()
```