How to operate with new forked sandbox?

Hi, I’d like to ask how to operate with the new forked sandbox?
here’s my code

const SiteClient = require('datocms-client').siteClient;
const client = new SiteClient('my api token')

client.environment.fork('primary', {
  id: 'test-sandbox'

My thought is to create a new client for it

const newClient = new SiteClient('my api token', {environment: 'test-sandbox'})
newClient....  // do the operate

Is there another way that I can implement it?

Hello @jeff.f.chen

I’m not sure i understood what you want to do, if what you want is to create a fork and start operating on it right away, an option would be the following snippet:

const SiteClient = require('datocms-client').siteClient;
let client = new SiteClient('my api token')

async function run() {
  const { id: environmentId } = await client.environment.fork('primary', {
    id: 'test-sandbox'

 client = new SiteClient('my api token', {environment: environmentId})

 client... //your operations

Hope this helps, let me know if i misunderstood what you were trying to do

1 Like

Yeah, this is what I thought.
Thank you!

1 Like