# API contract - C/V/FS tagging Jira Ticket: https://workpathhq.atlassian.net/browse/DRA-407 Proposed data structure: ```json goal: { title: string, // the whole title, pure text titleTags: [ { startOffset: number, // the start index endOffset: number, // the end index type: string, // "value" || "customer" || "future_state" textValue: string, // the actual text value id: number // not 100% sure if this is needed, but may be helpful }, ... ], ... } ``` ## Questions 1. Should it be part of the GET draft goals response, or a separate endpoint? 2. Would BE sort the array in any way? Is it possible to keep the order that FE provides? 3. What will happen in case we need some API changes(due to some issues that we may find later, during the actual implementation)? 4. How to handle changes/updates? When a tag/highlight has been deleted, do we have to send a delete request, or should we just use a PATCH for the entire array (with whatever changes we want to include, including adding new tags, changing existing ones and deleting them)? ## Answers 1. Include it in the draft goals response. 2. BE can preserve the order provided by FE 3. Small changes can be done. ## Solutions: - Multiple endpoints for create, update and delete. FE will request one by one - One endpoint for batch create, update and delete. ```json { create: [...], update: [...], delete: [...] } ``` - One endpoint for batch create, and every time FE requests, all previous tags will be deleted and create new tags. ```json { goals: [{ id: 12, tags: [...] }] } ``` 1. POST /v2/draft_goals/ [{id:1, textValue: 'whatever'...}, {id: 2, textValue: 'hello'...}, {id: 3, textValue: "Something"}] tags: [{textValue: 'whatever ok'...}, { textValue: 'hello'...}, { textValue: 'Something'}]