Error Format
All errors return JSON:Common Errors
400 Bad Request
Missing required fields:401 Unauthorized
Missing token:Authorization: Bearer YOUR_TOKEN header.
Expired token:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Common errors and how to fix them
{
"error": "Error message",
"detail": "More details"
}
{
"field_name": ["Error message"],
"email": ["This field is required."]
}
{
"password": ["This field is required."]
}
{
"username": ["This username is already taken in your organization."]
}
{
"detail": "Authentication credentials were not provided."
}
Authorization: Bearer YOUR_TOKEN header.
Expired token:
{
"detail": "Token is expired"
}
{
"detail": "You do not have permission to perform this action."
}
{
"detail": "Not found."
}
import requests
def create_student(token, data):
headers = {"Authorization": f"Bearer {token}"}
try:
response = requests.post(
"https://api.chessplay.io/api/v1/students/",
headers=headers,
json=data
)
response.raise_for_status()
return response.json()
except requests.exceptions.HTTPError as e:
if e.response.status_code == 400:
print(f"Validation error: {e.response.json()}")
elif e.response.status_code == 401:
print("Authentication failed. Login again.")
elif e.response.status_code == 403:
print("Need admin permissions.")
else:
print(f"Error: {e.response.status_code}")
return None
async function createStudent(token, data) {
try {
const response = await fetch('https://api.chessplay.io/api/v1/students/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
if (!response.ok) {
const error = await response.json();
if (response.status === 400) {
console.error('Validation error:', error);
} else if (response.status === 401) {
console.error('Authentication failed. Login again.');
} else if (response.status === 403) {
console.error('Need admin permissions.');
}
throw new Error(error.detail || 'Request failed');
}
return await response.json();
} catch (error) {
console.error('Error:', error);
throw error;
}
}
| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 204 | Deleted |
| 400 | Bad request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not found |
| 500 | Server error |
Was this page helpful?
