Surfaces
Publishing surfaces
Create a surface and upload versions through the API.
All calls use an API key with the surfaces:write scope (bearer token). Reading works with traces:read or surfaces:write. A key acts with the real role of its creator in the key's namespace: members manage their own private surfaces, admins can also publish.
HTML rules
One file, at most 16 MiB, containing a <head>. These are rejected: <iframe>, <link>, @import and <script src=...>. Inline all CSS and JavaScript.
Flow
- Create the surface (once):
curl -X POST https://adtraces.adfactory.app/v1/namespaces/<slug>/surfaces \
-H "Authorization: Bearer $TRACES_API_KEY" -H "Content-Type: application/json" \
-d '{"key":"cost-chart","name":"Cost chart","description":"Token cost per turn","icon":"chart"}'- Ask for an upload target. The version label must be new,
byteSizeis the exact size of your HTML in bytes:
curl -X POST https://adtraces.adfactory.app/v1/surfaces/cost-chart/versions/uploads \
-H "Authorization: Bearer $TRACES_API_KEY" -H "Content-Type: application/json" \
-d '{"version":"1.0.0","byteSize":12345}'The answer holds upload.url (single use, valid for 10 minutes, no token needed).
- Send the file to that URL. The body must have exactly the announced size. The answer holds
data.artifactId:
curl -X POST "<upload.url>" -H "Content-Type: text/html" --data-binary @surface.html- Complete the upload with that ID. This creates the immutable version but does not make it current:
curl -X POST https://adtraces.adfactory.app/v1/surfaces/cost-chart/versions/uploads/complete \
-H "Authorization: Bearer $TRACES_API_KEY" -H "Content-Type: application/json" -d '{"version":"1.0.0","artifactId":"<artifactId>"}'The response returns the version and the surface with its versions. Make it current with the PATCH below.
Manage
# Rename, change the current version, publish (admins only) or archive
curl -X PATCH https://adtraces.adfactory.app/v1/surfaces/cost-chart \
-H "Authorization: Bearer $TRACES_API_KEY" -H "Content-Type: application/json" \
-d '{"currentVersion":"1.0.0","publishStatus":"public"}'
curl https://adtraces.adfactory.app/v1/surfaces/cost-chart -H "Authorization: Bearer $TRACES_API_KEY"
curl https://adtraces.adfactory.app/v1/surfaces -H "Authorization: Bearer $TRACES_API_KEY" # marketplace
curl https://adtraces.adfactory.app/v1/pinned-surfaces -H "Authorization: Bearer $TRACES_API_KEY" # your pinsPUT /v1/pinned-surfaces replaces the whole pin list: {"keys":["cost-chart"]}, up to 20 keys. Versions are immutable; to change the HTML, upload a new version.
Patchable fields: name, description, icon, currentVersion, publishStatus (private or public), archived (boolean).