> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs-beta.getzep.com/v4/cloning-graphs/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-beta.getzep.com/_mcp/server. # Cloning Graphs ## Overview The `graph.clone` method creates a complete copy of a graph with a new identifier. Clone a user graph to test or migrate one user's context. Clone a shared Context Graph to create an isolated test copy of an account, project, product, or business-domain graph, or to use a maintained graph as a template. The clone request has no body fields. You give only the UUID of the source graph. Zep creates the target graph, gives it a new UUID, and returns the new graph and a task in the response. The response contains the UUID of the copy at once, so store it before the task completes. Use the task to track the copy of the graph data. See [Check data ingestion status](/check-data-ingestion-status#checking-operation-status-with-task-polling) for polling instructions. > **Note** > > The copy is always a new shared Context Graph, also when the source is a user graph. A clone does not create a user, and it does not copy data into an existing graph. ## Clone a Graph #### User Graph To clone a user graph, use the `graph_uuid` of the user as the source. **`Python`** ```python Python from zep_cloud.client import Zep client = Zep( api_key=API_KEY, ) # The graph_uuid that you stored when you created the user user = client.user.get(zep_user_uuid) # Clone the user graph to a new Context Graph result = client.graph.clone(user.graph_uuid, request={}) # Store the UUID of the copy before the task completes zep_graph_uuid = result.graph.uuid_ print(f"Cloned graph UUID: {zep_graph_uuid}") print(f"Clone task UUID: {result.task.uuid_}") ``` **`TypeScript`** ```typescript TypeScript import { ZepClient } from "@getzep/zep-cloud"; const client = new ZepClient({ apiKey: API_KEY, }); // The graphUuid that you stored when you created the user const user = await client.user.get(zepUserUuid); // Clone the user graph to a new Context Graph const result = await client.graph.clone(user.graphUuid!, {}); // Store the UUID of the copy before the task completes const zepGraphUuid = result.graph?.uuid; console.log(`Cloned graph UUID: ${zepGraphUuid}`); console.log(`Clone task UUID: ${result.task?.uuid}`); ``` **`Go`** ```go Go import ( "context" "fmt" "log" zep "github.com/getzep/zep-go/v4" zepclient "github.com/getzep/zep-go/v4/client" "github.com/getzep/zep-go/v4/option" ) ctx := context.TODO() client := zepclient.NewClient( option.WithAPIKey(apiKey), ) // The graph UUID that you stored when you created the user user, err := client.User.Get(ctx, zepUserUUID) if err != nil { log.Fatalf("Failed to get user: %v", err) } if user.GraphUUID == nil { log.Fatal("The user has no graph UUID") } // Clone the user graph to a new Context Graph result, err := client.Graph.Clone(ctx, *user.GraphUUID, zep.CloneGraphRequest{}) if err != nil { log.Fatalf("Failed to clone graph: %v", err) } // Store the UUID of the copy before the task completes fmt.Printf("Cloned graph UUID: %s\n", *result.Graph.UUID) fmt.Printf("Clone task UUID: %s\n", *result.Task.UUID) ``` #### Context Graph **`Python`** ```python Python from zep_cloud.client import Zep client = Zep( api_key=API_KEY, ) # Clone a shared Context Graph. Zep generates the UUID of the copy. result = client.graph.clone(source_graph_uuid, request={}) # Store the UUID of the copy before the task completes zep_graph_uuid = result.graph.uuid_ print(f"Cloned graph UUID: {zep_graph_uuid}") print(f"Clone task UUID: {result.task.uuid_}") ``` **`TypeScript`** ```typescript TypeScript import { ZepClient } from "@getzep/zep-cloud"; const client = new ZepClient({ apiKey: API_KEY, }); // Clone a shared Context Graph. Zep generates the UUID of the copy. const result = await client.graph.clone(sourceGraphUuid, {}); // Store the UUID of the copy before the task completes const zepGraphUuid = result.graph?.uuid; console.log(`Cloned graph UUID: ${zepGraphUuid}`); console.log(`Clone task UUID: ${result.task?.uuid}`); ``` **`Go`** ```go Go import ( "context" "fmt" "log" zep "github.com/getzep/zep-go/v4" zepclient "github.com/getzep/zep-go/v4/client" "github.com/getzep/zep-go/v4/option" ) client := zepclient.NewClient( option.WithAPIKey(apiKey), ) // Clone a shared Context Graph. Zep generates the UUID of the copy. result, err := client.Graph.Clone(context.TODO(), sourceGraphUUID, zep.CloneGraphRequest{}) if err != nil { log.Fatalf("Failed to clone graph: %v", err) } // Store the UUID of the copy before the task completes fmt.Printf("Cloned graph UUID: %s\n", *result.Graph.UUID) fmt.Printf("Clone task UUID: %s\n", *result.Task.UUID) ``` ## Key Behaviors and Limitations * **New target**: Zep always creates a new graph for the copy. You cannot select the identifier of the copy, and you cannot clone into an existing graph. * **Identifier at once**: The response contains the new graph with its `uuid` before the copy of the data is complete. Read data from the copy after the task succeeds. * **User graphs**: The copy of a user graph is a shared Context Graph. It is not a user graph, and Zep does not create a new user for it. * **Retries**: Each clone call creates a new graph. If your application can retry a clone, you can send an `Idempotency-Key` with the call: `idempotency_key` in Python, `idempotencyKey` in the TypeScript request options, or `option.WithIdempotencyKey` in Go. > Create complete copies of graphs with new identifiers for testing, migration, or templating