API Status Get API Key

Create Video Post

Creating a post with a video works in the same way as creating a text post, with the addition of a video entry in the assets array. assets is an ordered list where each entry specifies exactly one of image, video, document, or link — pass a video entry with the URL you want to attach. You can also optionally provide a thumbnailUrl for the video thumbnail.

mutation CreatePost {
  createPost(
    input: {
      text: "Hello there, this is another one!"
      channelId: "some_channel_id"
      schedulingType: automatic
      mode: addToQueue
      assets: [{ video: { url: "https://example.com/video.mp4" } }]
    }
  ) {
    ... on PostActionSuccess {
      post {
        id
        text
        assets {
          source
        }
      }
    }
    ... on MutationError {
      message
    }
  }
}
curl -X POST 'https://api.buffer.com' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{"query": "mutation CreatePost {\n  createPost(\n    input: {\n      text: \"Hello there, this is another one!\"\n      channelId: \"some_channel_id\"\n      schedulingType: automatic\n      mode: addToQueue\n      assets: [{ video: { url: \"https://example.com/video.mp4\" } }]\n    }\n  ) {\n    ... on PostActionSuccess {\n      post {\n        id\n        text\n        assets {\n          source\n        }\n      }\n    }\n    ... on MutationError {\n      message\n    }\n  }\n}"}'
const response = await fetch('https://api.buffer.com', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY',
  },
  body: JSON.stringify({
    query: `
    mutation CreatePost {
      createPost(
        input: {
          text: "Hello there, this is another one!"
          channelId: "some_channel_id"
          schedulingType: automatic
          mode: addToQueue
          assets: [{ video: { url: "https://example.com/video.mp4" } }]
        }
      ) {
        ... on PostActionSuccess {
          post {
            id
            text
            assets {
              source
            }
          }
        }
        ... on MutationError {
          message
        }
      }
    }
    `,
  }),
});

const data = await response.json();
console.log(data);
<?php

$query = '
mutation CreatePost {
  createPost(
    input: {
      text: "Hello there, this is another one!"
      channelId: "some_channel_id"
      schedulingType: automatic
      mode: addToQueue
      assets: [{ video: { url: "https://example.com/video.mp4" } }]
    }
  ) {
    ... on PostActionSuccess {
      post {
        id
        text
        assets {
          source
        }
      }
    }
    ... on MutationError {
      message
    }
  }
}
';

$payload = [
    'query' => $query,
];

$ch = curl_init('https://api.buffer.com');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer YOUR_API_KEY',
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
    CURLOPT_RETURNTRANSFER => true,
]);

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

$data = json_decode($response, true);
print_r($data);