> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postsyncer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Error Handling

> Learn how to handle API errors and responses properly

# Error Handling

The PostSyncer API uses standard HTTP status codes and returns detailed error messages to help you debug issues quickly.

## HTTP Status Codes

| Status Code | Description                               |
| ----------- | ----------------------------------------- |
| `200`       | Success - Request completed successfully  |
| `201`       | Created - Resource created successfully   |
| `400`       | Bad Request - Invalid request parameters  |
| `401`       | Unauthorized - Invalid or missing API key |
| `403`       | Forbidden - Insufficient permissions      |
| `404`       | Not Found - Resource doesn't exist        |
| `422`       | Unprocessable Entity - Validation errors  |
| `429`       | Too Many Requests - Rate limit exceeded   |
| `500`       | Internal Server Error - Server error      |

## Error Response Format

All error responses follow this format:

```json theme={null}
{
  "message": "Human-readable error message",
  "errors": {}
}
```

## Common Error Codes

### Authentication Errors

```json theme={null}
{
  "message": "Unauthenticated"
}
```

### Validation Errors

```json theme={null}
{
    "message": "The workspace id field is required.",
    "errors": {
        "workspace_id": [
            "The workspace id field is required."
        ]
    }
}
```

### Rate Limit Errors

```json theme={null}
{
  "message": "Too Many Attempts."
}
```

## Best Practices

<CardGroup cols={2}>
  <Card title="Check Status Codes" icon="code">
    Always check HTTP status codes before processing responses
  </Card>

  <Card title="Handle Rate Limits" icon="clock">
    Implement retry logic for 429 responses with exponential backoff
  </Card>

  <Card title="Log Errors" icon="file-text">
    Log detailed error information for debugging
  </Card>

  <Card title="Validate Input" icon="check">
    Validate data before sending to avoid 422 errors
  </Card>
</CardGroup>
