How do I clone a linode via API?

I've successfully followed the instructions for creating a new linode via API, which looks like this:

curl -X POST https://api.linode.com/v4/linode/instances -H \"Authorization: Bearer $AccessToken\" -H \"Content-type: application/json\" -d '{\"type\": \"$Linode2GB\", \"region\": \"us-east\", \"label\": \"$LinodeName\"}'

I'm now trying to do the same thing to clone an newly created linode via API, but I can't seem to find the documentation that would do this in the same way. I have found something that looks like a php interface for doing this, but I'm not using PHP. I would just like to invoke something similar to the above to make the cloning happen.

Tips are appreciated. Thank you.

3 Replies

You can certainly clone a Linode via our API. You can use the Clone Linode endpoint to do so:

curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-X POST -d '{
"region": "us-east",
"type": "g6-standard-2",
"linode_id": 124,
"label": "cloned-linode",
"group": "Linode-Group",
"backups_enabled": true,
"disks": [25674],
"configs": [23456]
}' \
https://api.linode.com/v4/linode/instances/123/clone

Thanks very, very much. That's very helpful.

This appears to be how to clone an existing linode to an existing system.

One question though: The "linode_id". How do I know that value? I know the name of the linode I want to be the new clone, but I don't see any ID for it that is an integer value.

Thanks again.

@ackroyd If you are using Cloud Manager you'll find your Linode ID in the URL when you are on your Linode page. It looks something like this:

https://cloud.linode.com/linodes/$LINODE_ID/summary

You can also get the IDs of all your Linodes by curling the Linode instances endpoint:

curl -H "Authorization: Bearer $TOKEN" https://api.linode.com/v4/linode/instances

If you have several Linodes this can be a lot of info so you'll probably want to pipe the output through something like jq:

curl -H "Authorization: Bearer $TOKEN" https://api.linode.com/v4/linode/instances | jq .data

This info is also well formatted when using the Linode CLI:

linode-cli linodes list

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct