Using the Portal Files API

The Portal Files API can be used as an alternative to the Portal CLI to manage dev portal content. Portal content must maintain a specific structure to render correctly, so it is generally recommended to use the CLI because it enforces that structure. The Portal Files API is useful for smaller tasks such as managing specification, content, or theme files outside the context of kong-portal-templates.

ParameterTypeDescriptionRequiredExamples
pathstringThe path to the file.yescontent/example.txt, specs/petstore.json, themes/base/layouts/index.html
contentsstringThe contents of the file.yescontents=@<file-location>.html, contents=@<spec-location>.json, contents=@<partial-location>.html

Note: The @ symbol in a command automatically reads the file on disk and places its contents into the contents argument.

POST a Content File

For more details about content files, see the Content File documentation.

Using cURL

Using HTTPie

  1. $ curl -X POST http://<admin-hostname>:8001/default/files \
  2. -F "path=content/homepage.html" \
  3. -F "contents=@<file-location>.json"
  1. $ http post :8001/default/files \
  2. path=content/homepage.html \
  3. contents=@<file-location>.html

POST a Spec File

For more details about specification files, see the Spec File documentation.

Using cURL

Using HTTPie

  1. $ curl -X POST http://<admin-hostname>:8001/default/files \
  2. -F "path=specs/homepage.json" \
  3. -F "contents=@<spec-location>.json"
  1. $ http post :8001/default/files \
  2. path=specs/homepage.json \
  3. contents=@<spec-location>.json

POST a Theme File

For more details about theme files, see the Theme File documentation.

Using cURL

Using HTTPie

  1. $ curl -X POST http://<admin-hostname>:8001/default/files \
  2. -F "path=themes/base/partials/header.html" \
  3. -F "contents=@<partial-location>.html"
  1. $ http post :8001/default/files \
  2. path=themes/base/partials/header.html \
  3. contents=@<partial-location>.html

GET a File

Using cURL

Using HTTPie

  1. $ curl -X GET http://<admin-hostname>:8001/default/files/content/index.txt
  1. $ http :8001/default/files/content/index.txt

PATCH a File

Using cURL

Using HTTPie

  1. $ curl -X PATCH http://<admin-hostname>:8001/default/files/content/index.txt \
  2. -F "contents=@<updated-content-file-location>.txt"
  1. $ http patch :8001/default/files/content/index.txt \
  2. contents=@<updated-content-file-location>.txt

DELETE a File

Using cURL

Using HTTPie

  1. $ curl -X DELETE http://<admin-hostname>:8001/default/files/content/index.txt
  1. $ http delete :8001/default/files/content/index.txt