### Create a Social Post (JavaScript) Source: https://api.postforme.dev/swagger# Create and schedule a social media post. This example demonstrates scheduling a post for one hour in the future with a caption and media URL. Ensure you have the social account IDs from a previous step. ```javascript // Step 2: Create the post using the social account ids // We are scheduling the post one hour from now const scheduledAt = new Date(); scheduledAt.setHours(scheduledAt.getHours() + 1); const postResponse = await fetch('https://api.postforme.dev/v1/social-posts', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY' }, body: JSON.stringify({ caption: 'Hello, world!', scheduled_at: scheduledAt, media: [ { "url": "https://picsum.photos/id/237/1080/1080", } ], social_accounts: accountIds, }), }); const postData = await postResponse.json(); ``` -------------------------------- ### Get Social Accounts (JavaScript) Source: https://api.postforme.dev/swagger# Fetch a list of connected social accounts for specified platforms. This is a prerequisite for creating posts, as you need the account IDs. ```javascript // Step 1: Fetch the social accounts you want to post to. In this case we are getting all facebook and instagram accounts. const socialAccountResponse = await fetch('https://api.postforme.app/v1/social-accounts?platform=facebook&platform=instagram', { method: 'GET', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY' } }); const { data } = await socialAccountResponse.json(); //Grab the ids from the social account response const accountIds = data.map((account) => account.id); ``` -------------------------------- ### GET /v1/social-posts Source: https://api.postforme.dev/swagger# Retrieves a list of all social posts. ```APIDOC ## GET /v1/social-posts ### Description Get a list of all social posts. ### Method GET ### Endpoint /v1/social-posts ### Response #### Success Response (200) - **data** (array) - An array of social post objects. - **id** (string) - The unique identifier for the post. - **caption** (string) - The caption of the post. - **scheduled_at** (string) - The scheduled time for the post. - **status** (string) - The current status of the post. ### Response Example ```json { "data": [ { "id": "post_xyz789", "caption": "Hello, world!", "scheduled_at": "2023-10-27T11:00:00Z", "status": "scheduled" } ] } ``` ``` -------------------------------- ### GET /v1/social-accounts Source: https://api.postforme.dev/swagger# Retrieves a list of all connected social accounts for the authenticated user. ```APIDOC ## GET /v1/social-accounts ### Description Fetch the social accounts you want to post to. ### Method GET ### Endpoint /v1/social-accounts ### Query Parameters - **platform** (string) - Optional - Filter accounts by platform (e.g., 'facebook', 'instagram'). Can be specified multiple times. ### Response #### Success Response (200) - **data** (array) - An array of social account objects. - **id** (string) - The unique identifier for the social account. - **platform** (string) - The social media platform. - **username** (string) - The username of the social account. ### Response Example ```json { "data": [ { "id": "acc_12345abc", "platform": "facebook", "username": "user_facebook" }, { "id": "acc_67890def", "platform": "instagram", "username": "user_instagram" } ] } ``` ``` -------------------------------- ### GET /v1/social-accounts/{id} Source: https://api.postforme.dev/swagger# Retrieves details of a specific social account. ```APIDOC ## GET /v1/social-accounts/{id} ### Description Get social account by ID. ### Method GET ### Endpoint /v1/social-accounts/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the social account. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the social account. - **platform** (string) - The social media platform. - **username** (string) - The username of the social account. ### Response Example ```json { "id": "acc_12345abc", "platform": "facebook", "username": "user_facebook" } ``` ``` -------------------------------- ### Webhook Payload Example Source: https://api.postforme.dev/swagger# This is the JSON body structure sent to your webhook URL when an event occurs. The 'event_type' indicates the trigger, and 'data' contains the event-specific entity. ```json { "event_type": "", "data": {} } ``` -------------------------------- ### GET /v1/social-posts/{id} Source: https://api.postforme.dev/swagger# Retrieves a specific social post by its ID. ```APIDOC ## GET /v1/social-posts/{id} ### Description Get a specific social post by its ID. ### Method GET ### Endpoint /v1/social-posts/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the post. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the post. - **caption** (string) - The caption of the post. - **scheduled_at** (string) - The scheduled time for the post. - **status** (string) - The current status of the post. ### Response Example ```json { "id": "post_xyz789", "caption": "Hello, world!", "scheduled_at": "2023-10-27T11:00:00Z", "status": "scheduled" } ``` ``` -------------------------------- ### POST /v1/media/create-upload-url Source: https://api.postforme.dev/swagger# Generates a pre-signed URL for uploading media assets. ```APIDOC ## POST /v1/media/create-upload-url ### Description Upload media assets (images, videos, etc.) that are not already publicly accessible. ### Method POST ### Endpoint /v1/media/create-upload-url ### Request Body - **filename** (string) - Required - The name of the file to be uploaded. - **content_type** (string) - Required - The MIME type of the file (e.g., 'image/jpeg', 'video/mp4'). ### Request Example ```json { "filename": "my_image.jpg", "content_type": "image/jpeg" } ``` ### Response #### Success Response (200) - **upload_url** (string) - A pre-signed URL to which the media file should be uploaded. - **media_url** (string) - The final URL where the media will be accessible after upload. ### Response Example ```json { "upload_url": "https://storage.postforme.dev/uploads/...", "media_url": "https://cdn.postforme.dev/media/..." } ``` ``` -------------------------------- ### Connect a Social Account (JavaScript) Source: https://api.postforme.dev/swagger# Use this to generate an authentication URL for connecting social accounts. Redirect the user to the returned URL to complete the connection process. ```javascript //Create an auth URL to redirect the user to in order for them to login and connect their account const socialAccountAuthUrlResponse = await fetch('https://api.postforme.dev/v1/social-accounts/auth-url', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_API_KEY' }, body: JSON.stringify({ platform: 'facebook' }), }); const { url } = await socialAccountAuthUrlResponse.json(); //Redirect to the url from the repsone console.log(url); ``` -------------------------------- ### Social Post Previews API Source: https://api.postforme.dev/swagger# Generate previews of how a social post will appear on different platforms before actual publishing. ```APIDOC ## POST /v1/social-post-previews ### Description Create a preview for a social post. ### Method POST ### Endpoint /v1/social-post-previews ### Request Body - **post_data** (object) - Required - The data for the social post to be previewed. - **account_ids** (array) - Required - List of account IDs to preview the post on. - **caption** (string) - Optional - The caption for the post. - **media_urls** (array) - Optional - URLs of media to include in the post. ### Request Example { "post_data": { "account_ids": ["acc_1", "acc_2"], "caption": "Check out this preview!", "media_urls": ["http://example.com/image.jpg"] } } ### Response #### Success Response (200) - **previews** (array) - A list of previews for each account. #### Response Example { "previews": [ { "account_id": "acc_1", "platform": "Instagram", "preview_url": "https://example.com/preview/insta" } ] } ``` -------------------------------- ### POST /v1/social-accounts/auth-url Source: https://api.postforme.dev/swagger# Creates a URL to authenticate and connect a social account to your Post for Me account. ```APIDOC ## POST /v1/social-accounts/auth-url ### Description Create an auth URL to redirect the user to in order for them to login and connect their account. ### Method POST ### Endpoint /v1/social-accounts/auth-url ### Request Body - **platform** (string) - Required - The social media platform to connect (e.g., 'facebook', 'instagram'). ### Request Example ```json { "platform": "facebook" } ``` ### Response #### Success Response (200) - **url** (string) - The URL to redirect the user to for authentication. ### Response Example ```json { "url": "https://auth.postforme.dev/connect?platform=facebook&state=..." } ``` ``` -------------------------------- ### POST /v1/social-posts Source: https://api.postforme.dev/swagger# Creates and schedules a new social media post. ```APIDOC ## POST /v1/social-posts ### Description Create a social post to be published across multiple social media platforms. ### Method POST ### Endpoint /v1/social-posts ### Request Body - **caption** (string) - Required - The main text content of the post. - **scheduled_at** (string) - Required - The date and time to schedule the post, in ISO 8601 format (e.g., '2023-10-27T10:00:00Z'). - **media** (array) - Optional - An array of media objects to attach to the post. - **url** (string) - Required - The publicly accessible URL of the media asset. - **social_accounts** (array) - Required - An array of social account IDs to publish the post to. - **id** (string) - The ID of the social account. ### Request Example ```json { "caption": "Hello, world!", "scheduled_at": "2023-10-27T11:00:00Z", "media": [ { "url": "https://picsum.photos/id/237/1080/1080" } ], "social_accounts": ["acc_12345abc", "acc_67890def"] } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created post. - **status** (string) - The current status of the post (e.g., 'scheduled', 'published'). - **scheduled_at** (string) - The scheduled time for the post. ### Response Example ```json { "id": "post_xyz789", "status": "scheduled", "scheduled_at": "2023-10-27T11:00:00Z" } ``` ``` -------------------------------- ### Authentication Source: https://api.postforme.dev/swagger# Authentication is required for all endpoints. Provide a valid API key as a Bearer token in the Authorization header. ```APIDOC ## Authentication ### Description Authentication is required for all endpoints. Provide a valid API key as a Bearer token in the Authorization header. Log in to your Post for Me account to retrieve your API key. ### Header `Authorization: Bearer YOUR_API_KEY` ``` -------------------------------- ### Webhooks API Source: https://api.postforme.dev/swagger# Manage webhooks to subscribe to events. Post for Me will send POST requests to your specified URL when subscribed events occur. ```APIDOC ## GET /v1/webhooks ### Description Get a list of all configured webhooks. ### Method GET ### Endpoint /v1/webhooks ### Response #### Success Response (200) - **webhooks** (array) - List of webhook configurations. #### Response Example { "webhooks": [ { "id": "wh_123", "url": "https://example.com/webhook" } ] } ## POST /v1/webhooks ### Description Create a new webhook subscription. ### Method POST ### Endpoint /v1/webhooks ### Request Body - **url** (string) - Required - The URL to receive webhook POST requests. - **event_types** (array) - Required - A list of event types to subscribe to. ### Request Example { "url": "https://example.com/webhook", "event_types": ["post.published", "post.failed"] } ### Response #### Success Response (201) - **webhook** (object) - The created webhook configuration, including the secret. #### Response Example { "webhook": { "id": "wh_456", "url": "https://example.com/webhook", "secret": "your_webhook_secret" } } ## GET /v1/webhooks/{id} ### Description Retrieve a specific webhook configuration by its ID. ### Method GET ### Endpoint /v1/webhooks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the webhook. ### Response #### Success Response (200) - **webhook** (object) - The webhook configuration details. #### Response Example { "webhook": { "id": "wh_456", "url": "https://example.com/webhook" } } ## PATCH /v1/webhooks/{id} ### Description Update an existing webhook configuration. ### Method PATCH ### Endpoint /v1/webhooks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the webhook to update. ### Request Body - **url** (string) - Optional - The new URL for the webhook. - **event_types** (array) - Optional - The updated list of event types. ### Request Example { "url": "https://example.com/new_webhook" } ### Response #### Success Response (200) - **webhook** (object) - The updated webhook configuration. #### Response Example { "webhook": { "id": "wh_456", "url": "https://example.com/new_webhook" } } ## DELETE /v1/webhooks/{id} ### Description Delete a webhook subscription. ### Method DELETE ### Endpoint /v1/webhooks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the webhook to delete. ### Response #### Success Response (204) No Content. ``` -------------------------------- ### PUT /v1/social-posts/{id} Source: https://api.postforme.dev/swagger# Updates an existing social media post. ```APIDOC ## PUT /v1/social-posts/{id} ### Description Update an existing social media post. ### Method PUT ### Endpoint /v1/social-posts/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the post to update. ### Request Body - **caption** (string) - Optional - The updated text content of the post. - **scheduled_at** (string) - Optional - The updated date and time to schedule the post, in ISO 8601 format. - **media** (array) - Optional - An array of media objects to attach to the post. - **url** (string) - Required - The publicly accessible URL of the media asset. - **social_accounts** (array) - Optional - An array of social account IDs to publish the post to. - **id** (string) - The ID of the social account. ### Request Example ```json { "caption": "Updated caption!", "scheduled_at": "2023-10-27T12:00:00Z" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the updated post. - **status** (string) - The current status of the post. - **scheduled_at** (string) - The updated scheduled time for the post. ### Response Example ```json { "id": "post_xyz789", "status": "scheduled", "scheduled_at": "2023-10-27T12:00:00Z" } ``` ``` -------------------------------- ### PATCH /v1/social-accounts/{id} Source: https://api.postforme.dev/swagger# Updates a social account's settings. ```APIDOC ## PATCH /v1/social-accounts/{id} ### Description Update social account settings. ### Method PATCH ### Endpoint /v1/social-accounts/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the social account to update. ### Request Body - **settings** (object) - Optional - An object containing updated settings for the social account. - **(specific settings fields would be detailed here if provided in the source)** ### Response #### Success Response (200) - **id** (string) - The unique identifier for the social account. - **platform** (string) - The social media platform. - **username** (string) - The username of the social account. - **settings** (object) - The updated settings for the social account. ### Response Example ```json { "id": "acc_12345abc", "platform": "facebook", "username": "user_facebook", "settings": { "notifications_enabled": true } } ``` ``` -------------------------------- ### DELETE /v1/social-posts/{id} Source: https://api.postforme.dev/swagger# Deletes a social media post. ```APIDOC ## DELETE /v1/social-posts/{id} ### Description Delete a social media post. ### Method DELETE ### Endpoint /v1/social-posts/{id} ### Path Parameters - **id** (string) - Required - The unique identifier of the post to delete. ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the post was deleted. ### Response Example ```json { "message": "Post deleted successfully." } ``` ``` -------------------------------- ### Social Post Results API Source: https://api.postforme.dev/swagger# Retrieve the outcomes of publishing content to various social media platforms, including publication status, errors, and platform URLs. ```APIDOC ## GET /v1/social-post-results ### Description Get all post results. ### Method GET ### Endpoint /v1/social-post-results ### Response #### Success Response (200) - **results** (array) - List of social post results. #### Response Example { "results": [ { "status": "success", "platform": "Twitter", "url": "https://twitter.com/user/status/12345" } ] } ## GET /v1/social-post-results/{id} ### Description Get a specific post result by its ID. ### Method GET ### Endpoint /v1/social-post-results/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the post result. ### Response #### Success Response (200) - **result** (object) - The social post result details. #### Response Example { "result": { "status": "success", "platform": "Facebook", "url": "https://facebook.com/user/posts/67890" } } ``` -------------------------------- ### POST /v1/social-accounts/{id}/disconnect Source: https://api.postforme.dev/swagger# Disconnects a social account from your Post for Me account. ```APIDOC ## POST /v1/social-accounts/{id}/disconnect ### Description Disconnect a social account from your Post for Me account. ### Method POST ### Endpoint /v1/social-accounts/{id}/disconnect ### Path Parameters - **id** (string) - Required - The unique identifier of the social account to disconnect. ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the account was disconnected. ### Response Example ```json { "message": "Social account disconnected successfully." } ``` ``` -------------------------------- ### Social Account Feeds API Source: https://api.postforme.dev/swagger# Access all posts made for a social account, including those not published via the API. This endpoint requires the 'feeds' permission. ```APIDOC ## GET /v1/social-account-feeds/{social_account_id} ### Description Get the feed of posts for a specific social account. ### Method GET ### Endpoint /v1/social-account-feeds/{social_account_id} ### Parameters #### Path Parameters - **social_account_id** (string) - Required - The ID of the social account. #### Query Parameters - **expand** (string) - Optional - Use 'metrics' to include metrics information (views, likes, etc.). ### Response #### Success Response (200) - **posts** (array) - List of posts for the social account. - **metrics** (object) - Metrics information for each post (if expand=metrics is used). #### Response Example { "posts": [ { "caption": "My latest post!", "url": "https://instagram.com/p/abcde" } ], "metrics": { "views": 1000, "likes": 50 } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.