profiles

Business plan members can create and manage multiple profile accounts. If you require multiple account for your business or clients, please contact us at [email protected] for assistance.

post
Post to Profiles

https://app.ayrshare.com/api/post
In addition to the /post endpoint spec, you can post to one or multiple profiles at once using the "profileKeys" body parameter. The return will be an array of posts or error results, with an overall status. If all posts successful, "success", or if any post failed, "error". You may obtain a client's profile key via either the when the profile is created with the /create-profile endpoint (see below), /user endpoint, or in Ayrshare's Web Dashboard GUI by switching to the profile and going to Profile Dashboard.
Request
Response
Request
Body Parameters
profileKeys
required
array
Array of profile API Keys. You must be the owner of these profiles to post.
Response
200: OK
Post results of all posts successful.
{
"status": "success",
"posts": [
{
"status": "success",
"errors": [],
"postIds": [
{
"status": "success",
"id": "1381620827414728708",
"platform": "twitter"
}
],
"id": "DQf4P4tBf0rpAibpt3Gm",
"profileTitle": "Good Fun",
"refId": "da19d0d2875afb2a516cde881172eb6c1002c592",
"post": "I love to post"
},
{
"status": "success",
"errors": [],
"postIds": [
{
"status": "success",
"id": "1381620827397951497",
"platform": "twitter"
}
],
"id": "jnKLGKcNcGS2iSPWnakw",
"profileTitle": "Digg It",
"refId": "866a36e1185b45e63f019386f941f320972b8e70",
"post": "I love to post"
}
]
}
400: Bad Request
Example of some posts success and other failure, with an overall failure.
{
"status": "error",
"posts": [
{
"status": "error",
"errors": [
{
"action": "post",
"status": "error",
"code": 156,
"message": "Facebook does not seem to be linked with Ayrshare. Please confirm the linkage on the Social Accounts page in your dashboard. https://docs.ayrshare.com/additional-info/troubleshooting",
"platform": "facebook"
}
],
"postIds": [
{
"status": "success",
"id": "1381620363155607552",
"platform": "twitter"
}
],
"id": "2crtBXkWRsh9xbGThE1O",
"profileTitle": "Good Fun",
"refId": "da19d0d2875afb2a516cde881172eb6c1002c592",
"post": "What a wonderful post"
},
{
"status": "success",
"errors": [],
"postIds": [
{
"status": "success",
"id": "1381620363096899585",
"platform": "twitter"
},
{
"status": "success",
"id": "102775157855689_323026635830539",
"postUrl": "https://www.facebook.com/102775157858689_323026635030539",
"platform": "facebook"
}
],
"id": "7ojyAsPpLR0ZlyL6B5rz",
"profileTitle": "Digg It",
"refId": "866a36e1185b45e63f019386f941f320972b8e70",
"post": "What a wonderful post"
}
]
}

If a response of an array is required, please include the body parameter arrayResponse with the boolean value of true.

Request Examples

cURL
Node.js
Python
PHP
Go
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"post": "Today is a great day!", "platforms": ["twitter", "facebook", "instagram", "linkedin"], "profileKeys": ["Key 1", "Key 2"], "media_urls": ["https://images.ayrshare.com/imgs/GhostBusters.jpg"]}' \
-X POST https://app.ayrshare.com/api/post
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const postMsg = "Today is a great day!";
fetch("https://app.ayrshare.com/api/post", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
post: postMsg, // required
platforms: ["twitter", "facebook", "instagram", "linkedin"], // required
profileKeys: ["PROFILE_KEY"], // required for client posting
mediaUrls: ["https://images.ayrshare.com/imgs/GhostBusters.jpg"], //optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'post': 'Today is a great day!',
'platforms': ['twitter', 'facebook', 'instagram', 'linkedin'],
'profileKeys': ['PROFILE_KEY'],
'mediaUrls': ['https://images.ayrshare.com/imgs/GhostBusters.jpg']}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/post',
json=payload,
headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'post' => 'Today is a great day!',
'platforms' => ['twitter', 'facebook', 'instagram', 'linkedin'], // required
'profileKeys' => ['PROFILE_KEY'], // required
'mediaUrls' => ['https://images.ayrshare.com/imgs/GhostBusters.jpg'], // optional
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
Go
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"post": "Today is a great day!",
"platforms": []string{"twitter", "facebook", "instagram", "linkedin"},
"profileKeys": []string{"PROFILE_KEY"},
"mediaUrls": []string{"https://images.ayrshare.com/imgs/GhostBusters.jpg"}
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/post",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
C#
using System;
using System.Net;
using System.IO;
namespace PostPOSTRequest_charp
{
class Post
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/post";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"post\" : \"Today is a great day forever!\","
+ "\"platforms\" : [ \"twitter\", \"facebook\", \"instagram\", \"linkedin\" ],"
+ "\"mediaUrls\" : [ \"https://images.ayrshare.com/imgs/GhostBusters.jpg\" ],"
+ "\"profileKeys\" : [ \"PROFILE_KEY\" ]}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

post
Create a New Profile

https://app.ayrshare.com/api/profiles/create-profile
Create a new profile under your primary account. The Profile Key of the newly created profile is returned. Use the Profile Key to manage and post on behalf of your client.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
title
required
string
Title of the new profile
Response
200: OK
Successful creation of a new profile with the profileKey. refId used to reference the profile when calling /user endpoint.
{
"status": "success",
"title": "Digg It",
"refId": "140b8709bd6ade099b242d895e268fb886130c53",
"profileKey": "7TVRLEZ-24A43C0-NJW0Z82-F11984N"
}
400: Bad Request
Profile with this title already exists.
{
"action": "create",
"status": "error",
"code": 146,
"message": "Profile title already exists."
}

Request Examples

cURL
Node.js
Python
PHP
Go
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title": "ACME Profile"}' \
-X POST https://app.ayrshare.com/api/profiles/create-profile
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/profiles/create-profile", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
title: "ACME Profile", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'title': 'ACME Profile'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/profiles/create-profile',
json=payload,
headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/profiles/create-profile',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'title' => ['ACME Profile'],
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
Go
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"title": "ACME Profile"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/profiles/create-profile",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
C#
using System;
using System.Net;
using System.IO;
namespace CreateProfilePOSTRequest_charp
{
class CreateProfile
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/profiles/create-profile";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"title\" : \"ACME Profile\"}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

delete
Delete a Profile

https://app.ayrshare.com/api/profiles/delete-profile
Delete a profile you are the owner of.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
profileKey
required
string
The profileKey of the profile to delete, returned from /create-profile. May also use the API Key found in the web dashboard.
Response
200: OK
Successful delete
{
"status": "success"
}
500: Internal Server Error
Error deleting profile
{
"action": "delete",
"status": "error",
"code": 147,
"message": "Error deleting profile."
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"profileKey": "PROFILE_KEY"}' \
-X DELETE https://app.ayrshare.com/api/profiles/delete-profile
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const profileKey = "PROFILE_KEY";
fetch("https://app.ayrshare.com/api/profiles/delete-profile", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ profileKey }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'profileKey': 'PROFILE_KEY'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.delete('https://app.ayrshare.com/api/profiles/delete-profile',
json=payload,
headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'DELETE',
'https://app.ayrshare.com/api/profiles/delete-profile',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'profileKey' => ['PROFILE_KEY'],
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
C#
using System;
using System.Net;
using System.IO;
namespace DeletePOSTRequest_charp
{
class Delete
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/profiles/delete-profile";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "DELETE";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"profileKey\" : \"Profile Key\"}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

get
Get Profiles

https://app.ayrshare.com/api/profiles
Get all the profiles associated with the primary account.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Response
200: OK
{
"profiles": [
{
"title": "Digg It Title",
"created": {
"_seconds": 1604094099,
"_nanoseconds": 530000000
},
"refId": "160c8700bd6ade099b242d845e268fb986130c53"
},
{
"title": "Super Profile",
"created": {
"_seconds": 1604377627,
"_nanoseconds": 252000000
},
"refId": "170a8700bd6ade099b242d845e268fb986130c53"
},
{
"title": "Good Fun Title"
"created": {
"_seconds": 1605107864,
"_nanoseconds": 96000000
},
"refId": "180s8700bd6ade099b242d845e268fb986130c53"
}
]
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/profiles
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/profiles", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://app.ayrshare.com/api/profiles', headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'GET',
'https://app.ayrshare.com/api/profiles',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
C#
using System;
using System.Net;
using System.IO;
namespace HistoryGETRequest_charp
{
class History
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/profiles";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

post
Generate a JWT

https://app.ayrshare.com/api/profiles/generateJWT
Generate a JSON Web Token for use with single sign on. Used if you do not want to generate the JWT yourself. Also provided is the URL that can directly be used for SSO.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
domain
required
string
Domain of app. Please use the exact domain given during onboarding.
privateKey
required
string
Private Key use for encryption.
profileKey
required
string
User Profile key.
Response
200: OK
JWT in an object.
{
"token": "eyJhbGciOiJSUzI1NiIsInR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": 189,
"message": "Error generating JWT. Error: error:09091064:PEM routines:PEM_read_bio_ex:bad base64 decode"
}
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"domain": "ACME", "privateKey": "-----BEGIN RSA PRIVATE KEY...", "profileKey": "PROFILE_KEY"' \
-X POST https://app.ayrshare.com/api/profiles/generateJWT
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_KEY";
fetch("https://app.ayrshare.com/api/profiles/generateJWT", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
domain: "ACME", // required
privateKey: "-----BEGIN RSA PRIVATE KEY...", // required
profileKey: PROFILE_KEY, // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'domain': 'ACME',
'privateKey': '-----BEGIN RSA PRIVATE KEY...',
'profileKey': 'PROFILE_KEY' }
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/profiles/generateJWT',
json=payload,
headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'domain' => 'ACME',
'privateKey' => '-----BEGIN RSA PRIVATE KEY...', // required
'profileKey' => 'PROFILE_KEY', // requires
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
C#
using System;
using System.Net;
using System.IO;
namespace GenerateJWTRequest_charp
{
class GenerateJWT
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/profiles/generateJWT";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"domain\" : \"ACME\","
+ "\"privateKey\" : \"-----BEGIN RSA PRIVATE KEY...\","
+ "\"profileKey\" : \"PROFILE_KEY\"}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

The Private Key must be precise, meaning preserving all characters including newlines. We recommend reading the private.key from a file to preserve all characters. If you paste the key into your code, you might need to manually replace newlines with a \n character.

Additional Endpoints

All other endpoints, such as /user, /analytics, or /delete, can be called on behalf of a Profile account by adding the "profileKeys" parameter and sending a single profileKey as a String.

For example, the /delete endpoint can be called to delete a Profile account's post for the given post id for the provided Profile Key.

const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_KEY";
const id = "Post ID";
fetch("https://app.ayrshare.com/api/delete", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
profileKeys: PROFILE_KEY, // a single Profile Key passed as a String
id: id
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);

or for a path parameter with /history:

https://app.ayrshare.com/api/history?profileKeys=ldfnk0s82j

Please see the endpoints for further detail.