Claude Code

CLI Tool

Claude Code là công cụ lập trình agent của Anthropic, chạy trực tiếp trong terminal. Cung cấp cho nó tài liệu tham chiếu API của VPS.org dưới dạng tệp CLAUDE.md, rồi dùng ngôn ngữ tự nhiên để triển khai máy chủ, quản lý tên miền và cấu hình hạ tầng.

https://docs.anthropic.com/en/docs/claude-code
Tải về tập tin.md
$ claudecode "triển khai ứng dụng của tôi đến VPS.org"
Đang tạo máy phục vụ... hoàn thành
Đang đăng ký miền... hoàn thành
Đang cấu hình DNS... hoàn thành
Đang triển khai ứng dụng... hoàn thành
App live at https://myapp.com

Claude Code Tính năng

Chạy trong terminal

Chạy trực tiếp trong terminal với quyền truy cập shell đầy đủ để thực thi lệnh và lệnh gọi API.

Thực thi tự động

Tự động lập kế hoạch và thực thi các quy trình nhiều bước mà không cần can thiệp thủ công.

Hỗ trợ tệp ngữ cảnh

Đọc CLAUDE.md từ thư mục gốc của dự án, nên rất phù hợp để nạp tài liệu tham chiếu API.

Làm thế nào? Claude Code Làm việc với VPS.org

Sử dụng Claude Code với VPS.org

Claude Code có thể đọc tệp tham chiếu API của VPS.org và dùng nó làm ngữ cảnh để viết và thực thi các lệnh gọi API nhằm triển khai máy chủ, đăng ký tên miền và cấu hình DNS. Chỉ cần đặt tệp .md vào thư mục gốc của dự án dưới tên CLAUDE.md, Claude Code sẽ tự động dùng nó làm ngữ cảnh.

Hướng dẫn thiết lập

  1. Tải tệp .md bên dưới
  2. Lưu tệp dưới tên CLAUDE.md trong thư mục gốc của dự án
  3. Chạy claude trong terminal
  4. Yêu cầu Claude triển khai ứng dụng của bạn lên VPS.org

Ví dụ lệnh

  • "Tạo một máy chủ VPS mới với Ubuntu 22.04 trên gói Standard"
  • "Đăng ký myapp.com và trỏ về máy chủ của tôi"
  • "Thiết lập bản ghi DNS cho myapp.com với bản ghi A trỏ tới địa chỉ IP máy chủ của tôi"
  • "Tạo bản sao lưu cho máy chủ web của tôi"

Tập tin tham chiếu API

Đây là nội dung đầy đủ của tập tin.md. Sao chép hoặc tải xuống nó để sử dụng với Claude Code.

Tải về tập tin.md
# VPS.org API Integration Guide for Claude Code

This document provides Claude Code with the information needed to interact
with the VPS.org cloud hosting API. Use these endpoints to create servers,
register domains, configure DNS, and manage cloud infrastructure.

Place this file as `CLAUDE.md` in your project root for automatic context loading.

## Quick Start
1. Get API token from https://admin.vps.org/account/developers/
2. Use `Authorization: Bearer <your-token>` header in all requests
3. Base URL: https://admin.vps.org/api/v1/

## Authentication

All API requests require a Bearer token. Generate one at https://admin.vps.org/account/developers/

```
Authorization: Bearer YOUR_API_TOKEN
```

**Base URL:** `https://admin.vps.org/api/v1/`

**Rate Limit:** 300 requests per 5 minutes per token.

**Token Format:** Tokens start with `vps_` followed by 64 hex characters. They are SHA256-hashed before storage.

**Permission System:** Tokens use `app:action` format permissions (e.g., `servers:create`, `dns:*`, `*:*` for full access).

---

## Servers

### List All Servers
```
GET /api/v1/servers/
```
**Query Parameters:**
- `status` (string, optional) — Filter by status: `active`, `stopped`, `suspended`
- `location` (string, optional) — Filter by datacenter location

**Response (200):**
```json
{
  "count": 2,
  "results": [
    {
      "id": 12345,
      "name": "web-server-01",
      "hostname": "web01.example.com",
      "status": "active",
      "ip_address": "203.0.113.10",
      "location": "us-west",
      "plan": {"id": 1, "name": "Standard VPS", "vcpus": 2, "memory": 4096, "storage": 80},
      "os": {"id": 5, "name": "Ubuntu 22.04 LTS"},
      "created_at": "2025-01-10T14:30:00Z"
    }
  ]
}
```

### Create New Server
```
POST /api/v1/servers/
```
**Request Body:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| name | string | Yes | Server name (alphanumeric, hyphens allowed) |
| plan_id | integer | Yes | ID of the VPS plan |
| os_id | integer | Yes | ID of the operating system |
| location | string | Yes | Datacenter location code |
| hostname | string | No | Server hostname (FQDN) |
| ssh_key_id | integer | No | SSH key ID to install |
| backups_enabled | boolean | No | Enable automatic backups (default: false) |

**Response (201):**
```json
{
  "id": 12347,
  "name": "web-server-02",
  "hostname": "web02.example.com",
  "status": "provisioning",
  "ip_address": null,
  "location": "us-west",
  "plan": {"id": 1, "name": "Standard VPS", "vcpus": 2, "memory": 4096, "storage": 80},
  "os": {"id": 5, "name": "Ubuntu 22.04 LTS"},
  "backups_enabled": true,
  "message": "Server is being provisioned. This may take 2-5 minutes."
}
```

### Get Server Details
```
GET /api/v1/servers/{server_id}/
```
**Response (200):** Full server object including `resource_usage` (cpu_percent, memory_used, disk_used, bandwidth_used).

### Update Server
```
PUT /api/v1/servers/{server_id}/
```
**Request Body:** `name` (string), `hostname` (string), `backups_enabled` (boolean) — all required.

### Partial Update Server
```
PATCH /api/v1/servers/{server_id}/
```
Only provided fields will be updated.

### Delete Server
```
DELETE /api/v1/servers/{server_id}/
```
**Response:** 204 No Content. This action cannot be undone.

### Power Management
```
POST /api/v1/servers/{server_id}/start/    — Power on a stopped server
POST /api/v1/servers/{server_id}/stop/     — Gracefully shut down a running server
POST /api/v1/servers/{server_id}/reboot/   — Restart a running server
```
**Response (200):**
```json
{
  "status": "success",
  "message": "Server is starting",
  "server": {"id": 12345, "name": "web-server-01", "status": "starting"}
}
```

---

## Plans

### List All Plans
```
GET /api/v1/plans/
```
Returns available VPS plans with pricing, CPU, memory, storage, and bandwidth details.

### Get Plan Details
```
GET /api/v1/plans/{plan_id}/
```

---

## Operating Systems

### List Operating Systems
```
GET /api/v1/operating-systems/
```
Returns available OS images for server deployment (Ubuntu, Debian, CentOS, etc.).

### Get OS Details
```
GET /api/v1/operating-systems/{os_id}/
```

---

## Locations

### List Datacenter Locations
```
GET /api/v1/locations/
```
Returns available datacenter regions with their codes and capabilities.

---

## Backups

### List Server Backups
```
GET /api/v1/servers/{server_id}/backups/
```

### Create Backup
```
POST /api/v1/servers/{server_id}/backups/
```
**Request Body:**
- `name` (string, optional) — Backup name

### Restore Backup
```
POST /api/v1/servers/{server_id}/backups/{backup_id}/restore/
```

---

## Snapshots

### List Snapshots
```
GET /api/v1/snapshots/
```

### Create Snapshot
```
POST /api/v1/servers/{server_id}/snapshots/
```
**Request Body:**
- `name` (string, optional) — Snapshot name

### Restore Snapshot
```
POST /api/v1/snapshots/{snapshot_id}/restore/
```

### Delete Snapshot
```
DELETE /api/v1/snapshots/{snapshot_id}/
```

---

## SSH Keys

### List SSH Keys
```
GET /api/v1/ssh-keys/
```

### Add SSH Key
```
POST /api/v1/ssh-keys/
```
**Request Body:**
- `name` (string, required) — Key name
- `public_key` (string, required) — SSH public key content

### Delete SSH Key
```
DELETE /api/v1/ssh-keys/{key_id}/
```

---

## Domains

### List All Domains
```
GET /api/v1/domains/
```
**Query Parameters:**
- `status` (string, optional) — Filter: `active`, `pending`, `expired`, `locked`
- `search` (string, optional) — Search domains by name

**Response (200):**
```json
{
  "count": 2,
  "results": [
    {
      "id": 101,
      "domain_name": "example.com",
      "status": "active",
      "registration_date": "2023-01-15T10:30:00Z",
      "expiration_date": "2026-01-15T10:30:00Z",
      "auto_renew": true,
      "locked": true,
      "nameservers": ["ns1.vps.org", "ns2.vps.org"],
      "privacy_protection": true
    }
  ]
}
```

### Register New Domain
```
POST /api/v1/domains/
```
**Request Body:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| domain_name | string | Yes | Domain to register (e.g., "example.com") |
| years | integer | No | Registration period 1-10 (default: 1) |
| auto_renew | boolean | No | Enable auto-renewal (default: true) |
| privacy_protection | boolean | No | Enable WHOIS privacy (default: true) |
| nameservers | array | No | Custom nameservers (default: VPS.org) |

**Response (201):** Domain object with `status: "pending"`. Registration takes 5-10 minutes.

### Get Domain Details
```
GET /api/v1/domains/{domain_id}/
```

### Update Domain Settings
```
PUT /api/v1/domains/{domain_id}/
```
**Request Body:** `auto_renew`, `privacy_protection`, `nameservers`, `locked` — all optional.

### Delete Domain
```
DELETE /api/v1/domains/{domain_id}/
```
Removes from account only. Domain registration remains active.

### Transfer Domain
```
POST /api/v1/domains/{domain_id}/transfer/
```
**Request Body:**
- `auth_code` (string, required) — EPP/Authorization code from current registrar
- `auto_renew` (boolean, optional) — Enable auto-renewal after transfer

---

## DNS Zones

### List DNS Zones
```
GET /api/v1/dns-zones/
```
**Query Parameters:**
- `domain` (string, optional) — Filter by exact domain name

**Response (200):**
```json
[
  {
    "uuid": "abc123-def456-ghi789",
    "domain": "example.com",
    "created_at": "2024-01-15T10:30:00Z",
    "record_count": 12
  }
]
```

### Create DNS Zone
```
POST /api/v1/dns-zones/
```
**Request Body:**
- `domain` (string, required) — Domain name (e.g., "example.com")

### Get DNS Zone Details
```
GET /api/v1/dns-zones/{uuid}/
```
Returns zone with all records.

### Delete DNS Zone
```
DELETE /api/v1/dns-zones/{uuid}/
```

---

## DNS Records

### List Records in Zone
```
GET /api/v1/dns-zones/{uuid}/records/
```

### Create DNS Record
```
POST /api/v1/dns-zones/{uuid}/records/
```
**Request Body:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| record_type | string | Yes | A, AAAA, CNAME, MX, TXT, NS, SRV, CAA |
| name | string | Yes | Record name (@ for root, subdomain, or FQDN) |
| value | string | Yes | Record value (IP, hostname, text) |
| ttl | integer | No | Time to live in seconds (default: 3600) |
| priority | integer | MX/SRV | Priority (required for MX and SRV records) |

**Response (201):**
```json
{
  "uuid": "rec-003",
  "record_type": "A",
  "name": "www",
  "value": "192.0.2.1",
  "ttl": 3600,
  "priority": null,
  "created_at": "2026-01-18T16:50:00Z"
}
```

### Manage Individual Records
```
GET    /api/v1/dns-records/{uuid}/   — Get record details
PUT    /api/v1/dns-records/{uuid}/   — Full update (all fields required)
PATCH  /api/v1/dns-records/{uuid}/   — Partial update
DELETE /api/v1/dns-records/{uuid}/   — Delete record
```

**Supported Record Types:** A, AAAA, CNAME, MX, TXT, NS, SRV, CAA

---

## Common Workflows

### Deploy a New Application
```
1. GET  /api/v1/plans/                              — Choose a plan
2. GET  /api/v1/operating-systems/                   — Choose an OS
3. GET  /api/v1/locations/                           — Choose a datacenter
4. POST /api/v1/servers/                             — Create the server
   Body: {"name": "myapp", "plan_id": 1, "os_id": 5, "location": "us-west"}
5. GET  /api/v1/servers/{id}/                        — Poll until status is "active"
6. SSH into server using the IP address to deploy your application
```

### Set Up a Domain with DNS
```
1. POST /api/v1/domains/                             — Register domain
   Body: {"domain_name": "myapp.com", "years": 1}
2. POST /api/v1/dns-zones/                           — Create DNS zone
   Body: {"domain": "myapp.com"}
3. POST /api/v1/dns-zones/{uuid}/records/            — Add A record
   Body: {"record_type": "A", "name": "@", "value": "SERVER_IP", "ttl": 3600}
4. POST /api/v1/dns-zones/{uuid}/records/            — Add www CNAME
   Body: {"record_type": "CNAME", "name": "www", "value": "myapp.com", "ttl": 3600}
```

### Full Deployment (Server + Domain + DNS)
```
1. Create server (see above)
2. Wait for server to become active, note the IP address
3. Register domain
4. Create DNS zone
5. Add A record pointing to server IP
6. Add any additional records (MX for email, TXT for verification, etc.)
7. SSH into server and deploy your application
8. (Optional) Set up SSL with Let's Encrypt
```

---

## Error Codes

| Status | Description |
|--------|-------------|
| 200 | Success |
| 201 | Created |
| 204 | No Content (successful deletion) |
| 400 | Bad Request — Invalid parameters |
| 401 | Unauthorized — Invalid or missing token |
| 402 | Payment Required — Insufficient credits |
| 403 | Forbidden — Insufficient permissions |
| 404 | Not Found — Resource doesn't exist |
| 429 | Too Many Requests — Rate limit exceeded |
| 500 | Internal Server Error |

**Rate Limit Headers:**
- `X-RateLimit-Limit` — Maximum requests allowed
- `X-RateLimit-Remaining` — Requests remaining
- `X-RateLimit-Reset` — Timestamp when limit resets

---

## Nameserver Infrastructure

- **ns1.vps.org** (38.248.6.195) — Primary master with DNSSEC
- **ns2.vps.org** (38.248.6.196) — Secondary
- **ns3.vps.org** (38.248.6.197) — Secondary

## Support

- **Support Tickets:** https://admin.vps.org/tickets/
- **Email:** hello@vps.org
- **Documentation:** https://www.vps.org/docs/
- **API Docs:** https://www.vps.org/api/