Skip to main content
POST
/
projects
/
{project_id}
/
resources
/
copy
Copy Resources
curl --request POST \
  --url https://api.example.com/projects/{project_id}/resources/copy \
  --header 'Content-Type: application/json' \
  --data '
{
  "resource_ids": [
    "<string>"
  ],
  "tags": [],
  "rewire_dependencies": true,
  "depth": 1,
  "strategy": "stateless"
}
'
import requests

url = "https://api.example.com/projects/{project_id}/resources/copy"

payload = {
    "resource_ids": ["<string>"],
    "tags": [],
    "rewire_dependencies": True,
    "depth": 1,
    "strategy": "stateless"
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    resource_ids: ['<string>'],
    tags: [],
    rewire_dependencies: true,
    depth: 1,
    strategy: 'stateless'
  })
};

fetch('https://api.example.com/projects/{project_id}/resources/copy', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.example.com/projects/{project_id}/resources/copy",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'resource_ids' => [
        '<string>'
    ],
    'tags' => [
        
    ],
    'rewire_dependencies' => true,
    'depth' => 1,
    'strategy' => 'stateless'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

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

func main() {

	url := "https://api.example.com/projects/{project_id}/resources/copy"

	payload := strings.NewReader("{\n  \"resource_ids\": [\n    \"<string>\"\n  ],\n  \"tags\": [],\n  \"rewire_dependencies\": true,\n  \"depth\": 1,\n  \"strategy\": \"stateless\"\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(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.example.com/projects/{project_id}/resources/copy")
  .header("Content-Type", "application/json")
  .body("{\n  \"resource_ids\": [\n    \"<string>\"\n  ],\n  \"tags\": [],\n  \"rewire_dependencies\": true,\n  \"depth\": 1,\n  \"strategy\": \"stateless\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/projects/{project_id}/resources/copy")

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  \"resource_ids\": [\n    \"<string>\"\n  ],\n  \"tags\": [],\n  \"rewire_dependencies\": true,\n  \"depth\": 1,\n  \"strategy\": \"stateless\"\n}"

response = http.request(request)
puts response.read_body
{
  "copied": [
    {
      "source_id": "<string>",
      "copied_resource": {
        "provider": "<string>",
        "resource": "<string>",
        "name": "<string>",
        "project_id": "<string>",
        "id": "<string>",
        "created_at": "2023-11-07T05:31:56Z",
        "updated_at": "2023-11-07T05:31:56Z",
        "config": {},
        "resolved_config": {},
        "dependencies": [],
        "owner_references": [],
        "outputs": {},
        "error": "<string>",
        "lifecycle_state": "draft",
        "health": "healthy",
        "health_message": "<string>",
        "pending_event_id": "<string>",
        "pending_event_type": "<string>",
        "provisioned": false,
        "reconcile_count": 0,
        "version": 0,
        "tags": [
          "<string>"
        ],
        "provider_version": "<string>"
      },
      "error": "<string>"
    }
  ],
  "total": 123,
  "succeeded": 123,
  "failed": 123
}
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>",
      "input": "<unknown>",
      "ctx": {}
    }
  ]
}

Path Parameters

project_id
string
required

Body

application/json

Request body for the subgraph copy operation.

Attributes: resource_ids: SurrealDB resource IDs to copy (roots of the subgraph). tags: Tags to apply to all copied resources. rewire_dependencies: If True, rewrite dependencies between copied resources to point to their copies instead of the originals. depth: Maximum traversal depth from roots. None means unlimited. strategy: Default copy strategy for resources that do not specify one.

resource_ids
string[]
required
Minimum array length: 1
tags
string[]
rewire_dependencies
boolean
default:true
depth
integer | null
Required range: x >= 0
strategy
enum<string>
default:stateless

Strategy for how a resource should be copied.

Attributes: STATELESS: Config-only copy. The resource is duplicated by creating a new instance with the same (or modified) configuration. No data migration. STATEFUL: Data-bearing copy. The resource needs to clone underlying data (e.g., database contents, vector indices) and may produce patches for ongoing synchronization.

Available options:
stateless,
stateful

Response

Successful Response

Response body for the subgraph copy operation.

Attributes: copied: List of per-resource copy results. total: Total resources in the selected subgraph. succeeded: Number of resources successfully copied. failed: Number of resources that failed to copy.

copied
CopyResourceResult · object[]
required
total
integer
required
succeeded
integer
required
failed
integer
required