Connect Your Social Media Accounts
Log in or sign up for an Ayrshare account. On the Social Account page, click the social networks you want to connect. Please be sure to grant all permissions.Get Your API Key
An API Key is required to authorize access to the API endpoints. This key is used in the header of your requests, and should be preceded by theBearer
keyword.
Your API Key is located within the Ayrshare Dashboard, on the API Key page. If necessary, switch to your ‘Primary Profile’ via the User Profiles page.
From there, you can find the API Key page in the left-hand side panel.

Bearer
Token. Also include the Content-Type
of application/json
.
Header
Send Your First API Post
Publishing the Post
Below are code examples showing how to make a post using our API in different programming languages. For an even easier integration, you can use one of our pre-built SDK packages. To make a post, you’ll need:- Your API Key for authentication.
- The text content of your post.
- The social media platforms you want to post to (only include platforms you’ve linked).
- Optional: URLs of any images or videos you want to include.
Post Response
You will receive a response with astatus
of “success” when our API successfully processes your post. The response includes:
status
: Overall status of the API call (“success” or “error”)errors
: Array of any errors encountered (empty if successful)postIds
: Array of objects containing platform-specific details:- Platform name
- Post ID on that platform
- URL to view the post
- Additional platform-specific information
postIds
array will have its own status, allowing you to verify which platforms successfully received your post.
Check your social media pages to ensure that the post was successfully processed and is live. Note that some platforms may have a slight delay before posts appear publicly.
Here is a sample response:
Post Response
Post
Diving a Little Deeper
Let’s break down the process of what just happened when we made this API call.1
Set the Header
We set the Header Authorization bearer token (API Key) and content type of
json.
2
Create a Body Object
Next, we created a body object:
- Post containing the text “Today is a great day!”.
- Social network platforms of Twitter, Facebook, Instagram, and LinkedIn. You should only include the platforms you linked in the Social Linkage Page.
- Added an image in the mediaUrls.
3
Call the /post Endpoint
Sent everything as an HTTP POST to the /post endpoint.
Before You Go, Some Best Practices
Read the Docs
We maintain extensive and up-to-date documentation. Since you are already here, take some time to check out the sections of the docs in the left navigation.Error Codes Are Important
You need to handle them so your users have a great experience.Errors
Keep Your API Key Secure
We take security very seriously, and so should you. You have full control over the connection between Ayrshare and your social media accounts. Once the accounts are connected, the Ayrshare API key becomes the way you authenticate. Please keep this key secret and secure.Publish Test Posts
You can publish test posts with a random quote, image, or video using therandomPost
, randomMediaUrl
, and isLandscapeVideo
or isPortraitVideo
parameters in the /post endpoint. If you use the randomPost
, the post
parameter is not required.
These posts are live on your social media pages, so if appropriate, delete them after testing.
Random Quote
Send a random quote for testing publishing a post by addingrandomPost: true
.
Used with the /post endpoint.
Random Image
Send a random image by addingrandomMediaUrl: true
.
Used with the /post endpoint.
Random Video
Send a random landscape video by addingisVideo: true
and isLandscapeVideo: true
.
The video will be standard landscape size.
Used with the /post endpoint.
isVideo: true
and isPortraitVideo: true
.
Used with the /post endpoint.
Random Comment
Send a random comment for testing publishing a comment by addingrandomComment: true
.
Used with the /comment endpoint.