API Reference
Complete reference documentation for the CloudBooks REST API. Build powerful integrations and automate your workflows with our comprehensive API.
Quick Start
Get started with the CloudBooks API in minutes. Follow our comprehensive guides and examples to integrate CloudBooks into your applications.
Base URL
Authentication
Getting Started
The CloudBooks API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Prerequisites
- A CloudBooks account (sign up for free at cloudbooks.com)
- An API key (generate from your dashboard)
- Basic understanding of REST APIs and HTTP
Making Your First Request
Here's a simple example to get you started. This request retrieves your user profile:
curl -X POST https://api.cloudbooks.com/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "your_password"
}'Authentication
The CloudBooks API uses API keys to authenticate requests. You can view and manage your API keys in the CloudBooks Dashboard.
Security Best Practices
- •Keep your API keys secure and never share them publicly
- •Use environment variables to store API keys
- •Rotate API keys regularly
- •Use different keys for production and testing
Authentication Methods
API Key Authentication
Include your API key in the Authorization header of every request:
Authorization: Bearer sk_live_1234567890abcdefOAuth 2.0
For applications that need to access user data on behalf of other users:
Authorization: Bearer user_access_tokenAPI Endpoints
Authentication
/auth/loginAuthenticate user and get access token
/auth/refreshAuth requiredRefresh access token
/auth/logoutAuth requiredInvalidate access token
Users
/users/meAuth requiredGet current user profile
/users/meAuth requiredUpdate current user profile
/users/{id}Auth requiredGet user by ID
/users/meAuth requiredDelete current user account
Organizations
/organizationsAuth requiredList all organizations
/organizationsAuth requiredCreate new organization
/organizations/{id}Auth requiredGet organization by ID
/organizations/{id}Auth requiredUpdate organization
/organizations/{id}Auth requiredDelete organization
Projects
/projectsAuth requiredList all projects
/projectsAuth requiredCreate new project
/projects/{id}Auth requiredGet project by ID
/projects/{id}Auth requiredUpdate project
/projects/{id}Auth requiredDelete project
Code Examples
Here are examples in multiple programming languages to help you get started quickly:
JavaScript / Node.js
const response = await fetch('https://api.cloudbooks.com/v1/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'your_password'
})
});
const data = await response.json();
console.log(data);TypeScript
interface LoginRequest {
email: string;
password: string;
}
interface LoginResponse {
token: string;
user: User;
}
async function login(credentials: LoginRequest): Promise<LoginResponse> {
const response = await fetch('https://api.cloudbooks.com/v1/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(credentials)
});
if (!response.ok) {
throw new Error('Login failed');
}
return response.json();
}Python
import requests
url = 'https://api.cloudbooks.com/v1/auth/login'
payload = {
'email': 'user@example.com',
'password': 'your_password'
}
response = requests.post(url, json=payload)
data = response.json()
print(data)Error Handling
CloudBooks uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success, codes in the 4xx range indicate an error from the provided information, and codes in the 5xx range indicate server errors.
OK
Request succeeded
Created
Resource successfully created
Bad Request
Invalid request parameters
Unauthorized
Authentication credentials missing or invalid
Forbidden
Authenticated but lacks permissions
Not Found
Requested resource does not exist
Too Many Requests
Rate limit exceeded
Internal Server Error
Something went wrong on our end
Error Response Format
{
"error": {
"code": "invalid_request",
"message": "Invalid email format",
"details": {
"field": "email",
"issue": "Must be a valid email address"
}
}
}Rate Limits
The CloudBooks API enforces rate limits to ensure system stability and fair usage across all customers. Rate limits vary based on your subscription plan.
Free
per hour
Pro
per hour
Enterprise
unlimited
Rate Limit Headers
Every API response includes headers to help you track your usage:
SDKs & Libraries
We provide official SDKs in popular programming languages to make integration easier. Each SDK includes type definitions, comprehensive documentation, and code examples.
JavaScript / TypeScript
npm install @cloudbooks/sdkPython
pip install cloudbooks-sdkRuby
gem install cloudbooksPHP
composer require cloudbooks/sdkGo
go get github.com/cloudbooks/go-sdkJava
Maven / Gradle available