Update metadata
PUT and PATCH /commerce/srrs/{tokenId}/metadata — replace or patch the metadata document of an issued SRR; set/append/prepend/insert, baseCid, 204.
PUT <base_url>/port/api/v1/commerce/srrs/{tokenId}/metadata — full replacement
PATCH <base_url>/port/api/v1/commerce/srrs/{tokenId}/metadata — partial update
Both routes end the same way: the new document is validated against its schema, pinned, and updateSRRMetadataWithCid is sent on chain. The SRR gets a new metadataDigest; every previous version stays in its metadata history. An update is not a transfer: the owner does not change.
Headers
commerce-api-key*
string
Commerce API Key
issuer-address*
string
Contract Address of API Key owner
Path
tokenId*
Decimal token id (digits only, at most 78)
Permissions
The LUW behind the API key must be the SRR's issuer or artist; on a collection, the collection owner is accepted as well. The owner of the SRR alone cannot update it. This is enforced when the typed data is built, after the document was checked.
PUT — replace the document
requestId
string
Optional idempotency key, same rule as issuance
payload.metadata*
object
The complete new document. $schema may be an official URL or a registered schema in any of the three forms
payload.collectionAddress
string
Required when the SRR lives on a collection; omit on the shared registry
The document stays on the schema version its $schema names (a registered schema is not moved to latest on update). Storage finalUrls anywhere in a registered-schema document become ipfs://<cid>; on the official schema the file-URL rules of issuance apply.
PATCH — change part of the document
gogh-api reads the current document, applies your changes, and continues exactly as PUT.
requestId
string
Optional idempotency key
payload.set
object
Top-level fields to set. A value replaces the whole field (no deep merge); null removes it; new fields are added. Applied first. $schema cannot be set here.
payload.append
object
{ "<field>": [entries] } — entries added at the end of a top-level array (created if absent)
payload.prepend
object
{ "<field>": [entries] } — entries put at the start, in the order given
payload.insert
object
{ "<field>": { "index": n, "entries": [entries] } } — index is the position the first entry takes; 0 = prepend, current length = append
payload.schema
string
Move the document to another schema version (CID or name form). Omitted = keep the current $schema
payload.baseCid
string
CID of the document to patch on top of — the metadataCID of your previous update. Omitted = the CID the subgraph currently holds
payload.collectionAddress
string
Required on a collection
At least one of set, append, prepend, insert, schema must be present.
Which to use
Add a history entry (newest first)
prepend.<field>
Add a history entry (oldest first)
append.<field>
Change one scalar or object field
set.<field>
Change one entry inside an array
set.<field> with the whole array
Remove a field
set.<field>: null
Add a field the current version does not allow
set plus schema naming the version that allows it
Rewrite everything
PUT
Automatic archiving of long histories
A registered schema can mark a top-level array so that gogh-api archives its oldest entries by itself when an add would push it past maxItems:
maxItems
the trigger: a PATCH that leaves more entries than this archives first
—
keep
entries that stay in the record after archiving, from the newest end, the ones just added included
1
ref
the field that receives the archive reference
archived<Field> (archivedBeneficiaries)
oldest
where the oldest entries sit: "last" for newest-first histories (prepend), "first" for append-style logs
"last"
When it triggers, in the same request: the oldest entries go to an archive file on IPFS — { "field", "entries" (record order), "archivedAt", "previous"?: the earlier reference, "record": { "tokenId", "collectionAddress"? } } — the record keeps the newest keep entries, and ref is set to { "cid", "count", "archivedAt" } where count is the length of the whole chain (this file and every previous one). The response lists it under archived (field, ref, cid, metadataURL, entries, count). Readers walk the chain through previous.
An entry is never archived on arrival: a request that adds more entries than keep is refused. Official schemas, registered schemas without the keyword and patches that stay within maxItems are not affected; PUT never archives. The file is pinned before the record is validated, so a patch refused afterwards leaves an unreferenced, harmless file behind.
Responses
previousMetadataCID
PATCH only. The CID the change was applied to (your baseCid, or what the subgraph held).
tokenId
The SRR
collectionAddress
Lower-cased collection address, null on the shared registry
metadataCID
CID of the new document. Pass it as baseCid on the next patch
metadataURL
The new document on the CDN gateway
txReceiptId
Receipt id of the on-chain transaction, when startrail-api returned one
No body. The request leaves the document exactly as it is — the new document's CID equals the current one (for PATCH: equals baseCid or the subgraph's CID). Nothing was pinned, nothing was sent, the metadata history has no new entry. Examples: a PUT with the current document, a set with the value the field already has, a document that differs only by a storage URL of a file it already holds as ipfs://<cid>.
The 200 means accepted. The subgraph shows the new metadataDigest once the transaction is mined; see subgraph lag.
Examples
Errors
Every refusal happens before anything is pinned or sent; a refused request changes nothing.
401
Missing header / API Key is not valid for <issuer-address>
Headers
400
tokenId must be a decimal token id (got "<value>")
Path param not digits
400
payload must contain at least one of set, append, prepend, insert, schema
Empty PATCH
400
baseCid must be the metadataCID of the document to patch on top of
baseCid is not a CID string
400
change the schema with payload.schema, not set.$schema
$schema in set
400
append.<field> must be an array / prepend.<field> must be an array / insert.<field>.entries must be an array
Entries not an array
400
insert.<field> must be an object with index and entries
Malformed insert
400
insert.<field>.index must be an integer from 0 to <length>, the current length of <field>
Index out of range
400
<field> is the target of both <op1> and <op2>: a field takes one array operation per request
Two array operations on one field
400
<op>.<field>: the current value of <field> is not an array
Array operation on a scalar or object field
400
metadata exceeds the maximum size of 204800 bytes (serialized size: <n> bytes)
The merged (PATCH) or new (PUT) document is too large
400
<field>: the request adds <n> entries but the schema keeps <keep> after archiving (x-archive); add fewer entries per request
Automatic archiving would have to archive an entry this request added
400
the schema's x-archive on <field> is invalid: <reason>
The registered schema's archiving declaration is malformed (fix the schema)
502
schema document <cid> could not be fetched from the IPFS gateway
The schema document needed for archiving is not reachable right now; retry
400
metadata for token <tokenId> is invalid. $schema path is invalid, cid is not found (no published registry schema for ipfs://<cid>) / … file is not found (no published registry schema named <name> v<version>)
Registered $schema (or payload.schema) not published
400
metadata for token <tokenId> is invalid. Details: <path> <message> (<params>). …
Official-schema document fails common-js validation
400
metadata for token <tokenId> is invalid. metadata failed validation against JSON schema. Details: <path> <message> (<params>). …
Registered-schema document breaks its schema (pinned form) — e.g. a set field the current version does not allow
400
… Details: refers to a file that is not in storage ({"url":"<url>"}). / … refers to a file whose CID is not calculated yet, retry shortly ({"url":"<url>"}).
Storage URL problems
400
Duplicate Request Error: Same requestId already logged
requestId reused
400
Request Content Error: Current request already logged with status in_progress / successful
Same body for the same token already running or done
403
Licensed user <issuer-address> is not enabled for registered metadata schemas
Closed release
404
SRR <tokenId> not found or has no metadata / SRR <tokenId> on <collectionAddress> not found or has no metadata
Unknown token, wrong or missing collectionAddress, or not indexed yet
404
no metadata document for <cid>: <reason>
baseCid is a well-formed CID that nothing resolves
4xx
<message> passed through
startrail-api refused the update (permissions, token on its side) — see the catalogue
500
STARTRAIL_ERROR: <reason> / schema registry resolution failed / <startrail-api message>
Signing, transport, registry or startrail-api failure
Last updated
Was this helpful?