delete

delete
Delete a Post

https://app.ayrshare.com/api/delete
Delete a a post from all social networks or bulk delete pending scheduled posts. Takes a post id returned from the /post.
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body Parameters
id
required
string
Id of the post to delete. Not required if bulk or deleteAllScheduled parameter sent. If the post is scheduled and still pending, the scheduled posts will be deleted and not sent to the networks. If the post has already been sent to the networks, the post will be deleted from the networks. Note: Instagram images can not be deleted via the API and must be deleted directly at Instagram.
deleteAllScheduled
optional
boolean
If true will delete all scheduled posts still in a pending state - has not yet been published to the networks. Required if id or bulk parameter not sent.
bulk
optional
array
Array of Strings post Ids to bulk delete. Required if id or deleteAllScheduled parameter not sent.
Response
200: OK
Post successfully deleted.
{
"twitter": {
"action": "delete",
"status": "success",
"id": "1288900099663775749"
},
"facebook": {
"action": "delete",
"status": "success",
"id": "104920007983682_108683297607743"
},
"status": "success"
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API Key" \
-H 'Content-Type: application/json' \
-d '{"id": "Post ID"}' \
-X DELETE https://app.ayrshare.com/api/delete
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_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({ id }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'id': 'Post ID'}
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' => [
'id' => ['7NFVK0QIXET5rCUS9tmf'] // top-level id from post request
]
]
);
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 = "{\"id\" : \"Post ID\"}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

Profiles

Delete a post for a particular user profile by passing the profileKeys parameter as a body parameter.

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

Available for Business Plan users only.