Accounts

Account Status

Check whether an account can publish, see when its access expires, and reconnect or disconnect it.

Every account has a status that tells you whether it can publish. Check it before you publish, and reconnect an account as soon as it stops being active.

import { Configuration, AccountsApi } from "@onepostly/sdk";

const accountsApi = new AccountsApi(
  new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY })
);

const response = await accountsApi.getAccount({
  id: "acc_YOUR_LINKEDIN_ACCOUNT_ID",
});
console.log(response);
{
  "id": "acc_YOUR_LINKEDIN_ACCOUNT_ID",
  "platform": "linkedin",
  "displayName": "Your Brand",
  "handle": "Your Brand",
  "avatarUrl": "https://cdn.onepostly.com/avatars/yourbrand.jpg",
  "status": "active",
  "canAutoRenew": false,
  "tokenExpiresAt": "2027-04-30T10:00:00.000Z",
  "profile": "Default",
  "metadata": {},
  "createdAt": "2027-03-01T10:00:00.000Z",
  "updatedAt": "2027-03-01T10:00:00.000Z"
}

Status Values

statusMeaningWhat to do
activeThe account worksNothing
expiredThe access ran out and could not renewReconnect the account
revokedThe platform or the owner withdrew the accessReconnect the account
errorThe account cannot be used until reconnectedReconnect the account

New values can be added, so treat anything but active as needing a reconnect. Until then, actions fail.

The API does not return disconnected accounts. You see disconnected only in the account.disconnected webhook.

Token Expiry

Two fields tell you whether an account stays connected on its own.

FieldMeaning
canAutoRenewtrue when the access renews by itself, so expiry never needs a reconnect
tokenExpiresAtWhen the access expires, or null when it never does

When canAutoRenew is false, the account works until tokenExpiresAt and then reads expired. It depends on what the platform granted at sign-in, so check it per account. Each platform page lists its access lifetimes under Connect.

Expiring Accounts

An account that cannot renew sends account.expiring about 7 days before tokenExpiresAt, or right after connecting when less time is left. Reconnect it before then to keep publishing.

EventWhen you get it
account.expiringAbout 7 days before the access runs out. Once per authorization
account.expiredThe access ran out, the next time the account is used
account.revokedThe platform rejected the access, or the owner withdrew it
account.connectedA connect or reconnect, with reconnected and the new tokenExpiresAt
account.disconnectedAn account was disconnected

See Account Webhooks for the payloads.

Reconnect an Account

Reconnect when status is not active, when account.expiring arrives, or when a post fails with TOKEN_INVALID. The account keeps its id, profile and posts, and is not billed as new.

POST /v1/accounts/{id}/reconnect needs a read_write key. Check type in the response.

typePlatformsResponse
oauthAll except BlueskyA sign-in url and its expiresAt
accountBlueskyThe reconnected account

Platforms With a Sign-In

Send the redirectUrl the browser returns to. It is required with an API key.

import { Configuration, AccountsApi } from "@onepostly/sdk";

const accountsApi = new AccountsApi(
  new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY })
);

const response = await accountsApi.reconnectAccount({
  id: "acc_YOUR_LINKEDIN_ACCOUNT_ID",
  reconnectAccountBody: {
    "redirectUrl": "https://yourapp.com/oauth/onepostly"
  },
});
console.log(response);
{
  "type": "oauth",
  "url": "https://www.linkedin.com/oauth/v2/authorization?response_type=code&state=eyJhbGciOiJIUzI1NiJ9",
  "expiresAt": "2027-03-15T10:10:00.000Z"
}

Send the user to the url within 10 minutes. They must sign in with the same account, and no Page picker is shown.

A success redirects with the usual parameters plus reconnected=1. Another account returns error=RECONNECT_MISMATCH. Other failures use the Redirect Errors codes.

Bluesky

Send the identifier and a new appPassword. The identifier has to belong to the same Bluesky account. The response has type set to account, with the reconnected account in account.

import { Configuration, AccountsApi } from "@onepostly/sdk";

const accountsApi = new AccountsApi(
  new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY })
);

const response = await accountsApi.reconnectAccount({
  id: "acc_YOUR_BLUESKY_ACCOUNT_ID",
  reconnectAccountBody: {
    "identifier": "yourbrand.bsky.social",
    "appPassword": "qrst-uvwx-yzab-cdef"
  },
});
console.log(response);
{
  "type": "account",
  "account": {
    "id": "acc_YOUR_BLUESKY_ACCOUNT_ID",
    "platform": "bluesky",
    "displayName": "Your Brand",
    "handle": "yourbrand.bsky.social",
    "avatarUrl": "https://cdn.onepostly.com/avatars/yourbrand.jpg",
    "status": "active",
    "canAutoRenew": true,
    "tokenExpiresAt": "2027-03-15T12:00:00.000Z",
    "profile": "Default",
    "metadata": {},
    "createdAt": "2027-03-01T10:00:00.000Z",
    "updatedAt": "2027-03-15T10:00:00.000Z"
  }
}

Disconnect an Account

DELETE /v1/accounts/{id} needs a read_write key and returns 204. Only YouTube also withdraws the access on the platform. Elsewhere, the owner can remove Onepostly in the platform's app settings.

import { Configuration, AccountsApi } from "@onepostly/sdk";

const accountsApi = new AccountsApi(
  new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY })
);

const response = await accountsApi.deleteAccount({
  id: "acc_YOUR_LINKEDIN_ACCOUNT_ID",
});
console.log(response);
After a disconnectResult
Published postsStay on the platform
Its posts in OnepostlyKeep their history
GET /v1/accounts/{id}404 ACCOUNT_NOT_FOUND
BillingStops counting from the next UTC day
Webhookaccount.disconnected

An account is also disconnected when its owner removes Onepostly in Facebook, Instagram or Threads settings, or asks the platform to delete their data. Connecting it again counts as a new account.

Errors

CodeHTTPCauseFix
REDIRECT_URL_REQUIRED400No redirectUrl with an API keySend redirectUrl
INVALID_REDIRECT_URL400Not a full https URL, or has credentialsSend a full https URL
BLUESKY_RECONNECT_APP_PASSWORD400identifier or appPassword is missingSend both
RECONNECT_MISMATCH400Another Bluesky account's identifierUse the original account
FORBIDDEN403A read_only keyUse a read_write key
ACCOUNT_NOT_FOUND404No such account, or already disconnectedUse a current id
AUTH_FAILED422Bluesky rejected the credentialsCreate a new App Password
PLATFORM_MAINTENANCE503Connections to the platform are pausedTry again later

See Errors for every other code.