CMS API - Pages - I Have Questions

I am trying to figure out if I can be more efficient and eliminate manual work for new clients by using the CMS API. We have a custom theme where the page templates have content included (matches a demo site that we built). Once the client has signed, I upload the theme, create the child theme then manually create the website pages tied to each page template (22 pages).

Main question-

Could I use the get request to retrieve all of the pages from our demo site then use that json data to “post” those pages to the new client portal?

If so, I have other questions.

1. For the access tokens, would I need to create a private app in the Demo portal for the get request and a private app in the client portal for the post request?

2. Would I have to modify any of the get request json data in order to use it in the post request? I am assuming there are some differences, especially if using the create batch option.

Obviously a rookie on the API stuff. I have used it a few times in Postman for some simple stuff but that was a while ago and nothing involving a ton of data.

Thanks,

Terry McMillan

Hi @tmcmillan99,

To answer your main question, yes, using the Pages API is possible in this case and is one of the recommended options to transfer pages from a development portal to production.

Regarding the other questions:

1. For the access tokens, would I need to create a private app in the Demo portal for the get request and a private app in the client portal for the post request?

Yes, you would need to create a private app in both of the portals and each app will provide you with an access token for that specific HubSpot portal. You don’t need to specify your portal ID in these API calls because the access key already knows where to go.

2. Would I have to modify any of the get request json data in order to use it in the post request? I am assuming there are some differences, especially if using the create batch option.

You should be able to copy the json from the “results” in the returned data. However, there is always a chance something can go wrong, so I would suggest doing a simple test of getting a single page first from your Demo portal and create a new site page with the json you get from the results of the first API call.

Demo portal:

GET /cms/v3/pages/site-pages/{objectId}

Client portal:

POST /cms/v3/pages/site-pages

If no errors and result is what you expected, you can try doing a couple of pages in the batch create first or do all of them - the error messages will typically indicate if there are any issues.

Demo portal:

GET /cms/v3/pages/site-pages

Client portal:

POST /cms/v3/pages/site-pages/batch/create

Hope this helps!

@evaldas Thank you for the reply and additional information. Exactly what I was looking for. I will start with your suggestion and test the api with one page. If successful, then I will do a test with multiple pages.