Postpone Logo
Examples

Example Queries

Common GraphQL queries you can execute against the Postpone API.

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
    }
  }
}

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
  }
}

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
      }
    }
  }
}

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
  }
}

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"]
    }
  ]
}