API Usage
Learn how to use the 2GC CloudBridge API for automation, integration, and custom workflows.
API Basics
Base URL
https://api.2gc.ru/v1
All API requests should be made to this base URL
Content Type
application/json
All requests and responses use JSON format
Authentication
Header Format
Authorization: Bearer YOUR_API_TOKEN
Common Operations
Users API
Get All Users
GET /api/users
Authorization: Bearer YOUR_API_TOKEN
Create User
POST /api/users
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"email": "user@example.com",
"name": "John Doe",
"role": "user"
}
Update User
PUT /api/users/{userId}
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"name": "John Smith",
"role": "admin"
}
Organizations API
Get Organization
GET /api/organizations/{orgId}
Authorization: Bearer YOUR_API_TOKEN
Update Organization
PUT /api/organizations/{orgId}
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"name": "Updated Organization Name",
"settings": {
"timezone": "UTC",
"language": "en"
}
}
Groups API
Get Groups
GET /api/groups
Authorization: Bearer YOUR_API_TOKEN
Create Group
POST /api/groups
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"name": "Development Team",
"description": "Software development team",
"permissions": ["read:users", "write:projects"]
}
Add User to Group
POST /api/groups/{groupId}/users
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"userId": "user_123"
}
Rate Limiting
1000
Requests per hour
100
Requests per minute
10
Requests per second
Rate Limit Headers
Check the X-RateLimit-*
headers in API responses to monitor your rate limit usage.
Error Handling
Common Error Codes
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
429 Rate Limited
500 Server Error
Error Response Format
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid email format",
"details": {
"field": "email",
"value": "invalid-email"
}
}
}
Best Practices
Security
- Always use HTTPS
- Store tokens securely
- Validate all input data
- Implement proper error handling
Performance
- Use pagination for large datasets
- Implement caching strategies
- Monitor rate limits
- Use appropriate HTTP methods