# Need help Creating a new layer with an image in the API

**URL:** https://forums.creativeclouddeveloper.com/t/need-help-creating-a-new-layer-with-an-image-in-the-api/5519
**Category:** UXP Plugin API
**Tags:** javascript
**Created:** [November 19, 2022, 8:58pm UTC](https://forums.creativeclouddeveloper.com/t/need-help-creating-a-new-layer-with-an-image-in-the-api/5519 "2022-11-19T20:58:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![stacho](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/stacho/32/2858_2.png) [@stacho](https://forums.creativeclouddeveloper.com/u/stacho)
#### Post date: [November 19, 2022, 8:58pm UTC](https://forums.creativeclouddeveloper.com/t/need-help-creating-a-new-layer-with-an-image-in-the-api/5519/1 "2022-11-19T20:58:48Z")

</div>

I am having trouble with Alchemist

The below code is giving a syntax error for some reason. It is the generated code

 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/e/ed2055a5b957a4ef3041e09f87b70b8c620cdbe4.png)

```auto
const batchPlay = require("photoshop").action.batchPlay;

const result = await batchPlay(
[
   {
      _obj: "placeEvent",
      ID: 2,
      null: {
         _path: "C:\Users\benja\Downloads\Page 1.png",
         _kind: "local"
      },
      freeTransformCenterState: {
         _enum: "quadCenterState",
         _value: "QCSAverage"
      },
      offset: {
         _obj: "offset",
         horizontal: {
            _unit: "pixelsUnit",
            _value: 0
         },
         vertical: {
            _unit: "pixelsUnit",
            _value: 0
         }
      },
      replaceLayer: {
         _obj: "placeEvent",
         to: {
            _ref: "layer",
            _id: 2
         }
      },
      _options: {
         dialogOptions: "dontDisplay"
      }
   }
],{
   synchronousExecution: false,
   modalBehavior: "fail"
});

```

Now the above being said, my true aim is just to be able to speed up a photobashing workflow. So how would I go about setting a new layer with an image that I get back from the cloud? What is the implementation, I can’t figure it out. Actions aren’t working right, and I am not seeing much in the API about setting a layer with a new image. However, I KNOW it can be done.
