> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Set YouTube Watermark

> Set a watermark image on your YouTube channel for all videos. Configure when it shows during playback with the timingType, offsetMs, and durationMs fields.

Set a watermark image on your YouTube channel that will appear on all your videos. The watermark can be configured to appear at specific times during video playback.

<ul>
  <li>Position is automatically set to bottom-right corner (YouTube API default)</li>
  <li>All timing parameters `timingType`, `offsetMs`, and `durationMs` are required when setting a watermark</li>
  <li>Watermarks apply to all videos on the channel (existing and future)</li>
  <li>The watermark image must meet YouTube's [watermark media guidelines](https://www.ayrshare.com/docs/media-guidelines/youtube.md#watermark)</li>
  <li>You must have proper permissions to manage the YouTube channel</li>
</ul>

## Header Parameters

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## Body Parameters

**mediaUrls** `array` *required*

Array containing the watermark image URL. Only the first URL will be used.

Use a PNG or JPEG image. The URL must contain `.png`, `.jpg`, or `.jpeg`, otherwise the request
returns error `101`. YouTube rejects WebP images with error `307`.

The image must be square (1:1), 150 to 1920 pixels wide and high, and 10 MB or smaller.

**timingType** `string` *required*

When to show the watermark during video playback.

Available timingType options:

* `offsetFromStart` - Show watermark starting from a specific time after video begins
* `offsetFromEnd` - Show watermark starting from a specific time before video ends

**offsetMs** `number` *required*

Time offset in milliseconds. Must be a positive number.

* For `offsetFromStart`: Time after video starts to show watermark
* For `offsetFromEnd`: Time before video ends to show watermark

**durationMs** `number` *required*

How long to display the watermark in milliseconds. Must be a positive number.

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "mediaUrls": ["https://example.com/watermark.png"],
  "timingType": "offsetFromStart",
  "offsetMs": 15000,
  "durationMs": 30000
}' \
-X POST https://api.ayrshare.com/api/post/youTubeWatermark
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/post/youTubeWatermark", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${API_KEY}`
  },
  body: JSON.stringify({
    mediaUrls: ["https://example.com/watermark.png"],
    timingType: "offsetFromStart",
    offsetMs: 15000,
    durationMs: 30000
  }),
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```python Python theme={"system"}
import requests

payload = {
    'mediaUrls': ['https://example.com/watermark.png'],
    'timingType': 'offsetFromStart',
    'offsetMs': 15000,
    'durationMs': 30000
}
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer API_KEY'
}

r = requests.post('https://api.ayrshare.com/api/post/youTubeWatermark',
    json=payload,
    headers=headers)

print(r.json())
```

```php PHP theme={"system"}
<?php

$apiUrl = 'https://api.ayrshare.com/api/post/youTubeWatermark';
$apiKey = 'API_KEY';  // Replace 'API_KEY' with your actual API key

$headers = [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey,
];

$data = json_encode([
    'mediaUrls' => ['https://example.com/watermark.png'],
    'timingType' => 'offsetFromStart',
    'offsetMs' => 15000,
    'durationMs' => 30000
]);

$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_POSTFIELDS => $data
]);

$response = curl_exec($curl);

if ($response === false) {
    echo 'Curl error: ' . curl_error($curl);
} else {
    echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}

curl_close($curl);
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace SetYouTubeWatermark_csharp
{
    class SetYouTubeWatermark
    {
        private static readonly HttpClient client = new HttpClient();

        static async Task Main(string[] args)
        {
            string API_KEY = "API_KEY";
            string url = "https://api.ayrshare.com/api/post/youTubeWatermark";

            // Set up request headers
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);

            // Prepare JSON content
            string json = @"{
                ""mediaUrls"": [""https://example.com/watermark.png""],
                ""timingType"": ""offsetFromStart"",
                ""offsetMs"": 15000,
                ""durationMs"": 30000
            }";
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            try
            {
                // Send POST request
                HttpResponseMessage response = await client.PostAsync(url, content);
                response.EnsureSuccessStatusCode();

                // Read response
                string responseBody = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseBody);
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine($"Error: {e.Message}");
            }
        }
    }
}
```

```json 200 theme={"system"}
{
  "status": "success",
  "message": "Watermark set successfully",
  "mediaUrls": [
    "https://example.com/watermark.png"
  ],
  "timingType": "offsetFromStart",
  "offsetMs": 1000,
  "durationMs": 5000
}
```

```json 400 - Invalid Image Dimensions theme={"system"}
{
    "action": "post",
    "status": "error",
    "code": 140,
    "message": "The image aspect ratio must be between 1 and 1. Current image aspect ratio: 1085/723 (1.50). https://www.ayrshare.com/docs/media-guidelines/youtube "
}
```

```json 400 - Unsupported Format theme={"system"}
{
    "status": "error",
    "code": 307,
    "message": "Media type 'image/webp' is not supported. "
}
```

```json 403 - Permission Error theme={"system"}
{
  "status": "error",
  "code": 250,
  "message": "The watermark cannot be set for this channel. Please check that you have proper permissions and the channel is valid."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.