[Go to site: main page, start]

Create Idea

Create an idea post for a specified Organization, using the provided content.

mutation CreateIdea {
  createIdea(input: {
    organizationId: "some_organization_id",
    content: {
      title: "New Idea from GraphQL API"
      text: "This is the text of the new idea created via the GraphQL API."
    }
  }) {
    ... on Idea {
      id
      content {
        title
        text
      }
    }
  }
}
curl -X POST 'https://api.buffer.com' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{"query": "mutation CreateIdea {\n  createIdea(input: {\n    organizationId: \"some_organization_id\",\n    content: {\n      title: \"New Idea from GraphQL API\"\n      text: \"This is the text of the new idea created via the GraphQL API.\"\n    }\n  }) {\n    ... on Idea {\n      id\n      content {\n        title\n        text\n      }\n    }\n  }\n}"}'
async function createIdea() {
  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 CreateIdea {
        createIdea(input: {
          organizationId: "some_organization_id",
          content: {
            title: "New Idea from GraphQL API"
            text: "This is the text of the new idea created via the GraphQL API."
          }
        }) {
          ... on Idea {
            id
            content {
              title
              text
            }
          }
        }
      }
      `,
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

createIdea();
import requests

query = """
mutation CreateIdea {
  createIdea(input: {
    organizationId: "some_organization_id",
    content: {
      title: "New Idea from GraphQL API"
      text: "This is the text of the new idea created via the GraphQL API."
    }
  }) {
    ... on Idea {
      id
      content {
        title
        text
      }
    }
  }
}
"""

response = requests.post(
    "https://api.buffer.com",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY",
    },
    json={
        "query": query,
    },
)

data = response.json()
print(data)
<?php

$query = '
mutation CreateIdea {
  createIdea(input: {
    organizationId: "some_organization_id",
    content: {
      title: "New Idea from GraphQL API"
      text: "This is the text of the new idea created via the GraphQL API."
    }
  }) {
    ... on Idea {
      id
      content {
        title
        text
      }
    }
  }
}
';

$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);