### Create Post - Full Example Source: https://developers.buffer.com/guides/posts-and-scheduling.html A comprehensive example of creating a post, including detailed response fields. ```APIDOC ## createPost (Full Example) ### Description Demonstrates the `createPost` mutation with a full response, including post details and potential errors. ### Method mutation ### Endpoint N/A (GraphQL) ### Parameters #### Input - **text** (String!) - The content of the post. - **channelId** (String!) - The ID of the channel to post to. - **schedulingType** (String!) - Must be `automatic`. - **mode** (String!) - Can be `addToQueue` or `customScheduled`. ### Request Example ```graphql mutation { createPost(input: { text: "Hello from the API", channelId: "your_channel_id", schedulingType: automatic, mode: addToQueue }) { ... on PostActionSuccess { post { id text dueAt assets { id mimeType } } } ... on MutationError { message } } } ``` ### Response #### Success Response - **post** (Post) - Contains details of the created post, including `id`, `text`, `dueAt`, and `assets`. #### Error Response - **message** (String) - An error message if the post creation fails. ``` -------------------------------- ### Create Post - Full Example Source: https://developers.buffer.com/guides/posts-and-scheduling.html A comprehensive example for creating a post, including fields for ID, text, due date, and assets. Always include `PostActionSuccess` and `MutationError` in your response. ```graphql mutation { createPost(input: { text: "Hello from the API", channelId: "your_channel_id", schedulingType: automatic, mode: addToQueue }) { ... on PostActionSuccess { post { id text dueAt assets { id mimeType } } } ... on MutationError { message } } } ``` -------------------------------- ### REST API Authentication Example Source: https://developers.buffer.com/guides/rest-migration.html Example of how to authenticate with the legacy REST API using an access token. ```http GET https://api.bufferapp.com/1/user.json?access_token=YOUR_TOKEN ``` -------------------------------- ### Create Idea Mutation Example Source: https://developers.buffer.com/reference.html This is an example of a successful response from the `createIdea` mutation. It confirms the creation of an idea and returns an empty object within the `data` field upon success. ```json { "data": { "createIdea": {} } } ``` -------------------------------- ### REST Pagination Example Source: https://developers.buffer.com/guides/rest-migration.html Example of offset-based pagination in the REST API. ```http GET /profiles/:id/updates/sent.json?page=2&count=20 ``` -------------------------------- ### JavaScript Fetch Request for Posts with Assets Source: https://developers.buffer.com/examples/get-posts-with-assets.html Make a POST request using the Fetch API in JavaScript to get posts and their associated assets. This example includes setting the necessary headers and constructing the GraphQL query in the request body. ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query GetPostsWithAssets { posts( input: {organizationId: "some_organization_id", filter: {status: [sent], channelIds: ["some_channel_id"]}} ) { edges { node { id text createdAt channelId assets { thumbnail mimeType source ... on ImageAsset { image { altText width height } } } } } } } `, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### StartPagePostMetadataInput Source: https://developers.buffer.com/reference.html Start Page post metadata. ```APIDOC INPUT StartPagePostMetadataInput Start Page post metadata Fields: link : String Optional link in post ``` -------------------------------- ### Account Query Response Source: https://developers.buffer.com/reference.html Example response for the 'account' query, which retrieves authenticated user information. ```json { "data": { "account": { "id": "...", "email": "...", "backupEmail": "...", "avatar": "..." } } } ``` -------------------------------- ### Migrate CreatePost Assets: Before Source: https://developers.buffer.com/guides/assets-input-migration.html Example of the old `assets` field structure for creating a post with mixed image and video assets. ```graphql mutation CreatePost($input: CreatePostInput!) { createPost(input: $input) { ... } } # variables { "input": { "channelId": "…", "schedulingType": "automatic", "mode": "addToQueue", "text": "Hello", "assets": { "images": [ { "url": "https://example.com/a.jpg" } ], "videos": [ { "url": "https://example.com/v.mp4" } ] } } } ``` -------------------------------- ### Making your first request: Fetch Organizations Source: https://developers.buffer.com/guides/getting-started.html This example demonstrates how to make a GraphQL query to fetch your account's organizations using cURL, JavaScript, and PHP. ```APIDOC ## Making your first request Here's a quick query to fetch your account and organization: ### GraphQL Query ```graphql query GetOrganizations { account { organizations { id } } } ``` ### cURL Example ```bash curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "query GetOrganizations {\n account {\n organizations {\n id\n }\n }\n}"}' ``` ### JavaScript Example ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query GetOrganizations { account { organizations { id } } } `, }), }); const data = await response.json(); console.log(data); ``` ### PHP Example ```php $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); ``` ``` -------------------------------- ### Migrate CreatePost Assets: After Source: https://developers.buffer.com/guides/assets-input-migration.html Example of the new `assets` field structure for creating a post with mixed image and video assets. The order in the array determines the display order. ```graphql mutation CreatePost($input: CreatePostInput!) { createPost(input: $input) { ... } } # variables { "input": { "channelId": "…", "schedulingType": "automatic", "mode": "addToQueue", "text": "Hello", "assets": [ { "image": { "url": "https://example.com/a.jpg" } }, { "video": { "url": "https://example.com/v.mp4" } } ] } } ``` -------------------------------- ### Channels Query Response Source: https://developers.buffer.com/reference.html Example response for the 'channels' query, which fetches all channels for an organization based on user permissions. ```json { "data": { "channels": [ { "id": "...", "allowedActions": [ "publishStartPage" ], "scopes": [ "..." ], "avatar": "..." } ] } } ``` -------------------------------- ### Fetch Account Data using cURL Source: https://developers.buffer.com/guides/rest-migration.html Example of how to make a GraphQL request to fetch account data using cURL. ```bash curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "query {\n account {\n id\n email\n name\n organizations {\n id\n name\n }\n }\n}"}' ``` -------------------------------- ### GraphQL Pagination JavaScript Request Source: https://developers.buffer.com/guides/rest-migration.html Example of making a GraphQL pagination request using JavaScript. ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query { posts( first: 20 after: "cursor_from_previous_page" input: { organizationId: "your_org_id" } ) { edges { node { id, text } } pageInfo { hasNextPage endCursor } } `, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Basic Paginated Query Source: https://developers.buffer.com/guides/pagination.html This example shows a basic query to fetch a list of posts with pagination. It uses `first` to set the page size and `input` for filtering. The response includes `edges` with `node` data and `pageInfo` for pagination. ```APIDOC ## Basic Paginated Query ### Description Fetches a batch of items using cursor-based pagination. ### Method query ### Endpoint N/A (GraphQL) ### Parameters #### Query Arguments - **first** (Int) - Required - The number of items to return (page size). - **after** (String) - Optional - The cursor to start from. Omit for the first page. - **input** (Object) - Optional - Filters for the query. - **organizationId** (String) - Required - The ID of the organization. - **filter** (Object) - Optional - Filtering criteria. - **status** (Array[String]) - Optional - Filter by item status. ### Request Example ```graphql query { posts( first: 20, input: { organizationId: "your_org_id", filter: { status: [sent] } } ) { edges { node { id text dueAt } } pageInfo { hasNextPage endCursor } } } ``` ### Response #### Success Response (200) - **edges** (Array[Object]) - The list of items, each wrapped in a `node`. - **node** (Object) - The item data. - **id** (String) - The item's unique identifier. - **text** (String) - The content of the item. - **dueAt** (String) - The due date of the item. - **pageInfo** (Object) - Pagination metadata. - **hasNextPage** (Boolean) - `true` if there are more items. - **endCursor** (String) - The cursor of the last item in the current batch. - **startCursor** (String) - The cursor of the first item in the current batch. - **hasPreviousPage** (Boolean) - Currently always `false`. ### Response Example ```json { "data": { "posts": { "edges": [ { "node": { "id": "post_1", "text": "Example post text 1", "dueAt": "2023-10-27T10:00:00Z" } }, { "node": { "id": "post_2", "text": "Example post text 2", "dueAt": "2023-10-27T11:00:00Z" } } ], "pageInfo": { "hasNextPage": true, "endCursor": "cursor_for_post_2", "startCursor": "cursor_for_post_1", "hasPreviousPage": false } } } } ``` ``` -------------------------------- ### GraphQL Pagination PHP Request Source: https://developers.buffer.com/guides/rest-migration.html Example of making a GraphQL pagination request using PHP. ```php $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); ``` -------------------------------- ### Fetch Account Data using JavaScript Source: https://developers.buffer.com/guides/rest-migration.html Example of how to make a GraphQL request to fetch account data using JavaScript's fetch API. ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query { account { id email name organizations { id name } } } `, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Filtering Paginated Results Source: https://developers.buffer.com/guides/pagination.html This example demonstrates how to apply filters to paginated queries using the `input.filter` object. Filters are combined with AND logic. ```APIDOC ## Filtering Paginated Results ### Description Applies filters to a paginated query to retrieve specific items. Filters are combined using AND logic. ### Method query ### Endpoint N/A (GraphQL) ### Parameters #### Query Arguments - **first** (Int) - Required - The number of items to return (page size). - **after** (String) - Optional - The cursor to start from. Omit for the first page. - **input** (Object) - Required - Input object for the query. - **organizationId** (String) - Required - The ID of the organization. - **filter** (Object) - Optional - Filtering criteria. - **status** (Array[String]) - Optional - Filter by item status (e.g., `scheduled`). - **channelIds** (Array[String]) - Optional - Filter by channel IDs. ### Request Example ```graphql query { posts( first: 20, input: { organizationId: "your_org_id", filter: { status: [scheduled], channelIds: ["your_channel_id", "your_other_channel_id"] } } ) { edges { node { id text channelId } } pageInfo { hasNextPage endCursor } } } ``` ### Response #### Success Response (200) - **edges** (Array[Object]) - The list of filtered items. - **node** (Object) - The item data. - **id** (String) - The item's unique identifier. - **text** (String) - The content of the item. - **channelId** (String) - The ID of the channel the item belongs to. - **pageInfo** (Object) - Pagination metadata. - **hasNextPage** (Boolean) - `true` if there are more items matching the filter. - **endCursor** (String) - The cursor of the last item in the current batch. ### Response Example ```json { "data": { "posts": { "edges": [ { "node": { "id": "post_5", "text": "Scheduled post for channel A", "channelId": "your_channel_id" } }, { "node": { "id": "post_6", "text": "Scheduled post for channel B", "channelId": "your_other_channel_id" } } ], "pageInfo": { "hasNextPage": true, "endCursor": "cursor_for_post_6" } } } } ``` ``` -------------------------------- ### Fetch Posts using cURL Source: https://developers.buffer.com/examples/get-posts-for-channels.html This cURL command shows how to make a POST request to the Buffer API to get posts for specified channels. Remember to replace YOUR_API_KEY with your actual API key. ```curl curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "query GetPostsForChannels {\n posts(\n input: {organizationId: \"some_organization_id\", sort: [{ field: dueAt, direction: desc }, { field: createdAt, direction: desc }] , filter: {status: sent, channelIds: [\"some_channel_id\"]}}\n ) {\n edges {\n node {\n id\n text\n createdAt\n channelId\n }\n }\n }\n}"}' ``` -------------------------------- ### Fetch Account Data using PHP Source: https://developers.buffer.com/guides/rest-migration.html Example of how to make a GraphQL request to fetch account data using PHP with cURL. ```php $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); ``` -------------------------------- ### Successful Post Creation Response Source: https://developers.buffer.com/guides/your-first-post.html This is an example of a successful response from the Buffer API after creating a post. It confirms the post creation and provides its ID, text, and scheduled due date. ```json { "data": { "createPost": { "post": { "id": "your_post_id", "text": "Hello from the Buffer API!", "dueAt": "2026-03-05T14:30:00.000Z" } } } } ``` -------------------------------- ### Fetch Channels using JavaScript Source: https://developers.buffer.com/examples/get-channels.html Example of fetching channels using the Fetch API in JavaScript. This code sends a POST request with the GraphQL query and includes necessary headers for authentication. ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query GetChannels { channels(input: { organizationId: "some_organization_id" }) { id name displayName service avatar isQueuePaused } } `, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### List Queued Posts (GraphQL) Source: https://developers.buffer.com/guides/rest-migration.html This snippet demonstrates how to list pending posts using the GraphQL API. It includes examples for direct GraphQL queries, cURL, JavaScript, and PHP. ```APIDOC ## List queued posts ### Description Retrieves a list of pending posts with specified filters and sorting. ### Method POST ### Endpoint https://api.buffer.com ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query {\n posts(\n first: 10\n input: {\n organizationId: \"your_org_id\"\n filter: {\n status: [scheduled]\n channelIds: [\"your_channel_id\"]\n }\n sort: [{ field: dueAt, direction: asc }]\n }\n ) {\n edges {\n node {\n id\n text\n status\n dueAt\n channelId\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the query results. - **posts** (object) - Information about the posts. - **edges** (array) - List of post nodes. - **node** (object) - Details of a single post. - **id** (string) - The unique identifier of the post. - **text** (string) - The content of the post. - **status** (string) - The current status of the post. - **dueAt** (string) - The scheduled time for the post. - **channelId** (string) - The identifier of the channel the post is scheduled for. - **pageInfo** (object) - Pagination information. - **hasNextPage** (boolean) - Indicates if there are more pages of results. - **endCursor** (string) - The cursor for the last item in the current page. #### Response Example ```json { "data": { "posts": { "edges": [ { "node": { "id": "post_id_1", "text": "Example post content", "status": "scheduled", "dueAt": "2023-10-27T10:00:00Z", "channelId": "channel_id_1" } } ], "pageInfo": { "hasNextPage": true, "endCursor": "cursor_string" } } } } ``` ``` -------------------------------- ### Fetch a Channel by ID (JavaScript) Source: https://developers.buffer.com/examples/get-channel.html Example using JavaScript's fetch API to send a GraphQL query to retrieve channel information. Remember to include your API key in the Authorization header. ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query GetChannel { channel(input: { id: "some_channel_id" }) { id name displayName service avatar isQueuePaused } }`, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Fetch Organizations using JavaScript Source: https://developers.buffer.com/examples/get-organizations.html Use the fetch API in JavaScript to send a POST request to the Buffer API with the GraphQL query. This example logs the response data to the console. Replace 'YOUR_API_KEY' with your actual API key. ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: ` query GetOrganizations { account { organizations { id name ownerEmail } } } `, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Get Filtered Channels Source: https://developers.buffer.com/examples/get-filtered-channels.html This operation fetches channels for a specified organization ID. You can filter the results, for example, to only retrieve unlocked channels. ```APIDOC ## Get Filtered Channels ### Description Fetches all channels for the provided Organization ID, with the ability to filter the results. ### Method POST ### Endpoint https://api.buffer.com ### Query Parameters None ### Request Body ```json { "query": "query GetChannels($orgId: String!, $filter: ChannelFilterInput) {\n channels(input: { organizationId: $orgId, filter: $filter }) {\n id\n name\n displayName\n service\n avatar\n isQueuePaused\n }\n}", "variables": { "orgId": "some_organization_id", "filter": { "isLocked": false } } } ``` ### Response #### Success Response (200) - **channels** (Array) - A list of channel objects. - **id** (String) - The unique identifier for the channel. - **name** (String) - The internal name of the channel. - **displayName** (String) - The user-facing display name of the channel. - **service** (String) - The social media service the channel is connected to. - **avatar** (String) - URL to the channel's avatar. - **isQueuePaused** (Boolean) - Indicates if the channel's queue is currently paused. ### Request Example (GraphQL) ```graphql query GetChannels { channels(input: { organizationId: "some_organization_id", filter:{ isLocked: false } }) { id name displayName service avatar isQueuePaused } } ``` ### Request Example (cURL) ```bash curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "query GetChannels {\n channels(input: {\n organizationId: \"some_organization_id\",\n filter:{ \n isLocked: false \n }\n }) {\n id\n name\n displayName\n service\n avatar\n isQueuePaused\n }\n}"}' ``` ### Request Example (JavaScript) ```javascript const response = await fetch('https://api.buffer.com', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY', }, body: JSON.stringify({ query: `\n query GetChannels {\n channels(input: {\n organizationId: \"some_organization_id\",\n filter:{ \n isLocked: false \n }\n }) {\n id\n name\n displayName\n service\n avatar\n isQueuePaused\n }\n }\n `, }), }); const data = await response.json(); console.log(data); ``` ### Request Example (PHP) ```php $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); ``` ``` -------------------------------- ### Serve Local Documentation Server Source: https://developers.buffer.com/explorer.html Instructions for serving the documentation locally to resolve CORS issues with the GraphQL Explorer. Use either npx or python. ```bash npx serve . ``` ```bash python -m http.server 8000 ``` -------------------------------- ### Get Paginated Posts Source: https://developers.buffer.com/examples/get-paginated-posts.html Fetches a list of posts with support for pagination. You can filter by organization ID, status, and channel IDs. The response includes pagination information like start cursor, end cursor, and whether there's a next page. ```APIDOC ## Get Paginated Posts ### Description Fetches a list of posts with support for pagination. You can filter by organization ID, status, and channel IDs. The response includes pagination information like start cursor, end cursor, and whether there's a next page. ### Method POST ### Endpoint https://api.buffer.com ### Parameters #### Query Parameters - **query** (string) - Required - The GraphQL query to execute. ### Request Example ```json { "query": "query GetPosts {\n posts(\n after: \"id_to_start_after\",\n first: 20,\n input: {organizationId: \"some_organization_id\", filter: {status: [sent], channelIds: [\"some_channel_id\"]}}\n ) {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n }\n edges {\n node {\n id\n text\n createdAt\n channelId\n }\n }\n }\n}" } ``` ### Headers - **Content-Type**: application/json - **Authorization**: Bearer YOUR_API_KEY ### Response #### Success Response (200) - **data** (object) - Contains the result of the query. - **posts** (object) - **pageInfo** (object) - **startCursor** (string) - The cursor for the start of the current page. - **endCursor** (string) - The cursor for the end of the current page. - **hasNextPage** (boolean) - Indicates if there is a next page of results. - **edges** (array) - A list of post edges. - **node** (object) - Represents a single post. - **id** (string) - The unique identifier for the post. - **text** (string) - The content of the post. - **createdAt** (string) - The timestamp when the post was created. - **channelId** (string) - The identifier of the channel the post belongs to. ### Response Example ```json { "data": { "posts": { "pageInfo": { "startCursor": "cursor_start", "endCursor": "cursor_end", "hasNextPage": true }, "edges": [ { "node": { "id": "post_id_1", "text": "Example post content 1", "createdAt": "2023-10-27T10:00:00Z", "channelId": "channel_id_1" } }, { "node": { "id": "post_id_2", "text": "Example post content 2", "createdAt": "2023-10-27T10:05:00Z", "channelId": "channel_id_2" } } ] } } } ``` ``` -------------------------------- ### REST Error Handling Example Source: https://developers.buffer.com/guides/rest-migration.html Example of error response from the REST API using HTTP status codes and numeric error codes. ```http HTTP 403 { "code": 1023, "error": "Profile update quota exceeded." } ``` -------------------------------- ### GraphQL Error Handling Example Source: https://developers.buffer.com/guides/rest-migration.html Example of error response from the GraphQL API, which always returns HTTP 200 and uses typed error unions. ```json { "data": { "createPost": { "message": "Queue limit reached", "limit": 100 } } } ``` -------------------------------- ### Fetch Channels using cURL Source: https://developers.buffer.com/examples/get-channels.html This cURL command demonstrates how to make a POST request to the Buffer API to fetch channels. Remember to replace 'YOUR_API_KEY' with your actual API key. ```curl curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "query GetChannels {\n channels(input: {\n organizationId: \"some_organization_id\"\n }) {\n id\n name\n displayName\n service\n avatar\n isQueuePaused\n }\n}"}' ``` -------------------------------- ### Create Draft Post using cURL Source: https://developers.buffer.com/examples/create-draft-post.html This cURL command demonstrates how to send the `createPost` mutation to the Buffer API to save a post as a draft. Ensure you replace `YOUR_API_KEY` with your actual API key. ```curl curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "mutation CreateDraftPost {\n createPost(input: {\n text: \"Hello there, this is a draft post!\",\n channelId: \"some_channel_id\",\n schedulingType: automatic,\n mode: addToQueue,\n saveToDraft: true\n }) {\n ... on PostActionSuccess {\n post {\n id\n text\n }\n }\n ... on MutationError {\n message\n }\n }\n}"}' ``` -------------------------------- ### Get Channels Source: https://developers.buffer.com/examples/get-channels.html Fetches all channels for the provided Organization ID. ```APIDOC ## Get Channels ### Description Fetches all channels for the provided Organization ID. ### Method POST ### Endpoint https://api.buffer.com ### Request Body - **query** (String) - Required - The GraphQL query to fetch channels. - **input** (Object) - Required - Input parameters for the channels query. - **organizationId** (String) - Required - The ID of the organization to fetch channels for. ### Request Example ```json { "query": "query GetChannels {\n channels(input: {\n organizationId: \"some_organization_id\"\n }) {\n id\n name\n displayName\n service\n avatar\n isQueuePaused\n }\n}" } ``` ### Response #### Success Response (200) - **data** (Object) - Contains the channels data. - **channels** (Array) - A list of channels. - **id** (String) - The unique identifier for the channel. - **name** (String) - The name of the channel. - **displayName** (String) - The display name of the channel. - **service** (String) - The service the channel is connected to (e.g., 'twitter', 'facebook'). - **avatar** (String) - URL to the channel's avatar. - **isQueuePaused** (Boolean) - Indicates if the channel's queue is paused. #### Response Example ```json { "data": { "channels": [ { "id": "channel_id_1", "name": "channel_name_1", "displayName": "Channel Display Name 1", "service": "twitter", "avatar": "http://example.com/avatar1.png", "isQueuePaused": false }, { "id": "channel_id_2", "name": "channel_name_2", "displayName": "Channel Display Name 2", "service": "facebook", "avatar": "http://example.com/avatar2.png", "isQueuePaused": true } ] } } ``` ``` -------------------------------- ### GraphQL Pagination Query Source: https://developers.buffer.com/guides/rest-migration.html Example of cursor-based pagination query in the GraphQL API. ```graphql query { posts( first: 20 after: "cursor_from_previous_page" input: { organizationId: "your_org_id" } ) { edges { node { id, text } } pageInfo { hasNextPage endCursor } } } ``` -------------------------------- ### Create Scheduled Post (JavaScript) Source: https://developers.buffer.com/examples/create-scheduled-post.html Use the `fetch` API in JavaScript to send the `createPost` mutation. Ensure the `Content-Type` and `Authorization` headers are correctly set, and the query is stringified in the request body. ```javascript 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: customScheduled, dueAt: "2026-03-26T10:28:47.545Z" }) { ... on PostActionSuccess { post { id text assets { id mimeType } } } ... on MutationError { message } } } `, }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### DateTimeComparator Source: https://developers.buffer.com/reference.html Comparator for filtering by date, allowing specification of start and end dates. ```APIDOC ## INPUT DateTimeComparator ### Description Comparator for filtering by date. ### Fields - **start** (DateTime) - Include results with dates equal to or after the specified date - **end** (DateTime) - Include results with dates equal to or before the specified date ``` -------------------------------- ### Get Channel by ID Source: https://developers.buffer.com/guides/rest-migration.html Retrieve a specific channel (formerly profile) by its unique ID. ```APIDOC ## GET /profiles/:id.json ### Description Retrieves a specific channel (profile) by its ID. ### Method GET ### Endpoint /profiles/:id.json ### Path Parameters - **id** (string) - Required - The unique identifier of the channel to retrieve. ``` ```APIDOC ## GraphQL Query for a Specific Channel ### Description Fetches details for a single channel using its unique ID. ### Method POST ### Endpoint https://api.buffer.com ### Request Body - **query** (string) - Required - The GraphQL query string. - **channel(input: { id: "your_channel_id" })** - Input object for the channel query, requires channel ID. - **id** (string) - The unique identifier for the channel. - **name** (string) - The name of the channel. - **service** (string) - The social media service the channel is connected to. - **displayName** (string) - The display name of the channel. - **avatar** (string) - URL to the channel's avatar. ### Request Example ```graphql query { channel(input: { id: "your_channel_id" }) { id name service displayName avatar } } ``` ### Response #### Success Response (200) - **data.channel** (object) - The channel object. - **id** (string) - The unique identifier for the channel. - **name** (string) - The name of the channel. - **service** (string) - The social media service the channel is connected to. - **displayName** (string) - The display name of the channel. - **avatar** (string) - URL to the channel's avatar. ``` -------------------------------- ### Create Image Post Request (cURL) Source: https://developers.buffer.com/examples/create-image-post.html This cURL command demonstrates how to send the `createPost` mutation to the Buffer API. Replace `YOUR_API_KEY` with your actual Buffer API key. ```curl 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: [\n {\n image: {\n url: \"https://images.unsplash.com/photo-1742850541164-8eb59ecb3282?q=80&w=3388&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\"\n }\n }\n ]\n }\n ) {\n ... on PostActionSuccess {\n post {\n id\n text\n assets {\n id\n mimeType\n }\n }\n }\n ... on MutationError {\n message\n }\n }\n}"}' ``` -------------------------------- ### Add Buffer MCP Server Configuration Source: https://developers.buffer.com/guides/integrations/cursor.html Configure Cursor's MCP settings to add the Buffer server. Replace YOUR_API_KEY with your actual Buffer API key. ```json { "mcpServers": { "Buffer": { "command": "npx", "args": [ "-y", "mcp-remote", "https://mcp.buffer.com/mcp", "--header", "Authorization: Bearer YOUR_API_KEY" ] } } } ``` -------------------------------- ### Create Video Post Request (cURL) Source: https://developers.buffer.com/examples/create-video-post.html This cURL command demonstrates how to send a POST request to the Buffer API to create a video post. Remember to replace 'YOUR_API_KEY' with your actual API key. ```curl 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}"}' ``` -------------------------------- ### GraphQL Pagination cURL Request Source: https://developers.buffer.com/guides/rest-migration.html Example of making a GraphQL pagination request using cURL. ```curl curl -X POST 'https://api.buffer.com' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -d '{"query": "query {\n posts(\n first: 20\n after: \"cursor_from_previous_page\"\n input: { organizationId: \"your_org_id\" }\n ) {\n edges {\n node { id, text }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}"}' ``` -------------------------------- ### Get Organizations Query Source: https://developers.buffer.com/explorer.html This GraphQL query retrieves a list of organizations associated with the authenticated account. ```APIDOC ## Get Organizations Query ### Description This GraphQL query retrieves a list of organizations associated with the authenticated account. ### Method POST ### Endpoint /graphql ### Request Body ```json { "query": "query GetOrganizations {\n account {\n organizations {\n id\n }\n }\n}" } ``` ### Headers ```json { "Authorization": "Bearer YOUR_TOKEN" } ``` ### Response #### Success Response (200) - **organizations** (Array of Objects) - A list of organizations, each with an 'id'. ### Response Example ```json { "data": { "account": { "organizations": [ { "id": "org_12345" } ] } } } ``` ```