auto-schedule

Create a schedule for future posts.

post
Set Auto Schedule

https://app.ayrshare.com/api/auto-schedule/set
Set up an auto-post schedule by providing times to send. Post will automatically be sent at the next available time. If no more times are available today, the first available time tomorrow will be used, and so on. Use the auto-schedule by setting the /post autoSchedule parameter to true and the title if you want to use a particular schedule. Example, set the times to UTC time 13:05Z and 20:14Z and autoSchedule: true in the post. The post will be scheduled at the next available time of 13:05Z or 20:14Z. Premium or Business Plan required.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
schedule
required
array
Array of strings of scheduled times to auto-posts. Format: ISO-8601 UTC. Example: ["13:05Z", "22:14Z"]. Not required if setStartDate provided.
title
optional
string
Multiple schedules can be set by providing a title for each schedule. If you specify the title in /post with autoScheduleTitle, that schedule will be used. Default title is: "default".
setStartDate
optional
string
Set a specific beginning date to start the auto schedule, provide a ISO-8601 UTC date time. E.g. 2021-07-08T12:30:00Z. The start time will be applied to the provided "title" or will use the default title of one isn't provided. New posts will go out from the start date onwards. Previously scheduled posts are not affected.
Response
200: OK
Schedule successfully set.
{
status: "success",
message: "Auto schedule set.",
title: "Schedule title",
}

Request Examples

cURL
Node.js
Python
PHP
Go
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"schedule": ["13:05Z", "20:14Z"], "title": "Instagram Schedule"}' \
-X POST https://app.ayrshare.com/api/auto-schedule/set
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/auto-schedule/set", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
schedule: ["13:05Z", "20:14Z"], // required
title: "Instagram Schedule" // optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'schedule': ['13:05Z', '20:14Z'], 'title': 'Instagram Schedule'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/auto-schedule/set',
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/auto-schedule/set',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'schedule' => ["13:05Z", "20:14Z"], // required
'title' => "Instagram Schedule" // 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{}{
"schedule": []string{"13:05Z", "20:14Z"},
"title": "Instagram Schedule"
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/auto-schedule/set",
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()
}

delete
Delete Auto Schedule

https://app.ayrshare.com/api/auto-schedule/delete
Delete a particular auto schedule. Provide the title of the schedule or "default" is used.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
title
optional
string
Schedule title previously set in /auto-schedule/set endpoint. If a title is not given, "default" title is used.
Response
200: OK
{
status: "success"
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API Key" \
-H 'Content-Type: application/json' \
-d '{"title": "Schedule Title"}' \
-X DELETE https://app.ayrshare.com/api/auto-schedule/delete
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const title = "Schedule Title";
fetch("https://app.ayrshare.com/api/delete", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ title }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'title': 'Schedule Title'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.delete('https://app.ayrshare.com/api/delete',
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/delete',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'title' => ['Schedule Title']
]
]
);
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/delete";
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 = "{\"title\" : \"Schedule Title\"}";
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
List Auto Schedule

https://app.ayrshare.com/api/auto-schedule/list
List the active auto schedules. Returns an array of schedules with titles, times, and last scheduled date. The next auto scheduled post will start at the last scheduled date.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Response
200: OK
{
"status": "success",
"schedules": {
"Title 1": {
"lastScheduleDate": {
"_seconds": 1605306840,
"_nanoseconds": 185000000
},
"schedule": [
"20:03Z",
"22:34Z"
]
},
"Title 2": {
"schedule": [
"13:05Z",
"22:14Z"
],
"lastScheduleDate": {
"_seconds": 1625833800,
"_nanoseconds": 0
}
}
}
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/auto-schedule/list
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/auto-schedule/list", {
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/auto-schedule/list', 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/auto-schedule/list',
[
'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 UserGETRequest_charp
{
class User
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/auto-schedule/list";
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);
}
}
}
}