Error Reference
This page documents error responses, status codes, and troubleshooting guidance for the Sharely.ai API.
Error Response Format
Error responses from the Sharely.ai API follow a consistent JSON structure:
{
"error": "Human-readable error description",
"errorId": "550e8400-e29b-41d4-a716-446655440000"
}| Field | Type | Description |
|---|---|---|
error | string | Human-readable description of what went wrong |
errorId | string (UUID) | Correlation ID for the failure. Include it when contacting support — it lets us find the exact server-side log entry |
HTTP Status Codes
The Sharely.ai API uses standard HTTP status codes to indicate success or failure of requests.
Success Codes
| Status Code | Description |
|---|---|
200 OK | Request succeeded, response contains requested data |
201 Created | Resource was successfully created |
204 No Content | Request succeeded, no response body (e.g. deletions) |
Client Error Codes
| Status Code | Description | Common Causes |
|---|---|---|
400 Bad Request | Invalid request format or parameters | Missing required fields, invalid JSON, failed validation, referenced resource doesn't belong to the workspace |
401 Unauthorized | Authentication failed | Missing/invalid Bearer token, expired access token, workspace mismatch, missing role under RBAC |
403 Forbidden | Insufficient permissions | Valid token but the operation crosses a boundary (e.g. a message ID that belongs to a different thread) |
404 Not Found | Resource doesn't exist | Invalid workspace, knowledge, role, thread, or category ID — or the resource was soft-deleted |
Server Error Codes
| Status Code | Description | Action |
|---|---|---|
500 Internal Server Error | Server encountered an error | Retry the request; if it persists, contact support with the errorId |
502 / 503 | Edge or upstream temporarily unavailable | Returned by the network edge rather than the API itself. Retry with exponential backoff |
Common Errors
Authentication Errors
Missing Authorization Header
{
"error": "Missing Authorization header",
"errorId": "..."
}Solution: Include the Authorization: Bearer {access_token} header in your request. The access token is obtained by calling the /workspaces/{workspaceId}/generate-access-key-token endpoint with your API key in the x-api-key header. See Authentication for the complete flow.
Invalid Access Token
{
"error": "Invalid or expired API key",
"errorId": "..."
}Solution: The access token may be expired or invalid. Generate a new access token by calling /workspaces/{workspaceId}/generate-access-key-token with your API key in the x-api-key header. If you're passing the raw API key directly as a Bearer token, this will not work — you must use the two-step authentication flow.
Workspace Mismatch
{
"error": "Token does not match workspace",
"errorId": "..."
}Solution: Access tokens are bound to a workspace. Ensure the workspaceId in the URL matches the workspace the token was generated for.
Validation Errors
Validation failures return 400 with a message describing the first failing field:
{
"error": "type must be one of the following values: FILE, URL, LINK, STRING",
"errorId": "..."
}Solution: Check the endpoint documentation and correct the offending field. Validation messages name the field and the expected format.
Resource Errors
Resource Not Found
{
"error": "Knowledge not found",
"errorId": "..."
}Solution: Verify the resource ID exists and belongs to the workspace in the URL. Soft-deleted resources also return 404.
Search Query Error
{
"error": "Either 'q' or 'title' parameter is required",
"errorId": "..."
}Solution: Provide at least one search parameter as required by the endpoint.
Best Practices for Error Handling
Before you run the following snippets, see the API Key Authentication section on the Authentication page. From there, follow Step 1: Generate Access Token to get an access token. Run that code first, in the same shell session or script as the following snippets. The snippets also rely on the environment variables SHARELY_API_URL, SHARELY_API_KEY, SHARELY_WORKSPACE_ID, and SHARELY_ORGANIZATION_ID, which are described in the Complete Authentication Example.
1. Implement Retry Logic
For transient errors (500, 502, 503), implement retry logic with exponential backoff:
curl --retry 3 \
"$SHARELY_API_URL/v1/workspaces/$SHARELY_WORKSPACE_ID/knowledge" \
-H "Authorization: Bearer $SHARELY_ACCESS_TOKEN" \
-H "organizationid: $SHARELY_ORGANIZATION_ID"2. Log the errorId
Always log the full error response — the errorId is the key to server-side diagnosis:
response=$(curl -s -w '\n%{http_code}' \
"$SHARELY_API_URL/v1/workspaces/$SHARELY_WORKSPACE_ID/knowledge" \
-H "Authorization: Bearer $SHARELY_ACCESS_TOKEN" \
-H "organizationid: $SHARELY_ORGANIZATION_ID")
status=$(tail -n 1 <<< "$response")
body=$(sed '$d' <<< "$response")
if [ "$status" -ge 400 ]; then
jq --arg status "$status" '{status: $status, error: .error, errorId: .errorId}' <<< "$body" >&2
fi3. Handle Specific Status Codes
Different status codes require different handling strategies:
response=$(curl -s -w '\n%{http_code}' \
"$SHARELY_API_URL/v1/workspaces/$SHARELY_WORKSPACE_ID/knowledge" \
-H "Authorization: Bearer $SHARELY_ACCESS_TOKEN" \
-H "organizationid: $SHARELY_ORGANIZATION_ID")
status=$(tail -n 1 <<< "$response")
case "$status" in
400)
# Fix request parameters
;;
401)
# Regenerate the access token from your API key
;;
403)
# The operation crosses a permission boundary — don't retry
;;
404)
# Resource doesn't exist, handle gracefully
;;
500|502|503)
# Retry with backoff
;;
esac4. Validate Before Sending
Validate request data before sending to reduce 400 errors:
validate_knowledge_creation() {
local type="$1"
if [ -z "$type" ]; then
echo "type is required" >&2
return 1
fi
case "$type" in
FILE|URL|LINK|STRING) ;;
*)
echo "type must be one of: FILE, URL, LINK, STRING" >&2
return 1
;;
esac
# Additional validation...
}Getting Help
If you encounter persistent errors or need assistance:
- Check this documentation for solutions
- Review your API key and permissions
- Verify request format matches endpoint specifications
- Contact support at support@sharely.ai with:
- Request details (endpoint, method, parameters)
- Full error response including the
errorId - Timestamp of the error
- Your workspace ID (if applicable)
See Also
- Authentication - Authentication setup and troubleshooting
- API Overview - General API information
- Knowledge API - Knowledge endpoint reference