# Feature OP-1910 - [APIv3] CRUD operations for attachments

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-1910

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | 4.2.0 |
| Sprint |  |
| Backlog bucket |  |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module |  |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable | Jan Sandbrink |
| Product manager |  |
| Feature Lead |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

**As an** OpenProject user  
**I want to** create, read and delete attachments of work packages.  
**so that** I can use the work packages details pane.

### Acceptance criteria

  - new capabilities in APIv3:
      - create an attachment for an existing work package
      - list attachments of an existing work package
      - delete an existing attachment 
  - related permissions (if any) stay in effect
  - new APIv3 endpoints are documented properly
  - Note: like before it is **not** possible to update existing attachments, they are immutable
      - thus it should technically not be called CRUD, but CRD, which would be a horrible acronym

### out of scope

  - creating attachments without associated work package
  - creating attachments for anything but work packages

### Technical Solution Concept

**required endpoints**

  - `/api/v3/attachments/:id` (GET, DELETE)
  - `/api/v3/work_packages/:id/attachments` (GET, POST)

**changes to WP representer**

  - add link to own attachments

**changes attachments representer**

*rebuild from scratch*

  - links
      - `self`
      - `container` (i.e. the work package; might change in the future, e.g. n:m relation between container and attachment)
      - `author`
      - `downloadLocation` (immediate DL link)
  - properties
      - `id`
      - `filename` (e.g. `foo.png`; no path or internal details)
      - `description` (exposed as `Formattable`)
      - `createdAt`

**open technical questions**

  - do we need a `contentType` property for attachments?
  - do we need a `digest` property?
      - if yes I’d vote for a format with an interchangable digest algorithm, e.g. like our `Formattable` objects
