# Apply watermark to an image

POST https://services.leadconnectorhq.com/social-media-posting/{locationId}/watermarks/add-image-watermark

Apply a watermark to an image using either a specific template ID or by resolving the template bound to a specific connected account.

If the same watermark + image combination has been processed before, the response returns immediately with `status: completed` and the output URL in `message`. Otherwise, processing is queued and the response returns `status: pending` with a `progressId`.

**Rate limits:** This endpoint may be rate-limited to prevent abuse. To resolve a template dynamically at publish time, pass `accountId` — the endpoint will resolve the template bound to that connected account. Use the [Get Accounts](./get-account) endpoint to look up account IDs.

Processing is asynchronous — the response returns a `progressId` that identifies this preview job.

**Document fields:**
- `status`: 'pending' | 'processing' | 'completed' | 'failed'
- `outputMediaUrl`: string, available when `status` is `completed`
- `errorMessage`: string, available when `status` is `failed`

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `socialplanner/watermarks.write`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location Id |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2023-02-21"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/social-media-posting/{locationId}/watermarks/add-image-watermark": {
      "post": {
        "summary": "Apply watermark to an image",
        "operationId": "applyWatermarkToAnImage",
        "description": "Apply a watermark to an image using either a specific template ID or by resolving the template bound to a specific connected account.\n\nIf the same watermark + image combination has been processed before, the response returns immediately with `status: completed` and the output URL in `message`. Otherwise, processing is queued and the response returns `status: pending` with a `progressId`.\n\n**Rate limits:** This endpoint may be rate-limited to prevent abuse. To resolve a template dynamically at publish time, pass `accountId` — the endpoint will resolve the template bound to that connected account. Use the [Get Accounts](./get-account) endpoint to look up account IDs.\n\nProcessing is asynchronous — the response returns a `progressId` that identifies this preview job.\n\n**Document fields:**\n- `status`: 'pending' | 'processing' | 'completed' | 'failed'\n- `outputMediaUrl`: string, available when `status` is `completed`\n- `errorMessage`: string, available when `status` is `failed`",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2023-02-21"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddImageWatermarkRequestDTO"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Watermark processing initiated or cached result returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AsyncWatermarkPreviewResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "socialplanner/watermarks.write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "AddImageWatermarkRequestDTO": {
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string",
            "description": "Template ID to apply. Required if `accountId` is not provided.",
            "example": "665f1bac78fda9b6c5f48012"
          },
          "accountId": {
            "type": "string",
            "description": "Connected account ID — the endpoint will resolve the template bound to this account. Required if `templateId` is not provided. Use the [Get Accounts](./get-account) endpoint to look up account IDs.",
            "example": "665f1bac78fda9b6c5f48099"
          },
          "inputMediaUrl": {
            "type": "string",
            "description": "Input media URL (either video or image)",
            "example": "http://example.com/media.mp4"
          },
          "mimeType": {
            "type": "string",
            "description": "MIME type of the media",
            "example": "image/png",
            "enum": [
              "image/jpeg",
              "image/jpg",
              "image/png",
              "image/gif",
              "image/bmp",
              "image/webp",
              "image/tiff",
              "image/svg+xml",
              "image/vnd.microsoft.icon",
              "image/heic",
              "image/heif",
              "video/mp4",
              "video/mpeg",
              "video/webm",
              "video/ogg",
              "video/x-msvideo",
              "video/x-ms-wmv",
              "video/quicktime",
              "video/x-flv",
              "video/x-matroska",
              "video/3gpp"
            ]
          },
          "postId": {
            "type": "string",
            "description": "Optional post ID to associate the watermark output with",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "watermarkId": {
            "type": "string",
            "description": "Optional cache key to fetch a previously-generated watermark result",
            "example": "ve9EPM428h8vShlRW1KT"
          },
          "updatePost": {
            "type": "boolean",
            "description": "Whether to update or create the linked post after watermarking",
            "example": false
          }
        },
        "required": [
          "inputMediaUrl"
        ],
        "title": "AddImageWatermarkRequestDTO"
      },
      "AsyncWatermarkPreviewResponseDTO": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success or Failure",
            "example": true
          },
          "statusCode": {
            "type": "number",
            "description": "Status Code",
            "example": 201
          },
          "message": {
            "type": "string",
            "description": "Message",
            "example": "Created Watermark Image"
          },
          "results": {
            "description": "Async processing result",
            "example": {
              "progressId": "abc123def456",
              "status": "pending",
              "message": "Watermark preview processing initiated."
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "progressId": {
                    "type": "string",
                    "description": "Progress ID identifying this asynchronous preview job",
                    "example": "abc123def456"
                  },
                  "status": {
                    "type": "string",
                    "description": "Current processing status",
                    "enum": [
                      "pending",
                      "processing",
                      "completed",
                      "failed"
                    ],
                    "example": "pending"
                  },
                  "message": {
                    "type": "string",
                    "description": "Status message",
                    "example": "Watermark preview processing initiated."
                  },
                  "outputMediaUrl": {
                    "type": "string",
                    "description": "URL of the watermarked output. Present only when status is completed (or on cache hit)",
                    "example": "https://storage.googleapis.com/bucket/watermarked.png"
                  }
                },
                "required": [
                  "progressId",
                  "status",
                  "message"
                ],
                "title": "AsyncWatermarkPreviewPayloadSchema"
              }
            ]
          }
        },
        "required": [
          "success",
          "statusCode",
          "message"
        ],
        "title": "AsyncWatermarkPreviewResponseDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const body = {
  "templateId": "665f1bac78fda9b6c5f48012",
  "accountId": "665f1bac78fda9b6c5f48099",
  "inputMediaUrl": "http://example.com/media.mp4",
  "mimeType": "image/png",
  "postId": "ve9EPM428h8vShlRW1KT",
  "watermarkId": "ve9EPM428h8vShlRW1KT",
  "updatePost": false
};

const response = await ghl.socialMediaPosting.applyWatermarkToAnImage('<LOCATIONID>', body);
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

body = {
    "templateId": "665f1bac78fda9b6c5f48012",
    "accountId": "665f1bac78fda9b6c5f48099",
    "inputMediaUrl": "http://example.com/media.mp4",
    "mimeType": "image/png",
    "postId": "ve9EPM428h8vShlRW1KT",
    "watermarkId": "ve9EPM428h8vShlRW1KT",
    "updatePost": false
}

response = await client.socialMediaPosting.apply_watermark_to_an_image('<LOCATIONID>', body=body)
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$body = [
    'templateId' => '665f1bac78fda9b6c5f48012',
    'accountId' => '665f1bac78fda9b6c5f48099',
    'inputMediaUrl' => 'http://example.com/media.mp4',
    'mimeType' => 'image/png',
    'postId' => 've9EPM428h8vShlRW1KT',
    'watermarkId' => 've9EPM428h8vShlRW1KT',
    'updatePost' => false
];

$response = $ghl->socialMediaPosting->applyWatermarkToAnImage('<LOCATIONID>', $body);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2023-02-21' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "templateId": "665f1bac78fda9b6c5f48012",
  "accountId": "665f1bac78fda9b6c5f48099",
  "inputMediaUrl": "http://example.com/media.mp4",
  "mimeType": "image/png",
  "postId": "ve9EPM428h8vShlRW1KT",
  "watermarkId": "ve9EPM428h8vShlRW1KT",
  "updatePost": false
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2023-02-21',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "templateId": "665f1bac78fda9b6c5f48012",
      "accountId": "665f1bac78fda9b6c5f48099",
      "inputMediaUrl": "http://example.com/media.mp4",
      "mimeType": "image/png",
      "postId": "ve9EPM428h8vShlRW1KT",
      "watermarkId": "ve9EPM428h8vShlRW1KT",
      "updatePost": false
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/social-media-posting/{locationId}/watermarks/add-image-watermark"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2023-02-21"
}

payload = {
    "templateId": "665f1bac78fda9b6c5f48012",
    "accountId": "665f1bac78fda9b6c5f48099",
    "inputMediaUrl": "http://example.com/media.mp4",
    "mimeType": "image/png",
    "postId": "ve9EPM428h8vShlRW1KT",
    "watermarkId": "ve9EPM428h8vShlRW1KT",
    "updatePost": false
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2023-02-21',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "templateId": "665f1bac78fda9b6c5f48012",
  "accountId": "665f1bac78fda9b6c5f48099",
  "inputMediaUrl": "http://example.com/media.mp4",
  "mimeType": "image/png",
  "postId": "ve9EPM428h8vShlRW1KT",
  "watermarkId": "ve9EPM428h8vShlRW1KT",
  "updatePost": false
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2023-02-21")
  .header("Content-Type", "application/json")
  .body("{\"templateId\":\"665f1bac78fda9b6c5f48012\",\"accountId\":\"665f1bac78fda9b6c5f48099\",\"inputMediaUrl\":\"http://example.com/media.mp4\",\"mimeType\":\"image/png\",\"postId\":\"ve9EPM428h8vShlRW1KT\",\"watermarkId\":\"ve9EPM428h8vShlRW1KT\",\"updatePost\":false}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark"
  payload := strings.NewReader(`{
  "templateId": "665f1bac78fda9b6c5f48012",
  "accountId": "665f1bac78fda9b6c5f48099",
  "inputMediaUrl": "http://example.com/media.mp4",
  "mimeType": "image/png",
  "postId": "ve9EPM428h8vShlRW1KT",
  "watermarkId": "ve9EPM428h8vShlRW1KT",
  "updatePost": false
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2023-02-21")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2023-02-21"
request["Content-Type"] = "application/json"
request.body = '{
  "templateId": "665f1bac78fda9b6c5f48012",
  "accountId": "665f1bac78fda9b6c5f48099",
  "inputMediaUrl": "http://example.com/media.mp4",
  "mimeType": "image/png",
  "postId": "ve9EPM428h8vShlRW1KT",
  "watermarkId": "ve9EPM428h8vShlRW1KT",
  "updatePost": false
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2023-02-21"
}

$body = '{
  "templateId": "665f1bac78fda9b6c5f48012",
  "accountId": "665f1bac78fda9b6c5f48099",
  "inputMediaUrl": "http://example.com/media.mp4",
  "mimeType": "image/png",
  "postId": "ve9EPM428h8vShlRW1KT",
  "watermarkId": "ve9EPM428h8vShlRW1KT",
  "updatePost": false
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/social-media-posting/<locationId>/watermarks/add-image-watermark' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
