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

# Error Handling

> API error codes and responses

## Response Structure

All API responses follow this structure:

```json theme={null}
{
  "code": 0,
  "msg": "Success",
  "data": {...}
}
```

* `code: 0` = Success
* `code > 0` = Error

***

## Error Codes

| Code      | Message                    | Description                              |
| --------- | -------------------------- | ---------------------------------------- |
| **0**     | Success                    | Request completed successfully           |
| **429**   | Rate limit exceeded        | Too many POST requests (20/minute limit) |
| **10104** | Record not found           | Resource ID does not exist               |
| **10105** | Invalid API key            | Wrong or missing `x-api-key` header      |
| **18020** | Insufficient credit        | Not enough credits to complete request   |
| **18025** | No permission to call APIs | Account lacks API access permission      |
| **40000** | Parameter error            | Invalid or missing required parameters   |
| **50000** | System error               | Internal server error                    |

***

## Error Response Examples

### Authentication Error

```json theme={null}
{
  "code": 10105,
  "msg": "Invalid API key",
  "data": null
}
```

### Insufficient Credits

```json theme={null}
{
  "code": 18020,
  "msg": "Insufficient credit",
  "data": null
}
```

### Parameter Error

```json theme={null}
{
  "code": 40000,
  "msg": "Parameter error: avatar_id is required",
  "data": null
}
```

### Rate Limit Error

```json theme={null}
{
  "code": 429,
  "msg": "Rate limit exceeded. Please try again later.",
  "data": null
}
```

***

## Best Practices

<CardGroup cols={2}>
  <Card title="Check Response Code" icon="check">
    Always verify the `code` field before processing data
  </Card>

  <Card title="Handle Errors" icon="triangle-exclamation">
    Implement proper error handling for all error codes
  </Card>

  <Card title="Log Errors" icon="file-lines">
    Record error details with timestamps for debugging
  </Card>

  <Card title="Retry Logic" icon="rotate">
    Implement retry for system errors (50000) and rate limits (429)
  </Card>
</CardGroup>

***

## Need Help?

Contact [support@jogg.ai](mailto:support@jogg.ai) with:

* Error code and message
* Request parameters
* Timestamp
* API endpoint

<Note>
  Include your user ID (not your API key) when contacting support.
</Note>
