Post Lifecycle

Understanding how posts move through different states in Outstand is crucial for building robust integrations. This guide explains the post lifecycle, status fields, timing expectations, and where to find error information.

Post States

Every post in Outstand goes through a lifecycle from creation to publication. The state is tracked both at the post level and at the per-account level.

Post-Level Status

At the post level, the publishedAt field indicates whether any account has successfully published:

FieldTypeDescription
publishedAtdatetime | nullSet when the first social account successfully publishes. null if no accounts have published yet.
scheduledAtdatetime | nullWhen the post is scheduled to publish. null for immediate publishing.

Per-Account Status

Each social account attached to a post has its own publishing status:

FieldTypeDescription
status'pending' | 'published' | 'failed'Current publishing state for this account.
errorstring | nullError message if publishing failed. null otherwise.
platformPostIdstring | nullThe platform-specific post ID after successful publish.
publishedAtdatetime | nullWhen this account successfully published.

State Transitions

pending

When a post is created and scheduled, each social account starts in the pending state. The publishing worker will attempt to publish to each account when the scheduled time arrives (or immediately if no scheduledAt is specified).

published

When publishing succeeds for a social account:

  • status is set to published
  • platformPostId is populated with the platform-specific ID (e.g., Twitter post ID, Instagram media ID)
  • publishedAt is set to the current timestamp
  • error is set to null

failed

When publishing fails for a social account:

  • status is set to failed
  • error contains the error message from the platform
  • platformPostId remains null
  • publishedAt remains null

Timing Expectations

ScenarioExpected Timing
Post creationImmediate response with post ID
Immediate publish (no scheduledAt)Publishing starts within seconds
Scheduled publishPublishing starts at the scheduled time (±30 seconds)
Status visibility via APIAvailable immediately after publishing completes
Webhook deliverySent within seconds of publishing completion

Note: Publishing to a social account typically takes 1-10 seconds depending on the platform and whether media upload is required. For posts with multiple accounts, each account is processed sequentially.

Where to Find Errors

Outstand provides two ways to get error information:

1. API Response (Polling)

Use GET /v1/posts/{id} to check the status of a post. Each social account in the response includes status, error, platformPostId, and publishedAt fields:

{
  "success": true,
  "post": {
    "id": "9dyJS",
    "publishedAt": "2025-01-15T10:30:00Z",
    "socialAccounts": [
      {
        "id": "abc123",
        "network": "facebook",
        "username": "MyPage",
        "status": "failed",
        "error": "Failed to upload Facebook photo from buffer: 400 - (#100) Invalid image",
        "platformPostId": null,
        "publishedAt": null
      },
      {
        "id": "def456",
        "network": "x",
        "username": "@myaccount",
        "status": "published",
        "error": null,
        "platformPostId": "1234567890123456789",
        "publishedAt": "2025-01-15T10:30:02Z"
      }
    ]
  }
}

2. Webhooks (Push)

If you've configured webhooks, you'll receive real-time notifications when publishing completes:

post.published - Sent when at least one account succeeds:

{
  "event": "post.published",
  "timestamp": "2025-01-15T10:30:05Z",
  "data": {
    "postId": "9dyJS",
    "socialAccounts": [
      {
        "network": "x",
        "username": "@myaccount",
        "platformPostId": "1234567890123456789"
      },
      {
        "network": "facebook",
        "username": "MyPage",
        "error": "Failed to upload..."
      }
    ]
  }
}

post.error - Sent when ALL accounts fail:

{
  "event": "post.error",
  "timestamp": "2025-01-15T10:30:05Z",
  "data": {
    "postId": "9dyJS",
    "socialAccounts": [
      {
        "network": "facebook",
        "username": "MyPage",
        "error": "Access token has expired"
      }
    ]
  }
}

See the Webhooks documentation for setup instructions.

Best Practices

  1. Use webhooks for real-time updates: Instead of polling, configure webhooks to receive immediate notifications when publishing completes or fails.

  2. Check per-account status: A post can partially succeed - some accounts may publish while others fail. Always check the status field for each social account.

  3. Handle retries: If publishing fails due to a transient error (rate limit, temporary outage), you can delete the failed post and create a new one.

  4. Store platform IDs: After successful publishing, store the platformPostId returned for each account. You'll need this for analytics, comments, and other platform-specific operations.

  5. Monitor for token expiration: Common errors like "Access token has expired" indicate the need to reconnect the social account.