Update Ghost Settings
Update Ghost Settings Endpoint
Section titled “Update Ghost Settings Endpoint”Use the following endpoint to update Ghost integration settings. Ensure you send the parameters nested under a settings key in the JSON body.
Endpoint
Section titled “Endpoint”PATCH /api/v1/public/integrations/ghost/update-settingsAuthentication
Section titled “Authentication”Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEYCode Examples
Section titled “Code Examples”// Example: Update Ghost integration status and website URLconst settingsToUpdate = { "isIntegrated": true, "autoPublish": "false", "credentials": { "websiteUrl": "https://myblog.example.com", "apiKey": "siteApiKeyPlaceholder" }};
// Endpoint: {API_ENDPOINTS.INTEGRATIONS.GHOST.UPDATE_SETTINGS}fetch('https://api.blogz.ai/api/v1/public/integrations/ghost/update-settings', { method: 'PATCH', // Use PATCH for partial updates headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ settings: settingsToUpdate}) // Send only the settings to update}).then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); // Expecting JSON like { success: true, integration: { ... } }}).then(data => console.log('Ghost settings updated:', data)).catch(error => console.error('Error updating Ghost settings:', error));interface IntegrationGhostCredentials { websiteUrl?: string; apiKey?: string;}
interface IntegrationGhost { isIntegrated?: boolean; autoPublish?: boolean; credentials?: IntegrationGhostCredentials;}
// Define the expected response structureinterface UpdateIntegrationResponse { success: boolean; integration?: IntegrationGhost; // The updated integration state}
// Example: Enable auto-publishing// Only include fields you want to change.const settingsToUpdate: Partial<IntegrationGhost> = { "isIntegrated": true, "autoPublish": "false", "credentials": { "websiteUrl": "https://myblog.example.com", "apiKey": "siteApiKeyPlaceholder" }};
// Endpoint: {API_ENDPOINTS.INTEGRATIONS.GHOST.UPDATE_SETTINGS}fetch('https://api.blogz.ai/api/v1/public/integrations/ghost/update-settings', { method: 'PATCH', // Use PATCH for partial updates headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ settings: settingsToUpdate}) // Send only the settings to update}).then(response => response.json() as Promise<UpdateIntegrationResponse>).then((data: UpdateIntegrationResponse) => console.log('Ghost settings updated:', data)).catch((error: Error) => console.error('Error updating Ghost settings:', error));import requestsimport json
# Endpoint: {API_ENDPOINTS.INTEGRATIONS.GHOST.UPDATE_SETTINGS}api_url = "https://api.blogz.ai/api/v1/public/integrations/ghost/update-settings"api_key = "YOUR_API_KEY"headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
# Only include fields you want to change.settings_to_update = { "settings": { "isIntegrated": True, "autoPublish": "false", "credentials": { "websiteUrl": "https://myblog.example.com", "apiKey": "siteApiKeyPlaceholder" } }}
payload = json.dumps(settings_to_update)
try: # Use PATCH for partial updates response = requests.patch(api_url, headers=headers, data=payload) response.raise_for_status() # Raises HTTPError for bad responses (4XX or 5XX)
# Assuming the response body contains { "success": true, "integration": { ... } } response_data = response.json() print("Ghost settings updated successfully:") print(json.dumps(response_data, indent=2))
except requests.exceptions.RequestException as e: print(f"Error updating Ghost settings: {e}") if e.response is not None: print(f"Status Code: {e.response.status_code}") try: # Try to print JSON error response from API print(f"Response body: {e.response.json()}") except json.JSONDecodeError: print(f"Response body: {e.response.text}")except json.JSONDecodeError: print(f"Error decoding JSON response: {response.text}")# Only include the fields you intend to modify.# Endpoint: {API_ENDPOINTS.INTEGRATIONS.GHOST.UPDATE_SETTINGS}curl -X PATCH https://api.blogz.ai/api/v1/public/integrations/ghost/update-settings \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "settings": { "isIntegrated": true, "autoPublish": "false", "credentials": { "websiteUrl": "https://myblog.example.com", "apiKey": "siteApiKeyPlaceholder" } } }'{ "settings": { "isIntegrated": true, "autoPublish": "false", "credentials": { "websiteUrl": "https://myblog.example.com", "apiKey": "siteApiKeyPlaceholder" } }}