Take a brand from its files
const url = 'http://localhost:3000/api/v1/brands/example/files/import';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"files":{"additionalProperty":"example"},"assets":{"additionalProperty":"example"},"commit":"example","message":"example","dryRun":true,"merge":true,"base":{"additionalProperty":"example"},"publish":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:3000/api/v1/brands/example/files/import \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "files": { "additionalProperty": "example" }, "assets": { "additionalProperty": "example" }, "commit": "example", "message": "example", "dryRun": true, "merge": true, "base": { "additionalProperty": "example" }, "publish": true }'The brand’s rules, pages, theme and name as the files say them, in one version of its history. With a source that remembers what both sides last agreed, what changed here since is kept: the files win only where both changed the same rule, page or setting, and conflicts names each. Files under assets/ are named in assets by id or by the SHA-256 of their bytes; a 422 lists every problem at its file and line (detail.errors) and the files to upload first (detail.missing); a brand.yaml whose slug names another brand is one. dryRun answers what would change. pending: the brand still holds changes the files lack, to export back. Takes setup on the project.
Scope: write.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Brand slug
Request Bodyrequired
Section titled “Request Bodyrequired”object
The brand’s files by path in its folder: brand.yaml, rules/.yaml, pages/.yaml. Others are left alone
object
The files under assets/ the brand’s files point at: path to asset id, or to the SHA-256 of its bytes (upload first)
object
The commit the files are at, when they are the repository’s: recorded as agreed, when the brand has a source
The commit’s message: its first line names the version the import makes
Check and merge, answer what would change, write nothing
Keep what changed here since the source last agreed (default); false takes the files whole
For a brand with no source: the files as you last had them from it (a pull, or your last push). What changed here since is kept
object
Examplegenerated
{ "files": { "additionalProperty": "example" }, "assets": { "additionalProperty": "example" }, "commit": "example", "message": "example", "dryRun": true, "merge": true, "base": { "additionalProperty": "example" }, "publish": true}Responses
Section titled “Responses”What changed
object
object
Something changed: a new version in the brand’s history
object
object
What changed: value, usage, label, spec, assets, type
object
Changed: the page’s own fields that changed (title, lede…)
Changed: its sections that changed, by id
object
Changed: which of its fields
Theme settings changed
The rules’ order changed
Pieces both sides changed differently: the files’ side was taken, this side’s is in the history
object
object
The brand holds changes the files lack: export them back
Example
{ "data": { "diff": { "rules": [ { "change": "added", "type": "color" } ], "pages": [ { "change": "added", "sections": [ { "change": "added" } ] } ] } }}Problems in the files
object
object
object
object
object
Files under assets/ to upload, then name in assets by SHA-256
Examplegenerated
{ "error": { "code": "example", "message": "example", "detail": { "errors": [ { "file": "example", "line": 1, "message": "example" } ], "warnings": [ { "file": "example", "line": 1, "message": "example" } ], "missing": [ "example" ] } }}default
Section titled “default”An error
object
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "detail": "example" }}