Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#62363] updated and formatted API spec

Eric Schubertd85f4670cd6c
diff --git a/docs/api/apiv3/components/examples/activity_response.yml b/docs/api/apiv3/components/examples/activity_response.yml
new file mode 100644
index 00000000000..b424c9e77af
--- /dev/null
+++ b/docs/api/apiv3/components/examples/activity_response.yml
@@ -0,0 +1,39 @@
+description: |-
+ A simple response example for an activity comment.
+value:
+ _type: Activity::Comment
+ id: 1478
+ comment:
+ format: markdown
+ raw: "I can give you a CR70 corvette, you have to make do, Leia..."
+ html: "<p class=\"op-uc-p\">I can give you a CR70 corvette, you have to make do, Leia...</p>"
+ details: [ ]
+ version: 4
+ createdAt: "2025-04-17T13:54:40.737Z"
+ updatedAt: "2025-04-17T13:54:40.737Z"
+ _embedded:
+ attachments:
+ _type: Collection
+ total: 1
+ count: 1
+ _hint: Attachments resource shortened for brevity.
+ workPackage:
+ id: 207
+ _type: WorkPackage
+ _hint: Work package resource shortened for brevity.
+ _links:
+ attachments:
+ href: "/api/v3/activities/1478/attachments"
+ addAttachment:
+ href: "/api/v3/activities/1478/attachments"
+ method: post
+ self:
+ href: "/api/v3/activities/1478"
+ workPackage:
+ href: "/api/v3/work_packages/207"
+ title: Recover Death Star blueprints
+ user:
+ href: "/api/v3/users/33"
+ update:
+ href: "/api/v3/activities/1478"
+ method: patch
diff --git a/docs/api/apiv3/components/schemas/activity_comment_write_model.yml b/docs/api/apiv3/components/schemas/activity_comment_write_model.yml
new file mode 100644
index 00000000000..bfd993e0c61
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/activity_comment_write_model.yml
@@ -0,0 +1,6 @@
+# Schema: ActivityCommentWriteModel
+---
+type: object
+properties:
+ comment:
+ type: string
diff --git a/docs/api/apiv3/components/schemas/activity_model.yml b/docs/api/apiv3/components/schemas/activity_model.yml
index cd34460005a..08b64638fb7 100644
--- a/docs/api/apiv3/components/schemas/activity_model.yml
+++ b/docs/api/apiv3/components/schemas/activity_model.yml
@@ -2,108 +2,96 @@
---
type: object
properties:
- _embedded:
- type: object
- properties:
- attachments:
- allOf:
- - "$ref": "./attachments_model.yml"
- - description: |-
- Collection of attachments for this activity
- workPackage:
- allOf:
- - "$ref": "./work_package_model.yml"
- - description: |-
- The work package this activity belongs to
-
- # Conditions
-
- Only embedded when the journable of the activity is a work package
+ _type:
+ type: string
+ enum:
+ - "Activity::Comment"
id:
type: integer
description: Activity id
- readOnly: true
- exclusiveMinimum: 0
+ minimum: 1
version:
type: integer
description: Activity version
- readOnly: true
- exclusiveMinimum: 0
+ minimum: 1
comment:
- allOf:
- - "$ref": "./formattable.yml"
- - {}
+ $ref: './formattable.yml'
details:
type: array
- readOnly: true
items:
- allOf:
- - "$ref": "./formattable.yml"
+ $ref: './formattable.yml'
createdAt:
type: string
format: date-time
description: Time of creation
- readOnly: true
updatedAt:
type: string
format: date-time
description: Time of update
- readOnly: true
+ _embedded:
+ type: object
+ properties:
+ attachments:
+ allOf:
+ - $ref: './attachments_model.yml'
+ - description: Collection of attachments for this activity
+ workPackage:
+ allOf:
+ - $ref: './work_package_model.yml'
+ - description: |-
+ The work package this activity belongs to
+
+ # Conditions
+
+ Only embedded when the `journable` of the activity is a work package
_links:
type: object
properties:
self:
allOf:
- - "$ref": "./link.yml"
+ - $ref: './link.yml'
- description: |-
This activity
**Resource**: Activity
- readOnly: true
workPackage:
allOf:
- - "$ref": "./link.yml"
+ - $ref: './link.yml'
- description: |-
The work package this activity belongs to
**Resource**: WorkPackage
- readOnly: true
user:
allOf:
- - "$ref": "./link.yml"
+ - $ref: './link.yml'
- description: |-
The user who created this activity
- **Resource**: User
- readOnly: true
+ **Resource**: Principal
update:
allOf:
- - "$ref": "./link.yml"
- - description: |-
- Update this activity
-
- **Method**: PATCH
-
- **Resource**: Activity
+ - $ref: './link.yml'
+ - description: Update this activity
attachments:
allOf:
- - "$ref": "./link.yml"
+ - $ref: './link.yml'
- description: |-
The attachment collection of this activity
- **Resource**: AttachmentCollection
- readOnly: true
+ **Resource**: Attachments
addAttachment:
allOf:
- - "$ref": "./link.yml"
+ - $ref: './link.yml'
- description: |-
Attach a file to the activity
# Conditions
- **Permission**: add_work_package_notes or add_comments_with_restricted_visibility (for internal comments)
- readOnly: true
+ **Permissions**:
+ - `add_work_package_notes`
+ - for internal comments: `add_comments_with_restricted_visibility`
example:
+ id: 1
_type: Activity::Comment
_embedded:
attachments:
@@ -199,11 +187,10 @@ example:
update:
href: "/api/v3/activities/1"
method: "patch"
- id: 1
details:
- - format: markdown
- raw: Lorem ipsum dolor sit amet.
- html: "<p>Lorem ipsum dolor sit amet.</p>"
+ - format: markdown
+ raw: Lorem ipsum dolor sit amet.
+ html: "<p>Lorem ipsum dolor sit amet.</p>"
comment:
format: markdown
raw: Lorem ipsum dolor sit amet.
diff --git a/docs/api/apiv3/components/schemas/file_upload_form.yml b/docs/api/apiv3/components/schemas/file_upload_form.yml
new file mode 100644
index 00000000000..53ea6e9b582
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/file_upload_form.yml
@@ -0,0 +1,12 @@
+# Schema: FileUploadForm
+---
+type: object
+properties:
+ metadata:
+ type: object
+ properties:
+ fileName:
+ type: string
+ file:
+ type: string
+ format: binary
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index da780ff6145..e2380b8abb6 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -491,6 +491,8 @@ paths:
components:
examples:
+ ActivityResponse:
+ $ref: "./components/examples/activity_response.yml"
DateAlertNotification:
$ref: "./components/examples/date_alert_notification.yml"
GridSimpleCollectionResponse:
@@ -609,6 +611,8 @@ components:
schemas:
ActivityModel:
"$ref": "./components/schemas/activity_model.yml"
+ ActivityCommentWriteModel:
+ "$ref": "./components/schemas/activity_comment_write_model.yml"
AttachmentModel:
"$ref": "./components/schemas/attachment_model.yml"
Attachments_Model:
@@ -673,6 +677,8 @@ components:
$ref: "./components/schemas/file_link_read_model.yml"
FileLinkWriteModel:
$ref: "./components/schemas/file_link_write_model.yml"
+ FileUploadForm:
+ $ref: "./components/schemas/file_upload_form.yml"
Formattable:
"$ref": "./components/schemas/formattable.yml"
GridCollectionModel:
diff --git a/docs/api/apiv3/paths/activity.yml b/docs/api/apiv3/paths/activity.yml
index ca10e327c70..1afe5a92578 100644
--- a/docs/api/apiv3/paths/activity.yml
+++ b/docs/api/apiv3/paths/activity.yml
@@ -1,150 +1,89 @@
# /api/v3/activities/{id}
---
get:
+ summary: Get an activity
+ operationId: get_activity
+ tags:
+ - Activities
+ description: Returns the requested activity resource identified by its unique id.
parameters:
- - description: Activity id
- example: '1'
- in: path
- name: id
- required: true
- schema:
- type: integer
+ - name: id
+ description: Activity id
+ in: path
+ required: true
+ schema:
+ type: integer
+ example: '1'
responses:
'200':
+ description: OK
content:
application/hal+json:
+ schema:
+ $ref: '../components/schemas/activity_model.yml'
examples:
response:
- value:
- _links:
- self:
- href: "/api/v3/activity/1"
- title: Priority changed from High to Low
- user:
- href: "/api/v3/users/1"
- title: John Sheppard - admin
- workPackage:
- href: "/api/v3/work_packages/1"
- title: quis numquam qui voluptatum quia praesentium blanditiis
- nisi
- _type: Activity::Comment
- comment:
- format: markdown
- html: "<p>Lorem ipsum dolor sit amet.</p>"
- raw: Lorem ipsum dolor sit amet.
- createdAt: '2014-05-21T08:51:20.396Z'
- updatedAt: '2014-05-21T09:14:02.300Z'
- details:
- - format: markdown
- html: "<p>Lorem ipsum dolor sit amet.</p>"
- raw: Lorem ipsum dolor sit amet.
- id: 1
- version: 31
- schema:
- "$ref": "../components/schemas/activity_model.yml"
- description: OK
- headers: {}
- tags:
- - Activities
- description: ''
- operationId: View_activity
- summary: View activity
+ $ref: '../components/examples/activity_response.yml'
+
patch:
+ summary: Update activity
+ operationId: update_activity
+ tags:
+ - Activities
+ description: Updates an activity's comment and, on success, returns the updated activity.
parameters:
- - description: Activity id
- example: '1'
- in: path
- name: id
- required: true
- schema:
- type: integer
+ - name: id
+ description: Activity id
+ in: path
+ required: true
+ schema:
+ type: integer
+ example: '1'
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '../components/schemas/activity_comment_write_model.yml'
responses:
'200':
+ description: OK
content:
application/hal+json:
+ schema:
+ $ref: '../components/schemas/activity_model.yml'
examples:
response:
- value:
- _links:
- self:
- href: "/api/v3/activity/1"
- title: Priority changed from High to Low
- user:
- href: "/api/v3/users/1"
- title: John Sheppard - admin
- workPackage:
- href: "/api/v3/work_packages/1"
- title: quis numquam qui voluptatum quia praesentium blanditiis
- nisi
- _type: Activity::Comment
- comment:
- format: markdown
- html: "<p>Lorem ipsum dolor sit amet.</p>"
- raw: Lorem ipsum dolor sit amet.
- createdAt: '2014-05-21T08:51:20.396Z'
- updatedAt: '2014-05-21T09:14:02.776Z'
- details:
- - format: markdown
- html: "<p>Lorem ipsum dolor sit amet.</p>"
- raw: Lorem ipsum dolor sit amet.
- id: 1
- version: 31
- schema:
- "$ref": "../components/schemas/activity_model.yml"
- description: OK
- headers: {}
+ $ref: '../components/examples/activity_response.yml'
'400':
- $ref: "../components/responses/invalid_request_body.yml"
+ $ref: '../components/responses/invalid_request_body.yml'
'403':
+ description: |-
+ Returned if the client does not have sufficient permissions.
+
+ **Required permission:** edit journals
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
+ $ref: '../components/schemas/error_response.yml'
examples:
response:
value:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not allowed to edit the comment of this journal entry.
- description: |-
- Returned if the client does not have sufficient permissions.
-
- **Required permission:** edit journals
- headers: {}
'406':
- $ref: "../components/responses/missing_content_type.yml"
+ $ref: '../components/responses/missing_content_type.yml'
'415':
- $ref: "../components/responses/unsupported_media_type.yml"
+ $ref: '../components/responses/unsupported_media_type.yml'
'422':
+ description: Returned if the client tries to modify a read-only property.
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
+ $ref: '../components/schemas/error_response.yml'
examples:
response:
value:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:PropertyIsReadOnly
message: The ID of an activity can't be changed.
- description: Returned if the client tries to modify a read-only property.
- headers: {}
- tags:
- - Activities
- description: Updates an activity's comment and, on success, returns the updated
- activity.
- operationId: Update_activity
- requestBody:
- content:
- application/json:
- schema:
- example:
- comment:
- raw: The updated comment
- properties:
- comment:
- properties:
- raw:
- type: string
- type: object
- type: object
- summary: Update activity
diff --git a/docs/api/apiv3/paths/activity_attachments.yml b/docs/api/apiv3/paths/activity_attachments.yml
index bae39a4b928..348c73d9806 100644
--- a/docs/api/apiv3/paths/activity_attachments.yml
+++ b/docs/api/apiv3/paths/activity_attachments.yml
@@ -1,66 +1,32 @@
# /api/v3/activities/{id}/attachments
---
get:
+ summary: List attachments by activity
+ operationId: list_activity_attachments
+ tags:
+ - Activities
+ - Attachments
+ description: List all attachments of a single activity.
parameters:
- - description: ID of the activity whose attachments will be listed
- example: '1'
+ - name: id
+ description: ID of the activity whose attachments will be listed
in: path
- name: id
required: true
schema:
type: integer
+ example: '1'
responses:
'200':
+ description: OK
content:
application/hal+json:
- examples:
- response:
- value:
- _embedded:
- elements:
- - _links:
- self:
- href: "/api/v3/attachments/30389"
- title: "Screenshot.png"
- author:
- href: "/api/v3/users/435"
- title: "Test User"
- staticDownloadLocation:
- href: "/api/v3/attachments/30389/content"
- downloadLocation:
- href: "/api/v3/attachments/30389/content"
- delete:
- href: "/api/v3/attachments/30389"
- method: delete
- _type: Attachment
- id: 30389
- fileName: "Screenshot.png"
- fileSize: 187760
- description:
- format: plain
- html: ''
- raw: ''
- status: "uploaded"
- contentType: image/png
- digest:
- algorithm: md5
- hash: cdd548290edfc1486c180585889dcea8
- createdAt: '2025-04-10T11:19:41.821Z'
- _links:
- self:
- href: "/api/v3/activities/79093/attachments"
- _type: Collection
- count: 1
- total: 1
schema:
- "$ref": "../components/schemas/attachments_model.yml"
- description: OK
- headers: {}
+ $ref: '../components/schemas/attachments_model.yml'
'404':
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
+ $ref: '../components/schemas/error_response.yml'
examples:
response:
value:
@@ -71,111 +37,75 @@ get:
Returned if the activity does not exist or the client does not have sufficient permissions
to see it.
- **Required permission:** view_work_packages or view_comments_with_restricted_visibility (for internal comments)
+ **Required permission:**
+ - `view_work_packages`
+ - for internal comments: `view_comments_with_restricted_visibility`
*Note: A client without sufficient permissions shall not be able to test for the existence of an activity.
That's why a 404 is returned here, even if a 403 might be more appropriate.*
- headers: {}
- tags:
- - Attachments
- description: ''
- operationId: List_attachments_by_activity
- summary: List attachments by activity
+
post:
+ summary: Add attachment to activity
+ operationId: create_activity_attachment
+ tags:
+ - Activities
+ - Attachments
+ description: Adds an attachment to the specified activity.
parameters:
- - description: ID of the activity to receive the attachment
- example: '1'
+ - name: id
+ description: ID of the activity to receive the attachment
in: path
- name: id
required: true
schema:
type: integer
+ example: '1'
+ requestBody:
+ content:
+ multipart/form-data:
+ schema:
+ $ref: '../components/schemas/file_upload_form.yml'
responses:
'200':
- content:
- application/hal+json:
- schema:
- $ref: "../components/schemas/attachment_model.yml"
- examples:
- response:
- value:
- _type: Attachment
- id: 30389
- fileName: "Screenshot.png"
- fileSize: 187760
- description:
- format: plain
- html: ''
- raw: ''
- status: "uploaded"
- contentType: image/png
- digest:
- algorithm: md5
- hash: cdd548290edfc1486c180585889dcea8
- createdAt: '2025-04-10T11:19:41.821Z'
- _links:
- self:
- href: "/api/v3/attachments/30389"
- title: "Screenshot.png"
- author:
- href: "/api/v3/users/435"
- title: "Test User"
- staticDownloadLocation:
- href: "/api/v3/attachments/30389/content"
- downloadLocation:
- href: "/api/v3/attachments/30389/content"
- delete:
- href: "/api/v3/attachments/30389"
- method: delete
description: OK
- headers: {}
- '400':
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
- examples:
- response:
- value:
- _type: Error
- errorIdentifier: urn:openproject-org:api:v3:errors:InvalidRequestBody
- message: The request could not be parsed as JSON.
+ $ref: '../components/schemas/attachment_model.yml'
+ '400':
description: |-
Returned if the client sends a not understandable request. Reasons include:
* Omitting one of the required parts (metadata and file)
* sending unparsable JSON in the metadata part
- headers: {}
- '403':
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
+ $ref: '../components/schemas/error_response.yml'
examples:
response:
value:
_type: Error
- errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
- message: You are not allowed to add attachments to this activity.
+ errorIdentifier: urn:openproject-org:api:v3:errors:InvalidRequestBody
+ message: The request could not be parsed as JSON.
+ '403':
description: |-
Returned if the client does not have sufficient permissions.
**Required permission:** view_work_packages or view_comments_with_restricted_visibility (for internal comments)
*Note that you will only receive this error, if you are at least allowed to see the activity*
- headers: {}
- '404':
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
+ $ref: '../components/schemas/error_response.yml'
examples:
response:
value:
_type: Error
- errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
- message: The requested resource could not be found.
+ errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
+ message: You are not allowed to add attachments to this activity.
+ '404':
description: |-
Returned if the activity does not exist or the client does not have sufficient permissions
to see it.
@@ -184,22 +114,21 @@ post:
*Note: A client without sufficient permissions shall not be able to test for the existence of an activity.
That's why a 404 is returned here, even if a 403 might be more appropriate.*
- headers: {}
- '406':
- $ref: "../components/responses/missing_content_type.yml"
- '415':
- $ref: "../components/responses/unsupported_media_type.yml"
- '422':
content:
application/hal+json:
schema:
- $ref: "../components/schemas/error_response.yml"
+ $ref: '../components/schemas/error_response.yml'
examples:
response:
value:
_type: Error
- errorIdentifier: urn:openproject-org:api:v3:errors:PropertyConstraintViolation
- message: File is too large (maximum size is 5242880 Bytes).
+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
+ message: The requested resource could not be found.
+ '406':
+ $ref: '../components/responses/missing_content_type.yml'
+ '415':
+ $ref: '../components/responses/unsupported_media_type.yml'
+ '422':
description: |-
Returned if the client tries to send an invalid attachment.
Reasons are:
@@ -207,11 +136,13 @@ post:
* Omitting the file name (`fileName` property of metadata part)
* Sending a file that is too large
- headers: {}
- tags:
- - Attachments
- description: |-
- Adds an attachment to the activity.
-
- operationId: Add_attachment_to_activity
- summary: Add attachment to activity
+ content:
+ application/hal+json:
+ schema:
+ $ref: '../components/schemas/error_response.yml'
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:PropertyConstraintViolation
+ message: File is too large (maximum size is 5242880 Bytes).