This page covers the write operations of the Specification API only. They are in the preview: check each operation's stage before you build on it.
A specification is created in one call, with its own chapters inside:
POST https://apis.traceone.com/spec/v2/food/specifications
POST https://apis.traceone.com/spec/v2/packaging/specifications- Everything the call creates exists after it, or nothing does. A refused value rejects the whole call with
422. - Shared objects are referenced by ID, not sent inline: library chapters, materials, packaging systems, requirements. Create them first, at their own address under
/library/, then reference them. - A new specification is private to your company until you share it (
POST .../share).
Create the leaves first:
- Materials and packaging components
- Library chapters and packaging systems
- Specifications that reference them
- Share
There is no call that updates a whole specification. Each chapter has its own PUT:
PUT https://apis.traceone.com/spec/v2/food/specifications/{specificationId}/labelling-chapter- Send the chapter's writable content. The description of each operation says what a missing section means.
- A library chapter is updated at its own address (
/library/...), not through a specification. The change is seen by every specification linked to it. - Attaching or replacing a library chapter on a specification is an action:
POST .../link.
Two writers in your company can change the same specification at the same time. To avoid overwriting someone else's change:
- Read the chapter with its
GET. Keep theETagresponse header. - Send it back in
If-Matchwith yourPUT. - If the specification changed since you read it, the answer is
412 Precondition Failed. Read the chapter again, apply your change to the new content, and retry.
GET https://apis.traceone.com/spec/v2/food/specifications/{specificationId}/labelling-chapter
→ 200 OK
ETag: "a1b2c3"
PUT https://apis.traceone.com/spec/v2/food/specifications/{specificationId}/labelling-chapter
If-Match: "a1b2c3"
→ 204 No Content (or 412 if it changed)After a successful PUT, read the chapter again to get its new ETag.
If-Match is optional. Without it, your PUT replaces the content whatever changed since you read it.
Business steps are action calls, not field updates: POST .../share, POST .../link.
Running an action again changes nothing and answers 204. A retried action is always safe.
| Call | On a timeout or 5xx |
|---|---|
PUT on a chapter | Retry: it sends the same content again |
Action (share, link) | Retry |
Create (POST .../specifications, POST /library/...) | Do not retry blindly: a lost answer may hide a successful create. Check whether the resource exists first |
A refused write answers 422. Read the error code:
| Code | Meaning | What to do |
|---|---|---|
UNPROCESSABLE_CONTENT | A value is refused. The error names the field | Fix the value |
INVALID_RESOURCE_STATE | The resource's state does not allow the write, for example the chapter is locked while the specification is in signature | Wait or fix the resource; the request itself is fine |
NAME_ALREADY_USED | The name of a library object is already used in your company | Pick another name |
The Specification API never answers 409. See Errors for the error body.
- Errors — status codes and the error body
- Specification preview — every write operation with its stage