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

# Validate a Post

> Send the same JSON you use for the /post endpoint to /validate/post to verify content and parameters before publishing. Posts are not sent to networks.

Before publishing a post, you can verify the content and parameters are correct.
Send the exact same JSON you normally send to the `/post` endpoint to the `/validate/post` endpoint and it will return a response with any issues found.

<ul>
  <li>Validation tests based on Ayrshare's own internal algorithms.</li>
  <li>Posts are not sent to the social networks.</li>

  <li>
    Posts may still return an error by the social networks at the time of publishing, even with a
    passed validation.
  </li>
</ul>

Please see the [/post endpoint](https://www.ayrshare.com/docs/apis/post/overview.md) for sending a post.

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

## Body Parameters

Send the same body as you would send to the [/post endpoint](https://www.ayrshare.com/docs/apis/post/post.md).

```bash cURL theme={"system"}
curl --location "https://api.ayrshare.com/api/validate/post" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer API_KEY" \
--data '{
  "post": "This is amazing",
  "platforms": [
  "facebook"
  ],
  "mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"]
}'
```

```javascript JavaScript theme={"system"}
const apiKey = 'API_KEY'; // Replace with your actual API key

const requestData = {
  post: "This is amazing",
  platforms: ["facebook"],
  mediaUrls: ["https://img.ayrshare.com/012/gb.jpg"]
};

fetch('https://api.ayrshare.com/api/validate/post', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${apiKey}`
  },
  body: JSON.stringify(requestData)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```

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

payload = {
'post': 'This is amazing',
'platforms': ['facebook'],
'mediaUrls': ['https://img.ayrshare.com/012/gb.jpg']
}

headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}

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

print(r.json())

```

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

$payload = [
    'post' => 'This is amazing',
    'platforms' => ['facebook'],
    'mediaUrls' => ['https://img.ayrshare.com/012/gb.jpg']
];

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

$ch = curl_init('https://api.ayrshare.com/api/validate/post');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
```

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

class Program
{
    static async Task Main()
    {
        var payload = new
        {
            post = "This is amazing",
            platforms = new[] { "facebook" },
            mediaUrls = new[] { "https://img.ayrshare.com/012/gb.jpg" }
        };

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");

        try
        {
            var response = await client.PostAsJsonAsync(
                "https://api.ayrshare.com/api/validate/post",
                payload
            );

            response.EnsureSuccessStatusCode();
            var result = await response.Content.ReadAsStringAsync();
            Console.WriteLine(result);
        }
        catch (HttpRequestException ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}
```

```go Go theme={"system"}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "log"
    "net/http"
)

type PostRequest struct {
    Post      string   `json:"post"`
    Platforms []string `json:"platforms"`
    MediaUrls []string `json:"mediaUrls"`
}

func main() {
    // Create the request payload
    payload := PostRequest{
        Post:      "This is amazing",
        Platforms: []string{"facebook"},
        MediaUrls: []string{"https://img.ayrshare.com/012/gb.jpg"},
    }

    // Convert payload to JSON
    jsonData, err := json.Marshal(payload)
    if err != nil {
        log.Fatalf("Error marshaling JSON: %v", err)
    }

    // Create the request
    req, err := http.NewRequest(
        "POST",
        "https://api.ayrshare.com/api/validate/post",
        bytes.NewBuffer(jsonData),
    )
    if err != nil {
        log.Fatalf("Error creating request: %v", err)
    }

    // Set headers
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer API_KEY")

    // Make the request
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        log.Fatalf("Error making request: %v", err)
    }
    defer resp.Body.Close()

    // Read the response
    body, err := io.ReadAll(resp.Body)
    if err != nil {
        log.Fatalf("Error reading response: %v", err)
    }

    // Print the response
    fmt.Println(string(body))
}
```

```json 200: Success theme={"system"}
{
    "status": "success",
    "message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
}
```

```json 200: Successful Post with Non-Fatal Warnings theme={"system"}
{
  "status": "success",
  "message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
  "warnings": [
    {
      "action": "post",
      "status": "error",
      "code": 156,
      "message": "Twitter is not linked with Ayrshare. Please confirm the linkage on the Social Accounts page in your dashboard."
    }
  ]
}
```

```json 400: Error Post theme={"system"}
{
  "action": "post",
  "status": "error",
  "code": 136,
  "message": "Media URLs invalid. Please verify the media is an externally accessible URL."
}
```


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