### Response from starting mask-objects job Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/create-mask/index.md Example JSON response containing the jobId and a self link to poll for job status. Use the href to check job completion. ```json { "jobId": "e3a13d81-a462-4b71-9964-28b2ef34aca7", "_links": { "self": { "href": "https://image.adobe.io/v1/status/e3a13d81-a462-4b71-9964-28b2ef34aca7" } } } ``` -------------------------------- ### Job status response example Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/get-job-status/index.md Example response from the status endpoint. The status field can be not_started, running, succeeded, or failed. errorDetails is present only when the job fails. ```json { "jobId": "de2415fb-82c6-47fc-b102-04ad651c5ed4", "status": "succeeded", "createdTime": "2025-01-20T10:35:00Z", "modifiedTime": "2025-01-20T10:40:00Z", "result": { "outputs": [] } } ``` -------------------------------- ### Generate Manifest Response Example Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/index.md Example JSON response from the generate-manifest call. Contains the jobId and the statusUrl to poll for job status. ```json { "jobId": "63c6e812-6cb8-43de-8a60-3681a9ec6feb", "statusUrl": "https://photoshop-api.adobe.io/v2/status/63c6e812-6cb8-43de-8a60-3681a9ec6feb" } ``` -------------------------------- ### Completed job response with succeeded status and output URL Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/fonts/index.md Example JSON response when the job completes successfully. Contains status "succeeded" and a result with an output URL. ```json { "jobId": "a619b1bd-75c8-427f-9660-61b23d2b8dc4", "status": "succeeded", "result": { "outputs": [ { "mediaType": "image/jpeg", "destination": { "url": "https://photoshop-api.adobe.io/v2/short-url/..." } } ] } } ``` -------------------------------- ### Start mask-objects job with curl POST Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/create-mask/index.md Submits an image via presigned URL to the /v1/mask-objects endpoint, initiating an asynchronous job. Requires Authorization Bearer token and x-api-key headers. Returns a jobId and status polling URL. ```shell curl -X POST \ https://image.adobe.io/v1/mask-objects \ -H "Authorization: Bearer $token" \ -H "x-api-key: $apiKey" \ -H "Content-Type: application/json" \ -d '{ "image": { "source": { "url": "" } } }' ``` -------------------------------- ### Example Event (Success) - JSON Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/webhooks/index.md Shows the JSON structure of a successful webhook event for a Photoshop API job, using the CloudEvents spec. The event type is com.adobe.photoshop-api.v2.generate-manifest.success and the data.status is "succeeded". ```json { "specversion": "1.0", "type": "com.adobe.photoshop-api.v2.generate-manifest.success", "source": "urn:aio_provider_metadata:cc_ffs_ps_job_status", "id": "7e3a89ce-d1f5-4b55-a9fc-682e3ac535e2", "time": "2025-01-20T10:40:00Z", "datacontenttype": "application/json", "requestorclientid": "cis_services", "adobeinternal": { "imsOrg": "36E3670466D07CD10A49422F@AdobeOrg" }, "data": { "jobId": "ad746e92-8991-69h3-ce4c-eg15e45d5h7h", "status": "succeeded", "createdTime": "2025-01-20T10:35:00Z", "modifiedTime": "2025-01-20T10:40:00Z" } } ``` -------------------------------- ### GET /v2/generate-manifest Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/photoshop-v2/manifest-response-reference.md Returns the current manifest response schema for the /v2/generate-manifest endpoint. This reference documents the response format layer type by layer type, starting with gradient layers. ```APIDOC ## [GET] /v2/generate-manifest ### Description Returns the current manifest response schema for the /v2/generate-manifest endpoint. This reference documents the response format layer type by layer type, starting with gradient layers. ### Method GET ### Endpoint /v2/generate-manifest ### Response #### Success Response (200) - **id** (number) - Layer ID - **name** (string) - Layer name - **type** (string) - Layer type, e.g., "gradient_layer" - **index** (number) - Layer index - **visible** (boolean) - Visibility flag - **protection** (array) - Protection flags - **linked** (array) - Linked layers - **userMask** (object) - User mask settings - **vectorMask** (object|null) - Vector mask settings - **proportionalScaling** (boolean) - Proportional scaling flag - **layerSettings** (object) - Layer settings - **effects** (object) - Effects - **pixelMask** (object|null) - Pixel mask - **blendOptions** (object) - Blend options - **compositeFrame** (object) - Composite frame - **referenceFrame** (object) - Reference frame - **compositeDimensions** (object) - Composite dimensions - **rotation** (number) - Rotation angle - **fill** (object) - Gradient fill object #### Response Example ```json { "id": 24, "name": "Gradient Fill 1", "type": "gradient_layer", "index": 12, "visible": true, "protection": ["none"], "linked": [], "userMask": { "density": 100, "feather": 0 }, "vectorMask": null, "proportionalScaling": false, "layerSettings": { "enabled": true }, "effects": {}, "pixelMask": null, "blendOptions": { "opacity": 100, "blendMode": "normal", "clipped": true, "interior": false, "fillOpacity": 100, "pixelMaskAsGlobalMask": false, "vectorMaskAsGlobalMask": false, "transparencyShapesLayer": true, "knockout": "none", "channelRestrictions": [], "blendRanges": [] }, "compositeFrame": { "absolute": { "left": 0, "top": 0, "right": 2100, "bottom": 1500 }, "relative": { "left": 0, "top": 0, "right": 2100, "bottom": 1500 } }, "referenceFrame": { "left": 0, "top": 0, "right": 0, "bottom": 0 }, "compositeDimensions": { "left": 0, "top": 0, "right": 2100, "bottom": 1500 }, "rotation": 0, "fill": { "type": "linear", "align": true, "angle": 90, "dither": false, "reverse": false, "scale": 100, "gradientAspectRatio": 1, "interpolationMethod": "smooth", "noisePreSeed": 10012, "offset": { "horizontal": 0, "vertical": 0 }, "gradient": { "type": "customStops", "value": { "gradientName": "Color to Transparent", "colorStops": [ { "type": "user_stop", "location": 0, "midpoint": 50, "color": { "mode": "rgb", "depth": 16, "components": [26985, 2858, 2858] } }, { "type": "user_stop", "location": 4096, "midpoint": 50, "color": { "mode": "rgb", "depth": 16, "components": [26985, 2858, 2858] } } ], "transparencyStops": [ { "location": 0, "midpoint": 50, "opacity": 100 }, { "location": 4096, "midpoint": 50, "opacity": 0 } ], "interpolation": 4096 } } } } ``` ``` -------------------------------- ### Access Token Response Example Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/index.md Example JSON response from the token endpoint. The access_token is used for API calls, token_type is bearer, and expires_in is 86399 seconds (24 hours). ```json { "access_token": "exampleAccessTokenAsdf123", "token_type": "bearer", "expires_in": 86399 } ``` -------------------------------- ### Succeeded Response (Granular Labels) Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/granular-labels/index.md Example succeeded response with granular labels. Contains a masks array with side-specific labels, scores, bounding boxes, and destination URLs. ```json { "jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "status": "succeeded", "masks": [ { "label": "Left Shoe", "score": 0.97, "boundingBox": { "left": 142, "top": 810, "width": 190, "height": 110 }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" }, { "label": "Right Shoe", "score": 0.96, "boundingBox": { "left": 352, "top": 812, "width": 188, "height": 108 }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" }, { "label": "Left Leg", "score": 0.98, "boundingBox": { "...": "..." }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" }, { "label": "Right Leg", "...": "..." }, { "label": "Upper Clothes", "...": "..." } ] } ``` -------------------------------- ### Successful status response with semantic and background masks Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/create-mask/index.md Example JSON response from a successful /status call. Contains semanticMasks for foreground objects and backgroundMasks for background regions, each with label, score, boundingBox, destination URL, and mediaType. ```json { "jobId": "e3a13d81-a462-4b71-9964-28b2ef34aca7", "status": "succeeded", "semanticMasks": [ { "label": "Person", "score": 0.98, "boundingBox": { "left": 120, "top": 45, "width": 320, "height": 610 }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" } ], "backgroundMasks": [ { "label": "Background", "score": 0.95, "boundingBox": { "left": 0, "top": 0, "width": 800, "height": 600 }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" } ] } ``` -------------------------------- ### Event Data Structure Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/webhooks/index.md Describes the JSON structure of webhook events using the CloudEvents specification, including examples for success and error events. ```APIDOC ## Event Data Structure ### Description Events are structured in JSON format using the CloudEvents spec. The event contains metadata and a data object with job information. ### Example Event (Success) ```json { "specversion": "1.0", "type": "com.adobe.photoshop-api.v2.generate-manifest.success", "source": "urn:aio_provider_metadata:cc_ffs_ps_job_status", "id": "7e3a89ce-d1f5-4b55-a9fc-682e3ac535e2", "time": "2025-01-20T10:40:00Z", "datacontenttype": "application/json", "requestorclientid": "cis_services", "adobeinternal": { "imsOrg": "36E3670466D07CD10A49422F@AdobeOrg" }, "data": { "jobId": "ad746e92-8991-69h3-ce4c-eg15e45d5h7h", "status": "succeeded", "createdTime": "2025-01-20T10:35:00Z", "modifiedTime": "2025-01-20T10:40:00Z" } } ``` ### Example Event (Error) ```json { "specversion": "1.0", "type": "com.adobe.photoshop-api.v2.create-composite.failed", "source": "urn:aio_provider_metadata:cc_ffs_ps_job_status", "id": "70b8efcb-38f2-4781-84ee-036013d3f5bc", "time": "2025-01-20T10:35:00Z", "datacontenttype": "application/json", "requestorclientid": "cis_services", "adobeinternal": { "imsOrg": "36E3670466D07CD10A49422F@AdobeOrg" }, "data": { "jobId": "9c635d81-7880-58g2-bd3b-df04d34c4g6g", "status": "failed", "createdTime": "2025-01-20T10:30:00Z", "modifiedTime": "2025-01-20T10:35:00Z", "errorDetails": [ { "error_code": "failed", "message": "Failed to process the composite image" } ] } } ``` ### Data Field Definitions | Field | Description | |-------|-------------| | `specversion` | CloudEvents specification version (always "1.0") | | `type` | Type of event used for event subscription routing | | `source` | Context in which an event happened | | `id` | Unique UUID generated per event | | `time` | Timestamp of the completion of the action | | `datacontenttype` | Content type of the data payload (always "application/json") | | `requestorclientid` | Client ID of the requestor (always "cis_services") | | `adobeinternal` | Adobe-specific extensions containing IMS organization information | | `data` | Event data object containing job information | | `data.jobId` | ID of the JOB | | `data.status` | Job status ("succeeded" or "failed") | | `data.createdTime` | Time stamp in ISO 8601 format when job was created | | `data.modifiedTime` | Time stamp in ISO 8601 format when job was last modified | | `data.result` | Job result containing outputs (optional for generate-manifest) | | `data.result.outputs` | List of job outputs as raw objects | | `data.errorDetails` | List of error details (only present for failed jobs) | ``` -------------------------------- ### Successful submission response (202) with jobId and statusUrl Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/fonts/index.md Example JSON response returned on successful submission. Contains jobId and statusUrl used for polling job status. ```json { "jobId": "a619b1bd-75c8-427f-9660-61b23d2b8dc4", "statusUrl": "https://photoshop-api.adobe.io/v2/status/a619b1bd-75c8-427f-9660-61b23d2b8dc4" } ``` -------------------------------- ### Example Event (Error) - JSON Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/webhooks/index.md Shows the JSON structure of a failed webhook event for a Photoshop API job, using the CloudEvents spec. The event type is com.adobe.photoshop-api.v2.create-composite.failed and the data.status is "failed", with errorDetails included. ```json { "specversion": "1.0", "type": "com.adobe.photoshop-api.v2.create-composite.failed", "source": "urn:aio_provider_metadata:cc_ffs_ps_job_status", "id": "70b8efcb-38f2-4781-84ee-036013d3f5bc", "time": "2025-01-20T10:35:00Z", "datacontenttype": "application/json", "requestorclientid": "cis_services", "adobeinternal": { "imsOrg": "36E3670466D07CD10A49422F@AdobeOrg" }, "data": { "jobId": "9c635d81-7880-58g2-bd3b-df04d34c4g6g", "status": "failed", "createdTime": "2025-01-20T10:30:00Z", "modifiedTime": "2025-01-20T10:35:00Z", "errorDetails": [ { "error_code": "failed", "message": "Failed to process the composite image" } ] } } ``` -------------------------------- ### Generate manifest for output PSD Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/workflows/smart_object/index.md POST /v2/generate-manifest request payload that reads the output PSD from Step 1 and returns a JSON manifest. Replace the placeholder with the presigned GET URL of the output PSD. The API initiates an asynchronous job; poll the href field for status and the manifest. ```json { "image": { "source": { "url": "" } }, "outputs": [ { "destination": { "embedded": "json" }, "mediaType": "application/json" } ] } ``` -------------------------------- ### Loading custom resources - Brushes and patterns Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Load custom brushes and patterns by providing URLs to .abr and .pat files. ```APIDOC ### Description Load custom brushes and patterns. ### Request Example ```json { "options": { "brushes": [ { "source": { "url": "https://your-storage.com/custom-brush.abr" } } ], "patterns": [ { "source": { "url": "https://your-storage.com/custom-pattern.pat" } } ] } } ``` ``` -------------------------------- ### Basic UXP Script Template Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/uxp/index.md Starter template for a UXP script that imports required modules, defines an async main function, and executes it. Uses modern JavaScript (ES6+) and the Photoshop UXP API. The script logs the active document name and flattens it, catching and rethrowing errors. ```javascript // Import required modules const { app } = require("photoshop"); const { storage } = require("uxp").storage; const fs = require("fs"); // Main async function async function main() { try { // Your Photoshop automation code here console.log("Document name:", app.activeDocument.name); // Perform operations await app.activeDocument.flatten(); } catch (error) { console.error("Error:", error); throw error; } } // Execute main function main(); ``` -------------------------------- ### Load custom brushes and patterns Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Specify custom brushes (`.abr`) and patterns (`.pat`) via `brushes` and `patterns` arrays. ```json { "options": { "brushes": [ { "source": { "url": "https://your-storage.com/custom-brush.abr" } } ], "patterns": [ { "source": { "url": "https://your-storage.com/custom-pattern.pat" } } ] } } ``` -------------------------------- ### Write and read files in UXP sandbox with additionalContents Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Shows file I/O inside the execute-actions sandbox: reads a config file from additionalContents using the placeholder __ADDITIONAL_CONTENTS_PATH_0__, optionally resizes the document via batchPlay, writes a report to plugin-temp:/process-report.json, and captures it as an output using scriptOutputPattern. ```bash curl -X POST "https://photoshop-api.adobe.io/v2/execute-actions" \ -H "Authorization: Bearer $TOKEN" \ -H "x-api-key: $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "image": { "source": { "url": "https://your-storage.com/input.psd" } }, "options": { "additionalContents": [ { "source": { "url": "https://your-storage.com/config.json" } } ], "uxp": { "source": { "content": "const { app } = require(\"photoshop\"); const fs = require(\"fs\"); async function main() { const configPath = \"__ADDITIONAL_CONTENTS_PATH_0__\"; const config = JSON.parse(fs.readFileSync(configPath, \"utf-8\")); const doc = app.activeDocument; if (config.applyResize && doc.width > config.maxWidth) { await app.batchPlay([{\"_obj\":\"imageSize\",\"width\":{\"_unit\":\"pixelsUnit\",\"_value\":config.maxWidth},\"constrainProportions\":true}], {}); } const report = { originalSize: { width: doc.width, height: doc.height }, configApplied: config, processedAt: new Date().toISOString() }; fs.writeFileSync(\"plugin-temp:/process-report.json\", JSON.stringify(report, null, 2), \"utf8\"); } main();", "contentType": "application/javascript" } } }, "outputs": [ { "mediaType": "image/jpeg", "destination": { "validityPeriod": 3600 } }, { "mediaType": "application/json", "destination": { "validityPeriod": 3600 }, "scriptOutputPattern": "process-report.json" } ] }' ``` -------------------------------- ### Remove Background API curl request Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/remove-background/index.md Sends a POST request to /v2/remove-background with a signed URL and mode 'cutout' to get a PNG with the subject on a transparent background. The response includes jobId and statusUrl; poll until status is succeeded or failed. ```shell curl -i -X POST \ https://image.adobe.io/v2/remove-background \ -H 'Authorization: Bearer $token' \ -H 'Content-Type: application/json' \ -H 'x-api-key: $apiKey' \ -d '{ "image": { "source": { "url": "" } }, "mode": "cutout", "output": { "mediaType": "image/png" } }' ``` -------------------------------- ### Submit create-composite job with font options (curl) Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/fonts/index.md POST to /v2/create-composite with an image source, fontOptions specifying defaultFontPostScriptName and missingFontStrategy, and a text layer edit. Requires Authorization Bearer token and X-Api-Key. A successful submission returns 202 with jobId and statusUrl. ```bash curl -X POST "https://photoshop-api.adobe.io/v2/create-composite" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "X-Api-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "image": { "source": { "url": "https://your-storage.example.com/input.psd" } }, "fontOptions": { "defaultFontPostScriptName": "Aboreto-Regular", "missingFontStrategy": "fail" }, "edits": { "layers": [ { "name": "Your Text Layer Name", "type": "text_layer", "operation": { "type": "edit" }, "text": { "content": "Hello from Adobe Fonts", "characterStyles": [ { "characterStyle": { "font": { "postScriptName": "Aboreto-Regular" }, "fontSize": 48 } } ] } } ] }, "outputs": [ { "mediaType": "image/jpeg", "destination": { "validityPeriod": 3600 } } ] }' ``` -------------------------------- ### Test input file path with curl Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/storage-solutions/index.md Use this command to verify that your public or pre-signed input URL is accessible by downloading the file. ```bash curl -X GET "" \ --output ``` -------------------------------- ### GET /v2/status/ Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/get-job-status/index.md Fetches the status of an asynchronous job submitted to the Photoshop API. Poll the statusUrl returned in the job submission response, or call this endpoint directly with the jobId. ```APIDOC ## [GET] /v2/status/ ### Description Fetches the status of an asynchronous job submitted to the Photoshop API. Poll the statusUrl returned in the job submission response, or call this endpoint directly with the jobId. ### Method GET ### Endpoint /v2/status/ ### Parameters #### Path Parameters - **JOB_ID** (string) - Required - The ID of the job to check. ### Response #### Success Response (200) - **jobId** (string) - ID of the job - **status** (string) - One of `not_started`, `running`, `succeeded`, or `failed` - **createdTime** (string) - Time the job was created, in ISO 8601 format - **modifiedTime** (string) - Time the job was last modified, in ISO 8601 format - **result.outputs** (array) - List of job outputs. The shape of each output depends on the endpoint that created the job. - **errorDetails** (array) - List of `errorCode` and `message` entries. Present only when the job failed. #### Response Example ```json { "jobId": "de2415fb-82c6-47fc-b102-04ad651c5ed4", "status": "succeeded", "createdTime": "2025-01-20T10:35:00Z", "modifiedTime": "2025-01-20T10:40:00Z", "result": { "outputs": [] } } ``` ### Request Example ```shell curl -X GET \ https://photoshop-api.adobe.io/v2/status/ \ -H "Authorization: Bearer $token" \ -H "x-api-key: $apiKey" ``` ``` -------------------------------- ### Test output file path with curl Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/getting-started/storage-solutions/index.md Use this command to verify that your pre-signed output URL is configured correctly for uploads. ```bash curl -X PUT "" \ -d ``` -------------------------------- ### GET https://image.adobe.io/v1/status/{jobId} Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/granular-labels/index.md Polls the status of an asynchronous job. Poll until `status` is `succeeded`, then retrieve the `masks` array. ```APIDOC ## GET https://image.adobe.io/v1/status/{jobId} ### Description Polls the status of an asynchronous job. Poll until `status` is `succeeded`, then retrieve the `masks` array. ### Method GET ### Endpoint https://image.adobe.io/v1/status/{jobId} ### Parameters #### Path Parameters - **jobId** (string) - Required - The job ID returned in the initial response. ### Response #### Success Response (200) Returns the job status and, when succeeded, the `masks` array. #### Response Example { "jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "status": "succeeded", "masks": [ { "label": "Left Shoe", "score": 0.97, "boundingBox": { "left": 142, "top": 810, "width": 190, "height": 110 }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" }, { "label": "Right Shoe", "score": 0.96, "boundingBox": { "left": 352, "top": 812, "width": 188, "height": 108 }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" }, { "label": "Left Leg", "score": 0.98, "boundingBox": { "...": "..." }, "destination": { "url": "https://storage.adobe.io/..." }, "mediaType": "image/png" }, { "label": "Right Leg", "...": "..." }, { "label": "Upper Clothes", "...": "..." } ] } ``` -------------------------------- ### Complete JavaScript sample for Fill Masked Areas API Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/using-fill-mask/index.md Full implementation using axios. Requires ACCESS_TOKEN environment variable, X-Api-Key header, and service base URL. Makes a POST to /v1/fill-masked-areas, then polls the status URL until the result is ready. ```js const axios = require("axios"); // Ensure ACCESS_TOKEN environment variable is there with the correct value of access token const { ACCESS_TOKEN } = process.env; // REST API's status codes const STATUS_ACCEPTED = 202; const DEFAULT_SERVICE_BASE_URL = "https://ff-services-api-stage.adobe.io"; // object containing api endpoints const apiEndpoints = { FILL_MASKED_AREAS: "/v1/fill-masked-areas", }; /** * Function to make get api call * @param {string} url - Api end point * @param {object} headers - headers to be passed * @returns {Promise} - Response of the API call */ function makeGetCall(url, headers) { return axios.get(url, { headers }); } /** * Function to make post api call * @param {string} url - Api end point * @param {object} payload - Payload to be passed * @param {object} headers - Headers to be passed * @returns {Promise} - Response of the API call */ function makePostCall(url, payload, headers) { return axios.post(url, payload, { headers }); } /** * Function to make service api calls * - post api call to get the status url * - get api call to get the result * @param {string} url - Api end point * @param {object} payload - Payload to be passed * @param {object} headers - Headers to be passed * @returns {Promise} - Object of image urls and its properties */ async function makeServiceApiCall(url, payload, headers) { const postResponse = await makePostCall(url, payload, headers); if (postResponse.status === STATUS_ACCEPTED) { const statusUrl = postResponse.data.statusUrl; const getResult = await makeGetCall(statusUrl, headers); return getResult.data; } else { console.log("Error in serviceApiCall post operation ", postResponse); } } /** * Function to fill masked areas of image based on the masks provided * @param {object} payload - payload with image and masks * @param {object} headers - headers to be passed * @returns {Promise} - result of the api response */ async function fillMaskedArea(headers, serviceBaseUrl, payload) { const endpoint = new URL( apiEndpoints.FILL_MASKED_AREAS, serviceBaseUrl ).toString(); return makeServiceApiCall(endpoint, payload, headers); } /** * Function to fetch token * @returns {Promise} - token string */ async function fetchAccessToken() { return `Bearer ${ACCESS_TOKEN}`; } /** * Function to generate headers * @returns {Promise} - headers object */ async function generateHeaders() { const token = await fetchAccessToken(); const headers = { "Content-Type": "application/json", // Update X-Api-Key with the actual api key "X-Api-Key": "", Authorization: token, }; return headers; } async function main() { // update serviceBaseUrl const serviceBaseUrl = "" || DEFAULT_SERVICE_BASE_URL; // update sourceImageUrl with the source image url const sourceImageUrl = ""; // update maskUrlArray with the mask urls const maskUrlArray = [""]; const headers = await generateHeaders(); const payload = { image: { source: { url: sourceImageUrl } }, masks: maskUrlArray.map((mask) => ({ source: { url: mask } })) }; const result = await fillMaskedArea(headers, serviceBaseUrl, payload); const finalImage = result.image.destination.url; return finalImage; } main(); ``` -------------------------------- ### Script output patterns Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Capture files created by UXP scripts using glob patterns. ```APIDOC ### Description Capture script output files using glob patterns. ### Request Example ```json { "outputs": [ { "mediaType": "image/png", "destination": { "validityPeriod": 3600 }, "scriptOutputPattern": "layer-*.png" } ] } ``` ``` -------------------------------- ### GET /v2/status/{jobId} Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/fonts/index.md Polls the status of a submitted job using the statusUrl returned from the create-composite endpoint. Returns job status and output URLs when completed. ```APIDOC ## [GET] /v2/status/{jobId} ### Description Polls the status of a submitted job using the statusUrl returned from the create-composite endpoint. Returns job status and output URLs when completed. ### Method GET ### Endpoint https://photoshop-api.adobe.io/v2/status/{jobId} ### Parameters #### Path Parameters - **jobId** (string) - Required - The unique identifier of the job. ### Response #### Success Response (200) - **jobId** (string) - Unique identifier for the job. - **status** (string) - Status of the job (e.g., "succeeded"). - **result** (object) - Result details. - **result.outputs** (array) - List of output files. - **result.outputs[].mediaType** (string) - Media type of the output. - **result.outputs[].destination** (object) - Destination details. - **result.outputs[].destination.url** (string) - URL to access the output. ### Request Example ```bash curl -X GET "https://photoshop-api.adobe.io/v2/status/YOUR_JOB_ID" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "X-Api-Key: YOUR_API_KEY" ``` #### Response Example ```json { "jobId": "a619b1bd-75c8-427f-9660-61b23d2b8dc4", "status": "succeeded", "result": { "outputs": [ { "mediaType": "image/jpeg", "destination": { "url": "https://photoshop-api.adobe.io/v2/short-url/..." } } ] } } ``` ``` -------------------------------- ### POST /v2/execute-actions - File I/O with additionalContents and scriptOutputPattern Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Executes a UXP script that reads a configuration file from additionalContents and writes a processing report to plugin-temp:/, which is then captured as an output using scriptOutputPattern. ```APIDOC ## [POST] https://photoshop-api.adobe.io/v2/execute-actions ### Description Executes a UXP script that reads a configuration file from additionalContents and writes a processing report to plugin-temp:/, which is then captured as an output using scriptOutputPattern. ### Method POST ### Endpoint https://photoshop-api.adobe.io/v2/execute-actions ### Parameters #### Request Body - **image.source.url** (string) - Required - URL of the input PSD file. - **options.additionalContents[].source.url** (string) - Optional - URL of an external file to be passed to the script. - **options.uxp.source.content** (string) - Required - The UXP script content (JavaScript). - **options.uxp.source.contentType** (string) - Required - MIME type of the script content (e.g., application/javascript). - **outputs[].mediaType** (string) - Required - Media type of the output (e.g., image/jpeg, application/json). - **outputs[].destination.validityPeriod** (number) - Optional - Validity period for the output URL in seconds. - **outputs[].scriptOutputPattern** (string) - Optional - Pattern to match files written to plugin-temp:/ for output capture. ### Response #### Success Response (200) - No response schema provided in the source. ### Request Example ```bash curl -X POST "https://photoshop-api.adobe.io/v2/execute-actions" \ -H "Authorization: Bearer $TOKEN" \ -H "x-api-key: $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "image": { "source": { "url": "https://your-storage.com/input.psd" } }, "options": { "additionalContents": [ { "source": { "url": "https://your-storage.com/config.json" } } ], "uxp": { "source": { "content": "const { app } = require(\"photoshop\"); const fs = require(\"fs\"); async function main() { const configPath = \"__ADDITIONAL_CONTENTS_PATH_0__\"; const config = JSON.parse(fs.readFileSync(configPath, \"utf-8\")); const doc = app.activeDocument; if (config.applyResize && doc.width > config.maxWidth) { await app.batchPlay([{\"_obj\":\"imageSize\",\"width\":{\"_unit\":\"pixelsUnit\",\"_value\":config.maxWidth},\"constrainProportions\":true}], {}); } const report = { originalSize: { width: doc.width, height: doc.height }, configApplied: config, processedAt: new Date().toISOString() }; fs.writeFileSync(\"plugin-temp:/process-report.json\", JSON.stringify(report, null, 2), \"utf8\"); } main();", "contentType": "application/javascript" } } }, "outputs": [ { "mediaType": "image/jpeg", "destination": { "validityPeriod": 3600 } }, { "mediaType": "application/json", "destination": { "validityPeriod": 3600 }, "scriptOutputPattern": "process-report.json" } ] }' ``` ``` -------------------------------- ### Fetch job status with curl Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/get-job-status/index.md Poll the statusUrl or call /v2/status/ with the returned jobId. Requires Authorization Bearer token and x-api-key header. ```shell curl -X GET \ https://photoshop-api.adobe.io/v2/status/ \ -H "Authorization: Bearer $token" \ -H "x-api-key: $apiKey" ``` -------------------------------- ### Submit a job response Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/get-job-status/index.md Response body from a successfully submitted Photoshop API V2 job, containing the job ID and a URL to poll for status. ```json { "jobId": "de2415fb-82c6-47fc-b102-04ad651c5ed4", "statusUrl": "https://photoshop-api.adobe.io/v2/status/de2415fb-82c6-47fc-b102-04ad651c5ed4" } ``` -------------------------------- ### Capture UXP script output with glob pattern Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Use `scriptOutputPattern` to capture files created by UXP scripts. The pattern matches filenames like `layer-*.png`. ```json { "outputs": [ { "mediaType": "image/png", "destination": { "validityPeriod": 3600 }, "scriptOutputPattern": "layer-*.png" } ] } ``` -------------------------------- ### Combining actions with UXP scripts Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Combine multiple actions with one UXP script in a single request. Actions execute first, then the UXP script runs. Only one UXP script is allowed per request, but up to 10 actions can be included. ```APIDOC ### Description Combine actions with a UXP script. ### Request Example ```json { "options": { "actions": [ { "source": { "content": "[{\"_obj\":\"imageSize\",\"width\":{\"_unit\":\"pixelsUnit\",\"_value\":1920}}]", "contentType": "application/json" } } ], "uxp": { "source": { "content": "const app = require('photoshop').app; const doc = app.activeDocument; /* custom UXP code */", "contentType": "application/javascript" } } } } ``` ``` -------------------------------- ### Poll job status using statusUrl (curl) Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/fonts/index.md GET request to the statusUrl returned in the submission response. Replace YOUR_JOB_ID with the actual job ID. Requires the same Authorization and X-Api-Key headers. ```bash curl -X GET "https://photoshop-api.adobe.io/v2/status/YOUR_JOB_ID" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "X-Api-Key: YOUR_API_KEY" ``` -------------------------------- ### Poll mask-objects job status with curl GET Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/create-mask/index.md Polls the /status endpoint using the jobId from the previous response. Requires the same Authorization and x-api-key headers. Returns job status and masks when complete. ```shell curl -X GET \ https://image.adobe.io/v1/status/e3a13d81-a462-4b71-9964-28b2ef34aca7 \ -H "Authorization: Bearer $token" \ -H "x-api-key: $apiKey" \ -H "Content-Type: application/json" ``` -------------------------------- ### Using additional contents Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Composite multiple images using placeholders. Use `__ADDITIONAL_CONTENTS_PATH_{index}__` in your action JSON or UXP script where `{index}` is the zero-based index of the `additionalContents` array. ```APIDOC ### Description Use additional contents to composite multiple images. ### Request Example ```json { "image": { "source": { "url": "https://your-storage.com/background.jpg" } }, "options": { "additionalContents": [ { "source": { "url": "https://your-storage.com/logo.png" } }, { "source": { "url": "https://your-storage.com/overlay.png" } } ], "actions": [ { "source": { "content": "[{\"_obj\":\"placeEvent\",\"null\":{\"_kind\":\"local\",\"_path\":\"__ADDITIONAL_CONTENTS_PATH_0__\"}}]", "contentType": "application/json" } } ] } } ``` ``` -------------------------------- ### Composite images using additionalContents placeholders Source: https://github.com/adobedocs/ffs-photoshop-api/blob/main/src/pages/guides/execute-actions/index.md Use `__ADDITIONAL_CONTENTS_PATH_{index}__` in action JSON or UXP script to reference additional images. The index is zero-based. ```json { "image": { "source": { "url": "https://your-storage.com/background.jpg" } }, "options": { "additionalContents": [ { "source": { "url": "https://your-storage.com/logo.png" } }, { "source": { "url": "https://your-storage.com/overlay.png" } } ], "actions": [ { "source": { "content": "[{\"_obj\":\"placeEvent\",\"null\":{\"_kind\":\"local\",\"_path\":\"__ADDITIONAL_CONTENTS_PATH_0__\"}}]", "contentType": "application/json" } } ] } } ```