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 contact@ayrshare.com 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 status and error results. 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 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
An array of the post results.
[
{
"status": "success",
"errors": [],
"postIds": [
{
"status": "success",
"id": "1321971404800249856",
"platform": "twitter"
}
],
"id": "tjC56M7Tj68tyQDK1lOi",
"profileTitle": "Profile Name 1"
},
{
"status": "success",
"errors": [],
"postIds": [
{
"status": "success",
"id": "1321971405387386880",
"platform": "twitter"
}
],
"id": "iCIP3BbJP8uWzwev7V9n",
"profileTitle": "Profile Name 2"
}
]

Request Example

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"], "unsplash": "random"}' \
-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
media_urls: ["https://images.ayrshare.com/imgs/GhostBusters.jpg"], //optional
shorten_links: true, // optional
unsplash: "random", // 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'],
'media_urls': ['https://images.ayrshare.com/imgs/GhostBusters.jpg'],
'unsplash': 'random'}
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
'media_urls' => ['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"},
"media_urls": []string{"https://images.ayrshare.com/imgs/GhostBusters.jpg"},
"unsplash": "random"
}
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\" ],"
+ "\"media_urls\" : [ \"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
{
"status": "success",
"title": "Digg It",
"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 Example

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 GUI desktop.
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 Example

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);
}
}
}
}

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.
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 given onboarding.
privateKey
required
string
Private Key use for encryption.
apiKey
required
string
Your app API key.
profileKey
required
string
User Profile key.
Response
200: OK
JWT in an object.
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlLZXkiOiJBSjNQR1cxLThIWk04UjQtR0NXVFZKVy1ZRTE1M1BFIiwicHJvZmlsZUtleSI6IjhKNDY4UFktSjM5TVlXRC1IWEpLVlIyLVBRMjBQUlMiLCJpYXQiOjE2MTQyMjYwNDksImV4cCI6MTYxNDIyNjM0OSwiYXVkIjoiaHR0cHM6Ly9hcHAuYXlyc2hhcmUuY29tIiwiaXNzIjoiYm9uZGJyYW5kbG95YWx0eS5jb20iLCJzdWIiOiJzdXBwb3J0QGF5cnNoYXJlLmNvbSJ9.Se387OyhJIdaDkFkvAe0Dwo3pQrHBwdg2bbjqKYn7BZuVDxPboJmTsd7rra8N-Z6b9_fJOtwlRFGBLW1CvgLGU4RSisTVqjqhAkb3KNhpA7cZ673IJbRX-ST7tYadKKzmd9GNrZW9rhxHOlgMJ9uOboc4dcaDbNmzb_yCrfLY-E"
}
400: Bad Request
{
"token": {
"action": "JWT",
"status": "error",
"code": 189,
"message": "Error generating JWT. Error: error:09091064:PEM routines:PEM_read_bio_ex:bad base64 decode"
}
}

Request Example

cURL
Node.js
Python
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"domain": "ACME", "privateKey": "-----BEGIN RSA PRIVATE KEY...", "apiKey": "API_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";
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
apiKey: API_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...',
'apiKey': 'API_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())
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...\","
+ "\"apiKey\" : \"API_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);
}
}
}
}

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 or a String in an Array.

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 in an Array or as a String
id
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);