[{"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"}]
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
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, // requiredplatforms: ["twitter", "facebook", "instagram", "linkedin"], // requiredprofileKeys: ["PROFILE_KEY"], // required for client postingmedia_urls: ["https://images.ayrshare.com/imgs/GhostBusters.jpg"], //optionalshorten_links: true, // optionalunsplash: "random", // 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'],'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())
<?phprequire '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);
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()}
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);}}}}
{"status": "success","title": "Digg It","profileKey": "7TVRLEZ-24A43C0-NJW0Z82-F11984N"}
{"action": "create","status": "error","code": 146,"message": "Profile title already exists."}
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
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);
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())
<?phprequire '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);
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()}
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);}}}}
{"status": "success"}
{"action": "delete","status": "error","code": 147,"message": "Error deleting profile."}
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
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);
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())
<?phprequire '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);
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);}}}}
{"token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlLZXkiOiJBSjNQR1cxLThIWk04UjQtR0NXVFZKVy1ZRTE1M1BFIiwicHJvZmlsZUtleSI6IjhKNDY4UFktSjM5TVlXRC1IWEpLVlIyLVBRMjBQUlMiLCJpYXQiOjE2MTQyMjYwNDksImV4cCI6MTYxNDIyNjM0OSwiYXVkIjoiaHR0cHM6Ly9hcHAuYXlyc2hhcmUuY29tIiwiaXNzIjoiYm9uZGJyYW5kbG95YWx0eS5jb20iLCJzdWIiOiJzdXBwb3J0QGF5cnNoYXJlLmNvbSJ9.Se387OyhJIdaDkFkvAe0Dwo3pQrHBwdg2bbjqKYn7BZuVDxPboJmTsd7rra8N-Z6b9_fJOtwlRFGBLW1CvgLGU4RSisTVqjqhAkb3KNhpA7cZ673IJbRX-ST7tYadKKzmd9GNrZW9rhxHOlgMJ9uOboc4dcaDbNmzb_yCrfLY-E"}
{"token": {"action": "JWT","status": "error","code": 189,"message": "Error generating JWT. Error: error:09091064:PEM routines:PEM_read_bio_ex:bad base64 decode"}}
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
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", // requiredprivateKey: "-----BEGIN RSA PRIVATE KEY...", // requiredapiKey: API_KEY, // requiredprofileKey: "PROFILE_KEY, // required}),}).then((res) => res.json()).then((json) => console.log(json)).catch(console.error);
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())
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);}}}}
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 Stringid}),}).then((res) => res.json()).then((json) => console.log(json)).catch(console.error);
​