Home App Docs Blog Github

Write API - Is it possible to post/patch/update and specify a custom page slug/url?

I am doing something like the snippet of code below and would like to know if I can specify a specific key value pair in the page object that would allow me to provide/update the url/slug of any page via the write api. Thank you!

const response = await axios.post('https://builder.io/api/v1/write/page', page, {
        headers: {
          Authorization: 'Bearer ' + process.env.API_SECRET
        }
 })

Hi @gandalfthedev , you’d want to add a query prop on the object you’re sending that’ similar to this:

        "query": [
          {
            "property": "urlPath",
            "operator": "is", // can be `startsWith` to match any urls that starts with value
            "value": "/my-page" // must start with /
          }
        ] 

PS: you can inspect the content in the GraphQL explorer

Thanks so much for your reply @aziz. May I ask, is there somewhere I could find more information about queries like this? The Write API documentation I’ve found doesn’t include much about more intricate queries. Builder.io Write API - Builder.io

For example how would I also query for the page SEO title?