Overview
Authentication
Create an API key and send it with your requests.
Every request to https://api.onepostly.com needs an API key from your workspace. A key only works for its own workspace. It reaches every account and post in it, or only those of some profiles.
Create an API Key
Open API Keys in the dashboard. Every member of the workspace can create keys.
Click Create Key and give the key a name. Pick its permission, expiration, profile access and the parts of the API it can use.
Copy the key. It starts with op_ and is shown only once.
None of these choices can be changed later. To change one, create a new key and delete the old one.
| Role | Keys they see and delete |
|---|---|
| Member | The keys they created |
| Owner or admin | Every key of the workspace |
A key works for the whole workspace, whoever created it. When a member leaves the workspace or deletes their account, the keys they created are deleted.
| Permission | Access |
|---|---|
read_write | Read and write. This is the default |
read_only | Read only. Write requests return 403 FORBIDDEN |
Expiration
A key never expires by default. You can give it a lifetime of 7, 30 or 90 days, or 1 year. After that, every request with it returns 401 UNAUTHORIZED. The API Keys page shows when each key expires.
Profile Access
A key reaches every profile by default. You can limit it to some profiles instead, such as a key for each client.
| Request | With a key limited to some profiles |
|---|---|
| Accounts, posts, comments, inbox, analytics and automations | Only those of the profiles' accounts. Others return 404 |
| Connecting an account | It goes to one of the key's profiles. See below |
GET /v1/profiles | Lists only the key's profiles |
| Creating, renaming or deleting a profile | 403 FORBIDDEN |
| Media, webhooks and the wallet | The whole workspace, as with any key |
When a key with one profile connects an account, the account goes to that profile. A key with several profiles must name one of them in profile. Without it, the request returns 400 VALIDATION_ERROR, and another profile returns 403 FORBIDDEN.
The key keeps working when you rename its profiles. You cannot delete a profile while a key is limited to it.
Restrict Access
A key can use the whole API by default. You can turn off parts of it, so the key can only do the work it is made for. A request to a part that is off returns 403 GROUP_DISABLED, with the part's name in details.group.
| Part | details.group | Endpoints |
|---|---|---|
| Publishing | publishing | /v1/posts, /v1/media and POST /v1/accounts/{id}/sync |
| Engagement | engagement | Comments, private replies, likes, bookmarks, reposts and reposters |
| Messages | messages | /v1/accounts/{id}/conversations and /v1/automations |
| Analytics | analytics | /v1/posts/{id}/analytics and /v1/accounts/{id}/analytics |
| Accounts | accounts | /v1/accounts, its settings and resources, /v1/connect-sessions and /v1/profiles |
| Billing | billing | /v1/wallet |
| Webhooks | webhooks | /v1/webhooks and its deliveries |
At least one part stays on.
Send the Key
Send the key as a bearer token in the Authorization header.
Authorization: Bearer op_YOUR_KEYUse the SDK
The samples in these docs read the key from the ONEPOSTLY_API_KEY environment variable.
export ONEPOSTLY_API_KEY="op_YOUR_KEY"This request lists your accounts, so it is a quick way to check that your key works.
import { Configuration, AccountsApi } from "@onepostly/sdk";
const accountsApi = new AccountsApi(
new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY })
);
const response = await accountsApi.listAccounts();
console.log(response);{
"data": [
{
"id": "acc_1699f4157fb643f49d2ac447491f3202",
"platform": "linkedin",
"displayName": "Your Brand",
"handle": "Your Brand",
"avatarUrl": "https://cdn.onepostly.com/avatars/yourbrand.jpg",
"status": "active",
"canAutoRenew": false,
"tokenExpiresAt": "2027-05-14T10:00:00.000Z",
"profile": "Default",
"metadata": {},
"createdAt": "2027-03-01T10:05:00.000Z",
"updatedAt": "2027-03-01T10:05:00.000Z"
},
{
"id": "acc_1699f4157fb643f49d2ac447491f32a8",
"platform": "x",
"displayName": "Your Brand",
"handle": "yourbrand",
"avatarUrl": "https://cdn.onepostly.com/avatars/yourbrand.jpg",
"status": "active",
"canAutoRenew": true,
"tokenExpiresAt": "2027-05-14T10:00:00.000Z",
"profile": "Default",
"metadata": {},
"xSubscriptionType": "None",
"createdAt": "2027-03-01T10:00:00.000Z",
"updatedAt": "2027-03-01T10:00:00.000Z"
}
],
"nextCursor": null,
"hasMore": false
}See SDKs to install and configure the Node.js and Python clients.
Errors
| Code | HTTP | Cause | Fix |
|---|---|---|---|
UNAUTHORIZED | 401 | The key is missing, wrong, expired or deleted | Send the full key and check that it still exists on the API Keys page |
FORBIDDEN | 403 | A read_only key called a write endpoint, or a key limited to some profiles went outside them | Use a key with the access you need |
GROUP_DISABLED | 403 | The key's part of the API in details.group is off | Use a key that has this part |
In TypeScript these errors throw a ResponseError, and in Python they raise an ApiException. The response body has a requestId. Share it with support when you need help. See Errors.
Keep Keys Safe
- Keep keys on your server. Never put them in browser or mobile code, or in version control.
- Store them in environment variables or a secret manager.
- Use a separate key for each app or environment. Then you can delete one without breaking the others.
- Use a
read_onlykey for integrations that only read data. - Limit a key to the profiles and parts of the API it needs.
- Give a key an expiration when it is only needed for a while.
Rotate a Key
Create a new key and deploy it. Then delete the old key on the API Keys page. Requests that still use the old key return 401 UNAUTHORIZED.