Adding custom page fields to a pageΒΆ

Below is a sample function written in python showing how to add custom page fields to a page.

import requests

AK_USERNAME = '' # Enter your username
AK_PASSWORD = '' # Enter your password

def change_page_fields(page_id, custom_page_fields):

    """ Updates the page at page_id with new custom_page_fields

        Example usage: back-dating old image URLs to use Cloudfront instead of S3

        custom_page_fields should be a dictionary,
        with the keys as the field names and the values as the field values.

        Example: custom_page_fields = {
            "featured_image": ""

    endpoint = 'page'

    # Step 1: Get the page by its ID
    response = requests.get(

    # Step 2: Get the resource_uri from the response
    resource_uri = response.json()['resource_uri']

    # Step 4: Apply custom fields to the page
    response = requests.patch(
        json={'fields': custom_page_fields }

    if response.status_code == 202:
        return "Successfully applied fields {0} to page #{1}".format(

With that function defined, you'll be able to use change_page_fields() with a given page_id and custom_page_fields, like: change_page_fields(1111, {"featured_image": ""}) which will add a custom page field (featured image) for page ID 1111.

Looking at /rest/v1/page/schema/, you'll notice that you can only use the GET HTTP method. In other words, /page/ is read-only, used to retrieve results of existing pages. So if we want to edit an page, we'll need to retrieve the resource_uri using /page/ and then edit that resource by its specific page type.

For example, if you're updating a petitionpage, look at /rest/v1/petitionpage/schema/. You'll notice that you have other http methods available: allowed_detail_http_methods includes get, patch, and put. We'll use PATCH to update the page.