Update Project
Update a project's configuration including name, domain, settings, and hosting options. Only provided fields will be updated; others remain unchanged.
Endpoint
Path Parameters
| Name | Type | Required | Description |
|---|
id | string | Yes | Unique project identifier (e.g., proj_abc123) |
| Name | Required | Description |
|---|
Authorization | Yes | Bearer $PAGEGUN_API_KEY |
Content-Type | Yes | application/json |
Body Parameters
| Name | Type | Required | Description |
|---|
name | string | No | Project display name (1-100 characters) |
domain | string | No | Custom domain (e.g., mywebsite.com) |
status | string | No | Project status: active or archived |
settings | object | No | Project configuration settings |
hosting | object | No | Hosting and domain configuration |
Settings Object
| Name | Type | Required | Description |
|---|
theme | string | No | Visual theme identifier |
favicon | string | No | URL to favicon image (PNG, ICO, or SVG) |
logo | string | No | URL to logo image (PNG, JPG, or SVG) |
custom_css | string | No | Custom CSS styles (max 50KB) |
google_analytics | string | No | Google Analytics tracking ID |
meta_description | string | No | Default meta description for SEO (max 160 characters) |
social_image | string | No | Default social sharing image URL |
Hosting Object
| Name | Type | Required | Description |
|---|
mode | string | No | Hosting mode: full_host, rewrite, or data_mode |
subdomain | string | No | PageGun subdomain (3-50 characters, lowercase) |
custom_domain | string | No | Custom domain name |
ssl_enabled | boolean | No | Enable SSL certificate for custom domain |
cdn_enabled | boolean | No | Enable CDN acceleration |
Response
Returns the updated project object with all current values.
{
"data": {
"id": "proj_abc123",
"name": "Updated Website Name",
"slug": "updated-website-name",
"domain": "newdomain.com",
"status": "active",
"hosting_mode": "full_host",
"page_count": 12,
"settings": {
"theme": "modern",
"favicon": "https://example.com/new-favicon.ico",
"logo": "https://example.com/new-logo.png",
"custom_css": "body { font-family: 'Inter', sans-serif; }",
"google_analytics": "GA-XXXXXXXX-X",
"meta_description": "My updated website description",
"social_image": "https://example.com/new-og-image.png"
},
"hosting": {
"mode": "full_host",
"subdomain": "mysite",
"custom_domain": "newdomain.com",
"ssl_enabled": true,
"cdn_enabled": true
},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-21T09:00:00Z"
}
}
Examples
curl -X PUT "https://api.pagegun.com/projects/proj_abc123" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My Awesome Website",
"domain": "awesome-site.com"
}'
Update Settings Only
curl -X PUT "https://api.pagegun.com/projects/proj_abc123" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"settings": {
"theme": "modern",
"google_analytics": "GA-XXXXXXXX-X",
"meta_description": "Updated SEO description"
}
}'
Update Hosting Configuration
curl -X PUT "https://api.pagegun.com/projects/proj_abc123" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"hosting": {
"mode": "rewrite",
"custom_domain": "mysite.com",
"ssl_enabled": true,
"cdn_enabled": true
}
}'
Archive Project
curl -X PUT "https://api.pagegun.com/projects/proj_abc123" \
-H "Authorization: Bearer $PAGEGUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "archived"
}'
JavaScript Example
const updateProject = async (projectId, updates) => {
const response = await fetch(`https://api.pagegun.com/projects/${projectId}`, {
method: 'PUT',
headers: {
'Authorization': `Bearer ${process.env.PAGEGUN_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(updates)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
};
// Usage
const updated = await updateProject('proj_abc123', {
name: 'My New Site Name',
settings: {
theme: 'modern',
meta_description: 'Updated description'
}
});
Error Responses
400 Bad Request
{
"statusCode": 422,
"name": "invalid_request",
"message": "Validation failed"
}
401 Unauthorized
{
"statusCode": 401,
"name": "unauthorized",
"message": "Invalid or missing API key"
}
403 Forbidden
{
"statusCode": 403,
"name": "forbidden",
"message": "You don't have permission to update this project"
}
404 Not Found
{
"statusCode": 404,
"name": "not_found",
"message": "Project not found"
}
409 Conflict
{
"statusCode": 400,
"name": "conflict",
"message": "Domain already in use"
}
422 Unprocessable Entity
{
"statusCode": 422,
"name": "validation_error",
"message": "Custom CSS exceeds maximum size limit"
}