auto-schedule

Create a schedule for future posts.

post
set-auto-schedule

https://app.ayrshare.com/api/set-auto-schedule
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 forth. 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.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
schedule
required
string
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. 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 Example

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/set-auto-schedule
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/set-auto-schedule", {
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/set-auto-schedule',
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/set-auto-schedule',
[
'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/set-auto-schedule",
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()
}