Example Queries
Here are some common GraphQL queries you can execute against the Postpone API to retrieve data about your account, posts, and social media connections.
Retrieve Profile
The profile
query is the most fundamental query for checking authentication and retrieving information about the authenticated user.
query profile {
profile {
id
email
username
fullName
timezone
registeredAt
account {
id
name
plan {
code
label
}
}
socialAccounts {
id
platform
username
followers
isEnabled
isConnected
}
}
}
{
"data": {
"profile": {
"id": "123",
"email": "user@example.com",
"username": "myusername",
"fullName": "John Doe",
"timezone": "America/New_York",
"registeredAt": "2023-01-15T10:30:00Z",
"account": {
"id": "456",
"name": "Creator Account",
"plan": {
"code": "creator",
"label": "Creator",
}
}
}
}
}
List Social Accounts
Retrieve all connected social media accounts for the authenticated user.
query socialAccounts($platform: String) {
socialAccounts(platform: $platform) {
id
username
formattedUsername
name
platform
followers
avatarUrl
profileUrl
isConnected
isEnabled
verified
}
}
{
"platform": "reddit"
}
{
"data": {
"socialAccounts": [
{
"id": "789",
"username": "myreddituser",
"formattedUsername": "u/myreddituser",
"name": "My Reddit Account",
"platform": "reddit",
"followers": 1250,
"avatarUrl": "https://example.com/avatar.png",
"profileUrl": "https://reddit.com/u/myreddituser",
"isConnected": true,
"isEnabled": true,
"verified": false
}
]
}
}
List Content Library Media
Query media files from your Content Library with filtering and pagination options.
query media(
$orderBy: String
$limit: Int
$page: Int
$search: String
$fileType: FileType
$unusedOnly: Boolean
) {
mediaAccountUsage {
size
humanReadableSize
usagePercentage
}
media(
orderBy: $orderBy
limit: $limit
page: $page
search: $search
fileType: $fileType
unusedOnly: $unusedOnly
) {
total
objects {
id
filename
originalFilename
fileType
size
humanReadableSize
url
thumbnailUrl
dateCreated
labels {
id
text
color
}
}
}
}
{
"limit": 20,
"page": 1,
"orderBy": "-date_created",
"fileType": "IMAGE",
"unusedOnly": false
}
{
"data": {
"mediaAccountUsage": {
"size": 52428800,
"humanReadableSize": "50 MB",
"usagePercentage": 25.0
},
"media": {
"total": 45,
"objects": [
{
"id": "101",
"filename": "meme-2024.jpg",
"originalFilename": "funny-meme.jpg",
"fileType": "IMAGE",
"size": 1048576,
"humanReadableSize": "1 MB",
"url": "https://media.postpone.app/meme-2024.jpg",
"thumbnailUrl": "https://media.postpone.app/thumb/meme-2024.jpg",
"dateCreated": "2024-01-15T14:30:00Z",
"labels": [
{
"id": "1",
"text": "Memes",
"color": "#FF5733"
}
]
}
]
}
}
}
List Next Account Schedule Dates
Get the next scheduled post dates for your connected social accounts.
query nextScheduleDates($socialAccountIds: [ID]) {
nextScheduleDates(socialAccountIds: $socialAccountIds) {
socialAccountId
scheduleDate
}
}
{
"socialAccountIds": ["789", "790"]
}
{
"data": {
"nextScheduleDates": [
{
"socialAccountId": "789",
"scheduleDate": "2024-01-16T09:00:00Z"
},
{
"socialAccountId": "790",
"scheduleDate": "2024-01-16T12:00:00Z"
}
]
}
}
Making API Requests
Here's how to execute these queries using curl:
curl --request POST \
--url https://api.postpone.app/gql \
--header 'Authorization: Bearer YOUR-API-TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"query": "query profile { profile { id username email account { plan { label } } } }",
"operationName": "profile"
}'
Remember to replace YOUR-API-TOKEN
with your actual API token from your Postpone account settings.
Query Variables
Many queries accept variables to filter and customize results. Always pass variables in the variables
field of your request:
curl --request POST \
--url https://api.postpone.app/gql \
--header 'Authorization: Bearer YOUR-API-TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"query": "query socialAccounts($platform: String) { socialAccounts(platform: $platform) { id username platform } }",
"variables": { "platform": "reddit" },
"operationName": "socialAccounts"
}'
Error Handling
Always check for errors in the GraphQL response:
{
"data": null,
"errors": [
{
"message": "Authentication required",
"locations": [{"line": 2, "column": 3}],
"path": ["profile"]
}
]
}