> ## 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.

# Verify Media URL Exists

> Verify that a media file URL exists with a HEAD request and get its contentType. Use it with /media/uploadUrl; it checks reachability, not file contents.

Verify that the media file exists when uploaded. It should be used in conjunction with the /media/uploadUrl endpoint.

## 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`

## Verify Media URL Exists

`POST` `https://api.ayrshare.com/api/media/urlExists`

Verify that the media file exists when uploaded. It should be used in conjunction with the /media/uploadUrl endpoint.
You will also receive the `contentType` of the media file.

A `HEAD` request is made to the media URL to verify it exists.
Please be sure the hosting provider is not blocking the `HEAD` request.

This endpoint checks reachability only. It does not run the deeper media probe used before publishing, validate the file's contents or platform requirements, or prove that a social network's crawler can download the media. A successful response can therefore still be followed by a media-validation error during `/post`.

## Body Parameters

**mediaUrl** `string` *required*

URL of the media to verify exists.

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"mediaUrl": "https://img.ayrshare.com/012/vid.mp4"}' \
-X POST https://api.ayrshare.com/api/media/urlExists
```

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

fetch("https://api.ayrshare.com/api/media/urlExists", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${API_KEY}`
      },
      body: JSON.stringify({
        mediaUrl: "https://img.ayrshare.com/012/vid.mp4"
      }),
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);
```

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

payload = {'mediaUrl': 'https://img.ayrshare.com/012/vid.mp4'}
headers = {'Content-Type': 'application/json',
        'Authorization': 'Bearer API_KEY'}

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

print(r.json())
```

```php PHP theme={"system"}
<?php
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html

$client = new GuzzleHttp\Client();
$res = $client->request(
    'POST',
    'https://api.ayrshare.com/api/media/urlExists',
    [
        'headers' => [
            'Content-Type'      => 'application/json',
            'Authorization'     => 'Bearer API_KEY'
        ],
        'mediaUrl' => 'https://img.ayrshare.com/012/vid.mp4'
    ]
);

echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
```

```json 200: OK Media URL is valid theme={"system"}
{
    "status": "success",
    "statusCode": 200,
    "contentType": "image/jpeg"
}
```

```json 404: Not Found Media file not found theme={"system"}
{
  "status": "error",
  "statusCode": 404,
  "statusText": "Not Found"
}
```


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