Quick Start Guide

Link your social accounts and send your first post in a few minutes.

The guide is for setting up a single company. For Business and Enterprise Plan members with multiple users, a personalized integration guide is provided.

Connect Your Social Media Accounts

Log in or sign up for an Ayrshare account. On the Social Account Linkage page, click the social networks you want to connect. Please be sure to grant all permissions.

Get Your API Key

You'll need your API Key to authorize access to the API endpoints. This key is used in the header of your requests, and should be preceded by the Bearer keyword.

Your API Key is located within the Developer Dashboard, specifically 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.

Every API call must include the API Key in the Header using a Bearer Token. Also include the Content-Type of application/json.

"Authorization": "Bearer API_KEY",
"Content-Type": "application/json"

Send Your First Post via the API

The cURL example is listed below, but you can use any language and we have examples and SDK packages.

Include a post body, the platform destinations, and a media URL if you are posting an image or video. The HTTP POST endpoint is /post.

Here is the sample code. Remember to only include the platforms you have linked.

curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"post": "Today is a great day!", "platforms": ["twitter", "facebook", "instagram", "linkedin"], "mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"]}' \
-X POST https://app.ayrshare.com/api/post

Congrats! You just sent your first post.

A response of status of “success” will be received. Check your social media pages to ensure that the post was successfully processed and is live.

See more code examples of calling the social media api in Node.js, Python, PHP, Golang, C#, and Ruby:

pagepost

Diving a Little Deeper...

Let's look at what happened.

  • Sent the Header Authorization bearer token (API Key) and content type of json.

  • Created a body object with a:

    • post containing the text "Today is a great day!".

    • Social network platforms of Twitter, Facebook, Instagram, and LinkedIn. Note, only include the platforms you linked in the Social Linkage Page (see above).

    • Added an image in the mediaUrls.

  • Sent everything as an HTTP POST to the /post endpoint.

More code examples can be accessed here: https://docs.ayrshare.com/rest-api/endpoints/post

Before You Go, Some Best Practices

Read the Docs

We maintain extensive and up-to-date documentation, and sometimes it even is a fun read.

pageAPI Overview

Error Codes Are Important

You need to handle them so your user have a great experience.

pageErrors

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.

Sending Test Posts with a Random Quote, Image, or Video

The social networks are very particular on sending duplicate content. If you want to test with unique content, the randomPost parameter of the /post endpoint will generate a random quote. If you use the randomPost, the post parameter is not required.

"randomPost": true,
"randomMediaUrl": true

For example, making a cURL call to post a random quote.

curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"randomPost": true, "platforms": ["twitter", "facebook", "instagram", "linkedin"], "randomMediaUrl": true}' \
-X POST https://app.ayrshare.com/api/post

Send a random video by adding isVideo: true. The video will be standard landscape size.

"randomPost": true,
"randomMediaUrl": true,
"isLandscapeVideo": true

Send a random portrait video, required my TikTok or Facebook/Instagram Reels, by adding isPortraitVideo: true.

"randomPost": true,
"randomMediaUrl": true,
"isPortraitVideo": true

Use Postman to Test Your API Calls

Postman is an amazing tool for testing API calls. You can even generate code in over a dozen languages.

pageTest with Postman

Common Troubleshooting

Sometimes things don't go right, so here is a little help.

pageTroubleshooting

Reach Out To Us for Help

We are here to help, so please contact us.

Last updated