API
API errors
Every API error has the same JSON shape with a stable code. The list of status codes and error codes, and how to handle each one.
On this page
Errors use one shape:
{
"error": {
"code": "not_found",
"message": "Workspace not found.",
"details": null
}
}Handle errors by code, and by details.reason when the code is conflict. The message is for people. Server errors carry a request id in details.requestId, and every answer has an X-Request-Id header.
Status codes and codes
| Status | Code | What it means | What to do |
|---|---|---|---|
| 400 | validation_error | The input is not valid. details lists the fields. | Fix the request. |
| 400 | idempotency_key_required | A call that spends credits needs an Idempotency-Key header. | Add the header. |
| 400 | linkedin_not_connected | The workspace has no working LinkedIn connection, or it needs to be renewed. | Connect LinkedIn in the app. |
| 401 | api_key_required | No x-api-key header. | Send the key. |
| 401 | api_key_invalid | The key is unknown, revoked or expired, or its creator left the organization. | Create a new key. |
| 402 | subscription_required | The trial ended or there is no live subscription. | Fix the plan in the app. |
| 402 | insufficient_credits | There are not enough credits for the call. Nothing is charged. | Wait for the monthly reset or add credits. |
| 403 | plan_limit | Your plan does not include the API, or a daily cap was reached. | Wait for the cap to reset or change the plan. |
| 403 | forbidden | The key's role cannot do this. | Use a key from someone with the right role. |
| 404 | not_found | The id does not exist, or the key cannot reach it. | Check the id and the workspace. |
| 409 | idempotency_conflict | The same key was used with a different body. | Use a new key for a new request. |
| 409 | post_locked | The post cannot be changed now, for example while it is publishing. details.reason says why. | Try again later. |
| 409 | conflict | details.reason is request_in_progress (a request with this key is still running) or already_done (the change was already made). Other reasons exist, such as item_moved. | For request_in_progress, wait and retry with the same key. For already_done, there is nothing to do. |
| 422 | post_too_long | The text is longer than LinkedIn allows. | Shorten the post. |
| 429 | rate_limited | Too many requests. See Retry-After. | Wait and retry. See Rate limits. |
| 503 | A dependency is down. Nothing was started. | Retry with the same Idempotency-Key. |
Idempotency
Send an Idempotency-Key on every call that spends credits. A retry with the same key and body returns the first answer and is never charged twice. The same key with another body returns idempotency_conflict. Answers are kept for a day.
Questions
Which part of an error should my code rely on?
The code. Messages are written for people and can change. Codes are stable.
What should I do with a 5xx answer?
Retry with the same Idempotency-Key. The answer includes a request id in details, and the same id is in the X-Request-Id header. Send it to support if the problem continues.
Related
- API overview: Create drafts, schedule posts, build carousels and infographics from your own tools with a REST API and an API key. Base URL, conventions and a first request.
- API rate limits: How many API requests a key and a workspace can make each minute, the headers that show what is left, and how to back off when you get a 429.
- API authentication: How API keys work. Send a key in the x-api-key header. Create, name and revoke keys in Settings. Keys are shown once, so keep them on your server.
Last updated