Ayrshare Docs
Ask or search…
βŒƒK
Comment on page

profiles

Profiles API Endpoint: Create and manage multiple user profiles.
​Business Plan required for accessing these endpoints.
Specify a User Profile in the API call by adding the Profile Key in the header.

User Profile API Endpoint

❗Click the β€Ί in the endpoint to view details.
post
https://app.ayrshare.com/api
/post
Post to a User Profile
If a response of an array is required instead of an object, please include the body parameter arrayResponse with the boolean value of true. For example, arrayResponse: true
It is important to follow the rules of the social networks, especially in regards to duplicate or similar content. Please see here for details:

Request Examples

cURL
Node.js
Python
PHP
Go
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"post": "Today is a great day!", "platforms": ["twitter", "facebook", "instagram", "linkedin"], "profileKey": "PROFILE_KEY", "mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"]}' \
-X POST https://app.ayrshare.com/api/post
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
profileKey: "PROFILE_KEY", // required for client posting
mediaUrls: ["https://img.ayrshare.com/012/gb.jpg"], //optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
​
payload = {'post': 'Today is a great day!',
'platforms': ['twitter', 'facebook', 'instagram', 'linkedin'],
'profileKey': 'PROFILE_KEY',
'mediaUrls': ['https://img.ayrshare.com/012/gb.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
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$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
'profileKey' => 'PROFILE_KEY', // required
'mediaUrls' => ['https://img.ayrshare.com/012/gb.jpg'], // optional
]
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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"},
"profileKey": "PROFILE_KEY",
"mediaUrls": []string{"https://img.ayrshare.com/012/gb.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()
}
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://img.ayrshare.com/012/gb.jpg\" ],"
+ "\"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
https://app.ayrshare.com/api
/profiles/profile
Create a User Profile

Request Examples

cURL
Node.js
Python
PHP
Go
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"title": "ACME Profile"}' \
-X POST https://app.ayrshare.com/api/profiles/profile
const API_KEY = "API_KEY";
​
fetch("https://app.ayrshare.com/api/profiles/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);
import requests
​
payload = {'title': 'ACME Profile'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
​
r = requests.post('https://app.ayrshare.com/api/profiles/profile',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/profiles/profile',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'title' => ['ACME Profile'],
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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/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()
}
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/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);
}
}
}
}
The Profile Key returned should be securely stored in your system with appropriate access controls. For security reasons, the Profile Key can't not be retrieved again via the API. However, you can retrieve the Profile Key via the dashboard.
The refId should also be stored to associate a profile to an endpoint return.
​
delete
https://app.ayrshare.com/api
/profiles/profile
Delete a User Profile

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"profileKey": "PROFILE_KEY"}' \
-X DELETE https://app.ayrshare.com/api/profiles/profile
const API_KEY = "API_KEY";
const profileKey = "PROFILE_KEY";
​
fetch("https://app.ayrshare.com/api/profiles/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);
import requests
​
payload = {'profileKey': 'PROFILE_KEY'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
​
r = requests.delete('https://app.ayrshare.com/api/profiles/profile',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'DELETE',
'https://app.ayrshare.com/api/profiles/profile',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'profileKey' => ['PROFILE_KEY'],
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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/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);
}
}
}
}
​
put
https://app.ayrshare.com/api
/profiles/profile
Update a User Profile

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"profileKey": "Jokdf-903Js-j9sd0-Pow02-QS9n3", "title": "ACME Profile"}' \
-X PUT https://app.ayrshare.com/api/profiles/profile
const API_KEY = "API_KEY";
​
fetch("https://app.ayrshare.com/api/profiles/profile", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
profileKey: "Jokdf-903Js-j9sd0-Pow02-QS9n3", // required
title: "ACME Profile",
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
​
payload = {'profileKey': 'Jokdf-903Js-j9sd0-Pow02-QS9n3', 'title': 'ACME Profile'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
​
r = requests.put('https://app.ayrshare.com/api/profiles/profile',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'PUT',
'https://app.ayrshare.com/api/profiles/profile',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'profileKey' => ['Jokdf-903Js-j9sd0-Pow02-QS9n3'],
'title' => ['ACME Profile'],
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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/profile";
​
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "PUT";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
​
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"profileKey\" : \"Jokdf-903Js-j9sd0-Pow02-QS9n3\", \"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);
}
}
}
}
​
get
https://app.ayrshare.com/api
/profiles
Get User Profiles

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/profiles
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);
import requests
​
headers = {'Authorization': 'Bearer API_KEY'}
​
r = requests.get('https://app.ayrshare.com/api/profiles', headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$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);
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);
}
}
}
}
​

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"platform": "twitter"}' \
-d '{"profileKey": "PROFILE_KEY"}' \
-X DELETE https://app.ayrshare.com/api/profiles/social
const API_KEY = "API_KEY";
const profileKey = "PROFILE_KEY";
​
fetch("https://app.ayrshare.com/api/profiles/social", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ platform: "twitter", profileKey }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
​
payload = {'platform': 'twitter', 'profileKey': 'PROFILE_KEY'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
​
r = requests.delete('https://app.ayrshare.com/api/profiles/social',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'DELETE',
'https://app.ayrshare.com/api/profiles/social',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'platform' => 'twitter',
'profileKey' => ['PROFILE_KEY'],
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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/social";
​
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 = "{\"platform\" : \"twitter\", \"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
https://app.ayrshare.com/api
/profiles/generateJWT
Generate a JWT

Request Examples

cURL
Node.js
Python
PHP
C#
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
const fs = require('fs');
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_KEY";
​
// Read in local private.key files - also can read from a DB
const privateKey = fs.readFileSync('private.key', 'utf8');
​
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, // required
profileKey: PROFILE_KEY, // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
​
# Read in local private.key files - also can read from a DB
with open('.private.key') as f:
profileKey = f.read()
​
payload = {'domain': 'ACME',
'privateKey': profileKey,
'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
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [