Getting started overview

Integrating with Ayrshare involves a series of steps designed to enable programmatic social media publishing. The core process includes:

  1. Account Creation: Registering for an Ayrshare account.
  2. API Key Retrieval: Obtaining your unique API key from the developer dashboard.
  3. Social Network Integration: Connecting the desired social media accounts (e.g., X, Facebook, LinkedIn) within the Ayrshare dashboard. This step grants Ayrshare the necessary permissions to post on your behalf.
  4. First API Request: Constructing and sending an API call to publish content using your API key.

Ayrshare provides a comprehensive set of documentation to guide developers through these steps, including API references and code examples in multiple languages. The API is designed as RESTful, supporting standard HTTP methods for interactions.

Step What to do Where
1. Create Account Sign up for an Ayrshare account. A free Developer Plan is available. Ayrshare Pricing Page
2. Get API Key Locate and copy your unique API key from the dashboard. Ayrshare Developer Dashboard
3. Connect Social Accounts Authorize Ayrshare to post to your social media profiles (e.g., X, Facebook, LinkedIn). Ayrshare Social Accounts Settings
4. Make First Request Send an API call using your API key to publish content. Ayrshare Post API Reference

Create an account and get keys

To begin using Ayrshare, the first step is to create an account. Ayrshare offers a Developer Plan that includes 50 API calls per month, which is suitable for initial testing and development. Registration typically requires an email address and password.

Once your account is created and you have logged into the Ayrshare dashboard, navigate to the API Key section. Here, you will find your unique API key. This key is essential for authenticating all your API requests and should be treated as a sensitive credential. It is recommended to store it securely and avoid exposing it directly in client-side code.

After obtaining your API key, the next crucial step is to connect your social media accounts. Within the Ayrshare dashboard, locate the section for 'Social Accounts' or 'Integrations'. From here, you can authorize Ayrshare to post to various platforms such as X (formerly Twitter), Facebook, LinkedIn, and more. Each social network requires a separate authorization flow, typically involving a redirect to the respective platform for permission grants. This process ensures that Ayrshare has the necessary access tokens to publish content on your behalf, without requiring you to manage these tokens directly.

Your first request

After setting up your account, retrieving your API key, and connecting your social media profiles, you are ready to make your first API request. Ayrshare's primary function is to publish posts to multiple social media platforms simultaneously. The main endpoint for this action is /post.

The API expects a JSON payload containing the content of your post, along with your API key in the request header. Here's an example using Node.js, one of Ayrshare's supported SDKs:

Node.js Example

First, install the Ayrshare Node.js SDK:

npm install ayrshare

Then, use the following code to publish a simple text post:

const ayrshare = require('ayrshare');

const API_KEY = 'YOUR_AYRSHARE_API_KEY'; // Replace with your actual API key
const client = new ayrshare.Ayrshare(API_KEY);

async function postToSocialMedia() {
  try {
    const postData = {
      post: "Hello from Ayrshare! This is my first programmatic post.",
      platforms: ["twitter", "facebook"], // Specify platforms to post to
      // scheduleDate: "2026-06-01T10:00:00Z" // Optional: Schedule post for a future date/time
    };

    const response = await client.post(postData);
    console.log('Post successful:', response);
  } catch (error) {
    console.error('Error posting to social media:', error.message);
  }
}

postToSocialMedia();

Direct cURL Example

If you prefer to make a direct HTTP request without an SDK, you can use curl or any HTTP client. Ensure you replace YOUR_AYRSHARE_API_KEY with your actual key.

curl -X POST \  'https://app.ayrshare.com/api/post' \  -H 'Content-Type: application/json' \  -H 'Authorization: Bearer YOUR_AYRSHARE_API_KEY' \  -d '{    "post": "My first post via cURL and Ayrshare!",    "platforms": ["twitter", "linkedin"]  }'

In both examples, the post field contains the content you wish to publish, and the platforms array specifies which connected social media accounts should receive the post. Upon successful execution, the API will return a response indicating the status of the post, including any post IDs generated by the social networks.

Common next steps

After successfully making your first API call, you might consider these common next steps to further integrate Ayrshare into your application or workflow:

  1. Explore Advanced Posting Features: The Ayrshare API supports more than just simple text posts. You can include images, videos, links, and even schedule posts for future publication. Review the Ayrshare Post API reference for details on parameters like mediaUrls, link, and scheduleDate.
  2. Implement Webhooks: To receive real-time notifications about the status of your posts (e.g., successful publication, errors), configure webhooks. This allows Ayrshare to send automated callbacks to your application, informing you of events without constant polling. The Ayrshare Webhooks documentation provides setup instructions.
  3. Integrate Analytics: Ayrshare also offers an Analytics API that allows you to retrieve data on your social media posts, such as engagement metrics. This can be valuable for tracking the performance of your published content.
  4. Error Handling: Implement robust error handling in your code to gracefully manage API failures, rate limit issues, or invalid requests. The Ayrshare error codes documentation provides details on common error responses.
  5. Explore SDKs: If you are using a language other than Node.js, explore the available SDKs for PHP, Python, Ruby, and Go to simplify your integration.
  6. Manage Social Accounts Programmatically: For applications that need to manage a large number of social accounts, Ayrshare offers API endpoints to add, list, and delete social accounts programmatically.

Troubleshooting the first call

Encountering issues during your first API call is not uncommon. Here are some steps to troubleshoot and resolve common problems:

  • Check API Key: Ensure your API key is correct and included in the Authorization: Bearer header (for direct HTTP requests) or passed correctly to the SDK client. A common mistake is using an expired or invalid key. You can regenerate your API key in the Ayrshare dashboard if needed.
  • Verify Social Account Connections: Confirm that the social media accounts you are trying to post to (specified in the platforms array) are actually connected and authorized within your Ayrshare dashboard. If an account is disconnected or its permissions have expired, the post will fail for that platform.
  • Review Request Payload: Double-check the JSON payload for correct syntax and required fields. Refer to the Ayrshare Post API reference for detailed specifications of all parameters. Missing a required field or providing an incorrectly formatted value can lead to errors.
  • Examine API Response: Always inspect the API response, even for non-200 HTTP status codes. Ayrshare provides descriptive error messages in the response body that can pinpoint the exact issue.
  • Check Rate Limits: If you are making multiple requests in quick succession, you might hit Ayrshare's rate limits. The API will return a 429 status code in such cases. Implement exponential backoff or ensure your application respects the documented rate limits.
  • Test with Sandbox Environment: Ayrshare offers a sandbox environment for testing. If your production API calls are failing, try using the sandbox to isolate whether the issue is with your code or specific to a live social network connection.
  • Consult Documentation and Support: If you're still stuck, the Ayrshare documentation is a valuable resource. For persistent issues, contact Ayrshare support.